]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[http] Fix HTTP SAN booting
authorMichael Brown <mcb30@ipxe.org>
Fri, 17 Aug 2012 17:00:40 +0000 (18:00 +0100)
committerMichael Brown <mcb30@ipxe.org>
Fri, 17 Aug 2012 17:00:40 +0000 (18:00 +0100)
Commit 501527d ("[http] Treat any unexpected connection close as an
error") introduced a regression causing HTTP SAN booting to fail.  At
the end of the response to the HEAD request, the call to http_done()
would erroneously believe that the server had disconnected in the
middle of the HTTP headers.

Fix by treating the header block from a HEAD request as a trailer
block.  This fixes the problem and also simplifies the logic in
http_rx_header().

Reported-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/tcp/httpcore.c

index 534e5a789d512c3a63f3f1f3625e95b65cac9ec2..7f178cc8145b82f6aa32ddf7ffecebfdaf5d3065 100644 (file)
@@ -260,8 +260,8 @@ static void http_done ( struct http_request *http ) {
         * force an error.
         */
        if ( ( http->rx_state < HTTP_RX_DATA ) || ( http->chunked != 0 ) ) {
-               DBGC ( http, "HTTP %p connection closed unexpectedly\n",
-                      http );
+               DBGC ( http, "HTTP %p connection closed unexpectedly in state "
+                      "%d\n", http, http->rx_state );
                http_close ( http, -ECONNRESET );
                return;
        }
@@ -362,8 +362,9 @@ static int http_rx_response ( struct http_request *http, char *response ) {
                return -EINVAL_RESPONSE;
        http->code = strtoul ( spc, NULL, 10 );
 
-       /* Move to received headers */
-       http->rx_state = HTTP_RX_HEADER;
+       /* Move to receive headers */
+       http->rx_state = ( ( http->flags & HTTP_HEAD_ONLY ) ?
+                          HTTP_RX_TRAILER : HTTP_RX_HEADER );
        return 0;
 }
 
@@ -697,8 +698,7 @@ static int http_rx_header ( struct http_request *http, char *header ) {
                }
 
                /* Move to next state */
-               if ( ( http->rx_state == HTTP_RX_HEADER ) &&
-                    ( ! ( http->flags & HTTP_HEAD_ONLY ) ) ) {
+               if ( http->rx_state == HTTP_RX_HEADER ) {
                        DBGC ( http, "HTTP %p start of data\n", http );
                        http->rx_state = ( http->chunked ?
                                           HTTP_RX_CHUNK_LEN : HTTP_RX_DATA );