Bläddra i källkod

[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 11 år sedan
förälder
incheckning
8f7cd88af5
1 ändrade filer med 6 tillägg och 6 borttagningar
  1. 6
    6
      src/net/tcp/httpcore.c

+ 6
- 6
src/net/tcp/httpcore.c Visa fil

@@ -260,8 +260,8 @@ static void http_done ( struct http_request *http ) {
260 260
 	 * force an error.
261 261
 	 */
262 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 265
 		http_close ( http, -ECONNRESET );
266 266
 		return;
267 267
 	}
@@ -362,8 +362,9 @@ static int http_rx_response ( struct http_request *http, char *response ) {
362 362
 		return -EINVAL_RESPONSE;
363 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 368
 	return 0;
368 369
 }
369 370
 
@@ -697,8 +698,7 @@ static int http_rx_header ( struct http_request *http, char *header ) {
697 698
 		}
698 699
 
699 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 702
 			DBGC ( http, "HTTP %p start of data\n", http );
703 703
 			http->rx_state = ( http->chunked ?
704 704
 					   HTTP_RX_CHUNK_LEN : HTTP_RX_DATA );

Laddar…
Avbryt
Spara