SoupRequest*, SoupHTTPInputStream: misc cleanups
authorDan Winship <danw@gnome.org>
Sat, 22 Oct 2011 19:20:07 +0000 (15:20 -0400)
committerDan Winship <danw@gnome.org>
Sun, 23 Oct 2011 12:51:41 +0000 (08:51 -0400)
libsoup/soup-http-input-stream.c
libsoup/soup-request-file.c
libsoup/soup-request-http.c
libsoup/soup-request.c

index 7697c12..a4c8c2a 100644 (file)
@@ -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);
index 85b9bf6..e772653 100644 (file)
@@ -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
index 5cf4658..668bb72 100644 (file)
@@ -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);
index 98087ee..06fe7ff 100644 (file)
@@ -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.