Browse Source

[http] Fix HTTP SAN booting

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>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
8f7cd88af5
1 changed files with 6 additions and 6 deletions
  1. 6
    6
      src/net/tcp/httpcore.c

+ 6
- 6
src/net/tcp/httpcore.c View File

260
 	 * force an error.
260
 	 * force an error.
261
 	 */
261
 	 */
262
 	if ( ( http->rx_state < HTTP_RX_DATA ) || ( http->chunked != 0 ) ) {
262
 	if ( ( http->rx_state < HTTP_RX_DATA ) || ( http->chunked != 0 ) ) {
263
-		DBGC ( http, "HTTP %p connection closed unexpectedly\n",
264
-		       http );
263
+		DBGC ( http, "HTTP %p connection closed unexpectedly in state "
264
+		       "%d\n", http, http->rx_state );
265
 		http_close ( http, -ECONNRESET );
265
 		http_close ( http, -ECONNRESET );
266
 		return;
266
 		return;
267
 	}
267
 	}
362
 		return -EINVAL_RESPONSE;
362
 		return -EINVAL_RESPONSE;
363
 	http->code = strtoul ( spc, NULL, 10 );
363
 	http->code = strtoul ( spc, NULL, 10 );
364
 
364
 
365
-	/* Move to received headers */
366
-	http->rx_state = HTTP_RX_HEADER;
365
+	/* Move to receive headers */
366
+	http->rx_state = ( ( http->flags & HTTP_HEAD_ONLY ) ?
367
+			   HTTP_RX_TRAILER : HTTP_RX_HEADER );
367
 	return 0;
368
 	return 0;
368
 }
369
 }
369
 
370
 
697
 		}
698
 		}
698
 
699
 
699
 		/* Move to next state */
700
 		/* Move to next state */
700
-		if ( ( http->rx_state == HTTP_RX_HEADER ) &&
701
-		     ( ! ( http->flags & HTTP_HEAD_ONLY ) ) ) {
701
+		if ( http->rx_state == HTTP_RX_HEADER ) {
702
 			DBGC ( http, "HTTP %p start of data\n", http );
702
 			DBGC ( http, "HTTP %p start of data\n", http );
703
 			http->rx_state = ( http->chunked ?
703
 			http->rx_state = ( http->chunked ?
704
 					   HTTP_RX_CHUNK_LEN : HTTP_RX_DATA );
704
 					   HTTP_RX_CHUNK_LEN : HTTP_RX_DATA );

Loading…
Cancel
Save