[libsoup] SoupRequest*, SoupHTTPInputStream: misc cleanups
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] SoupRequest*, SoupHTTPInputStream: misc cleanups
- Date: Mon, 24 Oct 2011 01:11:32 +0000 (UTC)
commit ed330af3e61a22a383c78a0c069a99f8e45f6f94
Author: Dan Winship <danw gnome org>
Date: Sat Oct 22 15:20:07 2011 -0400
SoupRequest*, SoupHTTPInputStream: misc cleanups
libsoup/soup-http-input-stream.c | 36 +++++++++++++-----------------------
libsoup/soup-request-file.c | 8 +++-----
libsoup/soup-request-http.c | 3 +--
libsoup/soup-request.c | 6 ++++--
4 files changed, 21 insertions(+), 32 deletions(-)
---
diff --git a/libsoup/soup-http-input-stream.c b/libsoup/soup-http-input-stream.c
index 7697c12..a4c8c2a 100644
--- a/libsoup/soup-http-input-stream.c
+++ b/libsoup/soup-http-input-stream.c
@@ -223,7 +223,7 @@ soup_http_input_stream_got_headers (SoupMessage *msg, gpointer stream)
static void
soup_http_input_stream_got_chunk (SoupMessage *msg, SoupBuffer *chunk_buffer,
- gpointer stream)
+ gpointer stream)
{
SoupHTTPInputStreamPrivate *priv = SOUP_HTTP_INPUT_STREAM_GET_PRIVATE (stream);
const gchar *chunk = chunk_buffer->data;
@@ -392,10 +392,6 @@ static void
send_sync_finished (GInputStream *stream)
{
SoupHTTPInputStreamPrivate *priv = SOUP_HTTP_INPUT_STREAM_GET_PRIVATE (stream);
- GError *error = NULL;
-
- if (!g_cancellable_set_error_if_cancelled (priv->cancellable, &error))
- set_error_if_http_failed (priv->msg, &error);
priv->got_headers_cb = NULL;
priv->finished_cb = NULL;
@@ -497,7 +493,7 @@ wrapper_callback (GObject *source_object, GAsyncResult *res,
g_input_stream_clear_pending (stream);
if (priv->outstanding_callback)
- (*priv->outstanding_callback)(source_object, res, user_data);
+ (*priv->outstanding_callback) (source_object, res, user_data);
priv->outstanding_callback = NULL;
g_object_unref (stream);
}
@@ -520,10 +516,8 @@ send_async_finished (GInputStream *stream)
priv->result = NULL;
g_simple_async_result_set_op_res_gboolean (result, error == NULL);
- if (error) {
- g_simple_async_result_set_from_error (result, error);
- g_error_free (error);
- }
+ if (error)
+ g_simple_async_result_take_error (result, error);
g_simple_async_result_complete (result);
g_object_unref (result);
}
@@ -577,11 +571,10 @@ soup_http_input_stream_send_async (SoupHTTPInputStream *httpstream,
g_return_if_fail (SOUP_IS_HTTP_INPUT_STREAM (httpstream));
if (!g_input_stream_set_pending (istream, &error)) {
- g_simple_async_report_gerror_in_idle (G_OBJECT (httpstream),
- callback,
- user_data,
- error);
- g_error_free (error);
+ g_simple_async_report_take_gerror_in_idle (G_OBJECT (httpstream),
+ callback,
+ user_data,
+ error);
return;
}
soup_http_input_stream_send_async_internal (istream, io_priority, cancellable,
@@ -629,10 +622,9 @@ read_async_done (GInputStream *stream)
priv->result = NULL;
if (g_cancellable_set_error_if_cancelled (priv->cancellable, &error) ||
- set_error_if_http_failed (priv->msg, &error)) {
- g_simple_async_result_set_from_error (result, error);
- g_error_free (error);
- } else
+ set_error_if_http_failed (priv->msg, &error))
+ g_simple_async_result_take_error (result, error);
+ else
g_simple_async_result_set_op_res_gssize (result, priv->caller_nread);
priv->got_chunk_cb = NULL;
@@ -715,10 +707,8 @@ soup_http_input_stream_close_async (GInputStream *stream,
soup_http_input_stream_close_async);
success = soup_http_input_stream_close (stream, cancellable, &error);
g_simple_async_result_set_op_res_gboolean (result, success);
- if (error) {
- g_simple_async_result_set_from_error (result, error);
- g_error_free (error);
- }
+ if (error)
+ g_simple_async_result_take_error (result, error);
g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
diff --git a/libsoup/soup-request-file.c b/libsoup/soup-request-file.c
index 85b9bf6..e772653 100644
--- a/libsoup/soup-request-file.c
+++ b/libsoup/soup-request-file.c
@@ -171,12 +171,10 @@ soup_request_file_send_async_thread (GSimpleAsyncResult *res,
stream = soup_request_file_send (request, cancellable, &error);
- if (stream == NULL) {
- g_simple_async_result_set_from_error (res, error);
- g_error_free (error);
- } else {
+ if (stream == NULL)
+ g_simple_async_result_take_error (res, error);
+ else
g_simple_async_result_set_op_res_gpointer (res, stream, g_object_unref);
- }
}
static void
diff --git a/libsoup/soup-request-http.c b/libsoup/soup-request-http.c
index 5cf4658..668bb72 100644
--- a/libsoup/soup-request-http.c
+++ b/libsoup/soup-request-http.c
@@ -103,8 +103,7 @@ sent_async (GObject *source, GAsyncResult *result, gpointer user_data)
if (soup_http_input_stream_send_finish (httpstream, result, &error)) {
g_simple_async_result_set_op_res_gpointer (simple, httpstream, g_object_unref);
} else {
- g_simple_async_result_set_from_error (simple, error);
- g_error_free (error);
+ g_simple_async_result_take_error (simple, error);
g_object_unref (httpstream);
}
g_simple_async_result_complete (simple);
diff --git a/libsoup/soup-request.c b/libsoup/soup-request.c
index 98087ee..06fe7ff 100644
--- a/libsoup/soup-request.c
+++ b/libsoup/soup-request.c
@@ -149,7 +149,7 @@ soup_request_initable_init (GInitable *initable,
ok = SOUP_REQUEST_GET_CLASS (initable)->
check_uri (request, request->priv->uri, error);
- if (!ok && error) {
+ if (!ok && error && !*error) {
char *uri_string = soup_uri_to_string (request->priv->uri, FALSE);
g_set_error (error, SOUP_REQUESTER_ERROR, SOUP_REQUESTER_ERROR_BAD_URI,
_("Invalid '%s' URI: %s"),
@@ -352,7 +352,9 @@ soup_request_get_content_length (SoupRequest *request)
* soup_request_get_content_type:
* @request: a #SoupRequest
*
- * Gets the type of the data represented by @request.
+ * Gets the type of the data represented by @request. As in the
+ * HTTP Content-Type header, this may include parameters after
+ * the MIME type.
*
* Return value: the type of the data represented by @request,
* or %NULL if not known.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]