[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>
pull/598/head
Michael Brown 2012-08-17 18:00:40 +01:00
parent 1170a36e6b
commit 8f7cd88af5
1 changed files with 6 additions and 6 deletions

View File

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