[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] Broken HTTP 1.0 and 0.9 support
From: |
Christian Grothoff |
Subject: |
Re: [libmicrohttpd] Broken HTTP 1.0 and 0.9 support |
Date: |
Thu, 22 Apr 2010 20:58:41 +0200 |
User-agent: |
KMail/1.12.4 (Linux/2.6.31-14-generic; KDE/4.3.5; i686; ; ) |
Hi!
I'm not sure about both of these. My reading of the standard (and the
principle of being permissive in general) is that if we receive an HTTP
request with an "unknown" version number (i.e. 0.9 or 1.2) but we can process
it, we should. Moreover, if your server wants to do something else (say, not
return 200 OK), you can (since the version number is exposed to you via the
API).
Similarly, my reading of the standard is that if a client says "HTTP 1.0", it
is completely OK to respond "and this server supports HTTP 1.1" as long as no
1.1 features are used otherwise.
If you have any specific statements in say HTTP RFCs that contradict this,
I'll be happy to give your patch strong consideration, but at this point I am
not convinced that these changes would actually be an improvement.
Finally, I am not sure what exactly you're trying to do with the 0-byte
response that you create in your patch (close the connection?), but I'm not
sure it is the best (=simplest) way to do whatever you want to do.
My 2 cents
Christian
On Wednesday 21 April 2010 03:00:12 pm Geoffrey McRae wrote:
> Hi All,
>
> I am one of the developers for XBMC where we are using your wonderful
> library for our web interface. It has come to my attention however that
> support for HTTP/1.0 and 0.9 is broken/wrong.
>
> Currently 0.9 for requests it serves out an invalid " 200 OK" and the
> headers, which it should not.
>
> For 1.0 it returns HTTP/1.1 in the response, which again is incorrect
> since we made a 1.0 request.
>
> The following patch corrects both of these issues.
>
> Kind Regards
> Geoffrey McRae (gnif)
> http://www.xbmc.org/
>
> diff --git a/lib/libmicrohttpd/src/daemon/connection.c
> b/lib/libmicrohttpd/src/daemon/connection.c
> index ef47b1c..dc71be9 100644
> --- a/lib/libmicrohttpd/src/daemon/connection.c
> +++ b/lib/libmicrohttpd/src/daemon/connection.c
> @@ -577,13 +577,23 @@ build_header_response (struct MHD_Connection
> *connection)
> enum MHD_ValueKind kind;
> const char *reason_phrase;
>
> + if (strlen(connection->version) == 0)
> + {
> + data = MHD_pool_allocate (connection->pool, 0, MHD_YES);
> + connection->write_buffer = data;
> + connection->write_buffer_append_offset = 0;
> + connection->write_buffer_send_offset = 0;
> + connection->write_buffer_size = 0;
> + return MHD_YES;
> + }
> +
> if (connection->state == MHD_CONNECTION_FOOTERS_RECEIVED)
> {
> add_extra_headers (connection);
> reason_phrase = MHD_get_reason_phrase_for
> (connection->responseCode);
> SPRINTF (code,
> "%s %u %s\r\n",
> - MHD_HTTP_VERSION_1_1, connection->responseCode,
> reason_phrase);
> + connection->version, connection->responseCode,
> reason_phrase);
> off = strlen (code);
> /* estimate size */
> size = off + 2; /* extra \r\n at the end */
>