diff options
author | Dan Winship <danw@src.gnome.org> | 2003-08-20 17:49:59 +0000 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2003-08-20 17:49:59 +0000 |
commit | e52fd4b479405d355dde27348ae3343f5dfc33d9 (patch) | |
tree | c9a4d373fbe76af1fd8b80afecd6ddd502a9ea42 /libsoup/soup-headers.c | |
parent | 6d5196ec11a0e771000e325b34606e0d16057d78 (diff) | |
download | libsoup-e52fd4b479405d355dde27348ae3343f5dfc33d9.tar.gz |
Make this a GObject. (Note that since SoupMessage was not refcounted
* libsoup/soup-message.c: Make this a GObject. (Note that since
SoupMessage was not refcounted before, it's not really refcounted
now either. TBF)
(soup_message_free): Gone, replaced by g_object_unref
(soup_message_copy, soup_message_foreach_remove_header): Remove
these, since neither was currently functional.
(soup_message_is_keepalive): New utility function to look at
HTTP version and request/response headers to decide if a message
indicates the connection should be kept alive.
(soup_message_set_connection, soup_message_get_connection): New
(soup_message_get_socket): New
* libsoup/soup-server-message.c: Make this a subclass of
SoupMessage.
(soup_server_message_new): Now takes a SoupServer and SoupSocket
(soup_server_message_get_server): New
(soup_server_message_set_encoding,
soup_server_message_get_encoding): Get/set whether the message
should be sent with content-length or chunked encoding
(soup_server_message_is_started, soup_server_message_is_finished):
Private member accessors.
(soup_server_message_add_chunk): Renamed from add_data
(soup_server_message_get_chunk): Pops a chunk from the list.
(soup_server_message_get_source): Gone
* libsoup/soup-server.c: Update for SoupServerMessage changes.
(error_cb, write_done_cb): All the cleanup stuff that used to be
here happens automatically by unreffing the message now.
(get_response_header): Remove some erroneous leftover CGI stuff
(issue_bad_request): add "Connection: close" to the response.
(read_headers_cb): clean this up a bit. Reject HTTP/1.1 messages
with no Host header as per RFC 2616.
* libsoup/soup-connection.c (soup_connection_start_ssl): Gone
(soup_connection_set_in_use): Let the caller set the connection to
"not in use" even after the socket has been disconnected.
* libsoup/soup-context.c: Use soup_message_get_connection
* libsoup/soup-headers.c (soup_headers_parse_request): Remove the
check on request length, since it was rejecting
"GET / HTTP/1.0\r\n\r\n", which is a valid complete request.
* libsoup/soup-queue.c: Use soup_message_get_connection and
soup_message_get_socket.
(soup_queue_read_done_cb): Use soup_message_is_keepalive
(proxy_https_connect_cb): Use soup_socket_start_ssl rather than
soup_connection_start_ssl
* libsoup/soup-socket.c (finalize): disconnect the GIOChannel
handlers if the socket hasn't been disconnected yet.
* libsoup/soup-transfer.c (soup_reader_read_body_chunk,
reader_read): Fix these so that reader_read will exit properly if
the read is cancelled.
* tests/auth-test.c (main): s/soup_message_free/g_object_unref/
* tests/simple-httpd.c (server_callback): set the message to
content-length encoding.
* tests/simple-proxy.c (server_callback): Likewise
Diffstat (limited to 'libsoup/soup-headers.c')
-rw-r--r-- | libsoup/soup-headers.c | 60 |
1 files changed, 24 insertions, 36 deletions
diff --git a/libsoup/soup-headers.c b/libsoup/soup-headers.c index 6441c2c2..9cd38922 100644 --- a/libsoup/soup-headers.c +++ b/libsoup/soup-headers.c @@ -1,11 +1,8 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* - * soup-headers.c: Asyncronous Callback-based HTTP Request Queue. + * soup-headers.c: HTTP message header parsing * - * Authors: - * Alex Graveley (alex@ximian.com) - * - * Copyright (C) 2001-2002, Ximian, Inc. + * Copyright (C) 2001-2003, Ximian, Inc. */ #include <string.h> @@ -26,12 +23,12 @@ * val: "1234, 567" */ static gboolean -soup_headers_parse (gchar *str, - gint len, +soup_headers_parse (char *str, + int len, GHashTable *dest) { - gchar *key = NULL, *val = NULL, *end = NULL; - gint offset = 0, lws = 0; + char *key = NULL, *val = NULL, *end = NULL; + int offset = 0, lws = 0; key = strstr (str, "\r\n"); key += 2; @@ -81,7 +78,7 @@ soup_headers_parse (gchar *str, val = strchr (key, ':'); /* find start of val */ if (!val || val > strchr (key, '\r')) - goto THROW_MALFORMED_HEADER; + return FALSE; /* set end of key */ val [0] = '\0'; @@ -92,7 +89,7 @@ soup_headers_parse (gchar *str, /* find the end of the value */ end = strstr (val, "\r\n"); if (!end) - goto THROW_MALFORMED_HEADER; + return FALSE; exist_hdrs = g_hash_table_lookup (dest, key); exist_hdrs = g_slist_append (exist_hdrs, @@ -105,24 +102,21 @@ soup_headers_parse (gchar *str, } return TRUE; - - THROW_MALFORMED_HEADER: - return FALSE; } gboolean -soup_headers_parse_request (gchar *str, - gint len, +soup_headers_parse_request (char *str, + int len, GHashTable *dest, - gchar **req_method, - gchar **req_path, + char **req_method, + char **req_path, SoupHttpVersion *ver) { guint http_major, http_minor; - gchar method[16], path[1024]; + char method[16], path[1024]; - if (!str || !*str || len < sizeof ("GET / HTTP/0.0\r\n\r\n") - 1) - goto THROW_MALFORMED_HEADER; + if (!str || !*str) + return FALSE; if (sscanf (str, "%16s %1024s HTTP/%1u.%1u", @@ -130,10 +124,10 @@ soup_headers_parse_request (gchar *str, path, &http_major, &http_minor) < 4) - goto THROW_MALFORMED_HEADER; + return FALSE; if (!soup_headers_parse (str, len, dest)) - goto THROW_MALFORMED_HEADER; + return FALSE; *req_method = g_strdup (method); *req_path = g_strdup (path); @@ -146,16 +140,13 @@ soup_headers_parse_request (gchar *str, } return TRUE; - - THROW_MALFORMED_HEADER: - return FALSE; } gboolean soup_headers_parse_status_line (const char *status_line, SoupHttpVersion *ver, guint *status_code, - gchar **status_phrase) + char **status_phrase) { guint http_major, http_minor, code; guint phrase_start = 0; @@ -185,29 +176,26 @@ soup_headers_parse_status_line (const char *status_line, } gboolean -soup_headers_parse_response (gchar *str, - gint len, +soup_headers_parse_response (char *str, + int len, GHashTable *dest, SoupHttpVersion *ver, guint *status_code, - gchar **status_phrase) + char **status_phrase) { if (!str || !*str || len < sizeof ("HTTP/0.0 000 A\r\n\r\n")) - goto THROW_MALFORMED_HEADER; + return FALSE; if (!soup_headers_parse (str, len, dest)) - goto THROW_MALFORMED_HEADER; + return FALSE; if (!soup_headers_parse_status_line (str, ver, status_code, status_phrase)) - goto THROW_MALFORMED_HEADER; + return FALSE; return TRUE; - - THROW_MALFORMED_HEADER: - return FALSE; } |