#include <string.h>
+#include <glib/gi18n-lib.h>
+
#include "soup.h"
#include "soup-connection.h"
#include "soup-message-private.h"
parse_response_headers (SoupMessage *req,
char *headers, guint headers_len,
SoupEncoding *encoding,
- gpointer user_data)
+ gpointer user_data,
+ GError **error)
{
SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (req);
SoupHTTPVersion version;
req->response_headers,
&version,
&req->status_code,
- &req->reason_phrase))
+ &req->reason_phrase)) {
+ g_set_error_literal (error, SOUP_REQUEST_ERROR,
+ SOUP_REQUEST_ERROR_PARSING,
+ _("Could not parse HTTP response"));
return SOUP_STATUS_MALFORMED;
+ }
g_object_notify (G_OBJECT (req), SOUP_MESSAGE_STATUS_CODE);
g_object_notify (G_OBJECT (req), SOUP_MESSAGE_REASON_PHRASE);
else
*encoding = soup_message_headers_get_encoding (req->response_headers);
- if (*encoding == SOUP_ENCODING_UNRECOGNIZED)
+ if (*encoding == SOUP_ENCODING_UNRECOGNIZED) {
+ g_set_error_literal (error, SOUP_REQUEST_ERROR,
+ SOUP_REQUEST_ERROR_ENCODING,
+ _("Unrecognized HTTP response encoding"));
return SOUP_STATUS_MALFORMED;
+ }
return SOUP_STATUS_OK;
}
status = io->parse_headers_cb (msg, (char *)io->read_header_buf->data,
io->read_header_buf->len,
&io->read_encoding,
- io->header_data);
+ io->header_data, error);
g_byte_array_set_size (io->read_header_buf, 0);
if (status != SOUP_STATUS_OK) {
char *headers,
guint header_len,
SoupEncoding *encoding,
- gpointer user_data);
+ gpointer user_data,
+ GError **error);
typedef void (*SoupMessageCompletionFn) (SoupMessage *msg,
gpointer user_data);
#include <string.h>
+#include <glib/gi18n-lib.h>
+
#include "soup.h"
#include "soup-message-private.h"
#include "soup-misc-private.h"
static guint
parse_request_headers (SoupMessage *msg, char *headers, guint headers_len,
- SoupEncoding *encoding, gpointer sock)
+ SoupEncoding *encoding, gpointer sock, GError **error)
{
SoupMessagePrivate *priv = SOUP_MESSAGE_GET_PRIVATE (msg);
char *req_method, *req_path, *url;
&req_method,
&req_path,
&version);
- if (!SOUP_STATUS_IS_SUCCESSFUL (status))
+ if (!SOUP_STATUS_IS_SUCCESSFUL (status)) {
+ if (status == SOUP_STATUS_MALFORMED) {
+ g_set_error_literal (error, SOUP_REQUEST_ERROR,
+ SOUP_REQUEST_ERROR_PARSING,
+ _("Could not parse HTTP request"));
+ }
return status;
+ }
g_object_set (G_OBJECT (msg),
SOUP_MESSAGE_METHOD, req_method,
* @SOUP_REQUEST_ERROR_BAD_URI: the URI could not be parsed
* @SOUP_REQUEST_ERROR_UNSUPPORTED_URI_SCHEME: the URI scheme is not
* supported by this #SoupSession
+ * @SOUP_REQUEST_ERROR_PARSING: the server's response could not
+ * be parsed
+ * @SOUP_REQUEST_ERROR_ENCODING: the server's response was in an
+ * unsupported format
*
* A #SoupRequest error.
*
typedef enum {
SOUP_REQUEST_ERROR_BAD_URI,
- SOUP_REQUEST_ERROR_UNSUPPORTED_URI_SCHEME
+ SOUP_REQUEST_ERROR_UNSUPPORTED_URI_SCHEME,
+ SOUP_REQUEST_ERROR_PARSING,
+ SOUP_REQUEST_ERROR_ENCODING
} SoupRequestError;
G_END_DECLS
libsoup/soup-body-input-stream.c
libsoup/soup-converter-wrapper.c
+libsoup/soup-message-client-io.c
libsoup/soup-message-io.c
+libsoup/soup-message-server-io.c
libsoup/soup-request.c
libsoup/soup-session.c
libsoup/soup-tld.c