Add a helper for HTTP GET

and use hex value for dump dir mode in configure

Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
This commit is contained in:
Matej Habrnal 2015-08-26 15:53:03 +02:00
parent 042ef11f33
commit 9926ac3d6a
3 changed files with 112 additions and 1 deletions

View File

@ -0,0 +1,69 @@
From 85e6d59c4c9aeabb16cb9e0c68f13933b2c7ed7b Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Tue, 25 Aug 2015 15:49:13 +0200
Subject: [PATCH] curl: add a helper for HTTP GET
Please do not think I am an idiot but I really do not see any better way
to enable ABRT to use HTTP GET through libreport helper functions.
Related: rhbz#1256493
Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
src/include/libreport_curl.h | 10 ++++++++++
src/lib/curl.c | 4 ++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/include/libreport_curl.h b/src/include/libreport_curl.h
index 4b41ecc..5478fa6 100644
--- a/src/include/libreport_curl.h
+++ b/src/include/libreport_curl.h
@@ -70,6 +70,7 @@ enum {
POST_DATA_FROMFILE_PUT = -3,
POST_DATA_FROMFILE_AS_FORM_DATA = -4,
POST_DATA_STRING_AS_FORM_DATA = -5,
+ POST_DATA_GET = -6,
};
int
post(post_state_t *state,
@@ -79,6 +80,15 @@ post(post_state_t *state,
const char *data,
off_t data_size);
static inline int
+get(post_state_t *state,
+ const char *url,
+ const char *content_type,
+ const char **additional_headers)
+{
+ return post(state, url, content_type, additional_headers,
+ NULL, POST_DATA_GET);
+}
+static inline int
post_string(post_state_t *state,
const char *url,
const char *content_type,
diff --git a/src/lib/curl.c b/src/lib/curl.c
index f7321b5..c927ece 100644
--- a/src/lib/curl.c
+++ b/src/lib/curl.c
@@ -351,7 +351,7 @@ post(post_state_t *state,
xcurl_easy_setopt_ptr(handle, CURLOPT_PASSWORD, (state->password ? state->password : ""));
}
- if (data_size != POST_DATA_FROMFILE_PUT)
+ if (data_size != POST_DATA_FROMFILE_PUT && data_size != POST_DATA_GET)
{
// Do a HTTP POST. This also makes curl use
// a "Content-Type: application/x-www-form-urlencoded" header.
@@ -459,7 +459,7 @@ post(post_state_t *state,
error_msg_and_die("out of memory or read error (curl_formadd error code: %d)", (int)curlform_err);
xcurl_easy_setopt_ptr(handle, CURLOPT_HTTPPOST, post);
}
- else
+ else if (data_size != POST_DATA_GET)
{
// ...from a blob in memory
xcurl_easy_setopt_ptr(handle, CURLOPT_POSTFIELDS, data);
--
2.5.0

View File

@ -0,0 +1,36 @@
From 9f32aba65d3d56e42f22f6b4709fd5cfd8b93f4c Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Wed, 26 Aug 2015 08:30:14 +0200
Subject: [PATCH] configure: use hex value for dump dir mode
The hex value is hard to understand but is supported by all languages
(Python, C, ...).
The octal value is an invalid token in Python3.
The value is exported in libreport pkg-config file and projects like
ABRT use the value in their source files (sed 's/.../.../').
Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
configure.ac | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 81a5ada..c7b9ef8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -316,8 +316,8 @@ AC_PATH_PROG(AUGPARSE, augparse, no)
AC_ARG_WITH([defaultdumpdirmode],
AS_HELP_STRING([--with-defaultdumpdirmode=OCTAL-MODE],
- [Default dump dir mode (default: 0640)]),
- [], [with_defaultdumpdirmode="0640"])
+ [Default dump dir mode (default: 0x1A0 (0640))]),
+ [], [with_defaultdumpdirmode="0x1A0"])
AC_SUBST([DEFAULT_DUMP_DIR_MODE], [$with_defaultdumpdirmode])
DUMP_DIR_OWNED_BY_USER=1
--
2.5.0

View File

@ -7,7 +7,7 @@
Summary: Generic library for reporting various problems
Name: libreport
Version: 2.6.2
Release: 3%{?dist}
Release: 4%{?dist}
License: GPLv2+
Group: System Environment/Libraries
URL: https://abrt.readthedocs.org/
@ -19,6 +19,8 @@ Source1: autogen.sh
Patch0001: 0001-Use-a-dgettext-function-returning-strings-instead-of.patch
Patch0002: 0002-dd-stop-warning-about-corrupted-mandatory-files.patch
Patch0003: 0003-dd-don-t-warn-about-missing-type-if-the-locking-fail.patch
Patch0004: 0004-curl-add-a-helper-for-HTTP-GET.patch
Patch0005: 0005-configure-use-hex-value-for-dump-dir-mode.patch
# git is need for '%%autosetup -S git' which automatically applies all the
# patches above. Please, be aware that the patches must be generated
@ -735,6 +737,10 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%changelog
* Wed Aug 26 2015 Matej Habrnal <mhabrnal@redhat.com> 2.6.2-4
- add a helper for HTTP GET
- configure: use hex value for dump dir mode
* Fri Aug 14 2015 Matej Habrnal <mhabrnal@redhat.com> 2.6.2-3
- don't warn about missing 'type' if the locking fails
- stop warning about corrupted mandatory files