summaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
authorMichael Brown2016-05-25 16:27:50 +0200
committerMichael Brown2016-05-25 16:35:43 +0200
commitf42b2585fe81903488c3c1560089457e860241d4 (patch)
treeb1ff65372acbccd1be07c45ec8e13c850bc1b51b /src/net
parent[lotest] Add option to use broadcast packets for loopback testing (diff)
downloadipxe-f42b2585fe81903488c3c1560089457e860241d4.tar.gz
ipxe-f42b2585fe81903488c3c1560089457e860241d4.tar.xz
ipxe-f42b2585fe81903488c3c1560089457e860241d4.zip
[http] Ignore unrecognised "Connection" header tokens
Some HTTP/2 servers send the header "Connection: upgrade, close". This currently causes iPXE to fail due to the unrecognised "upgrade" token. Fix by ignoring any unrecognised tokens in the "Connection" header. Reported-by: Ján ONDREJ (SAL) <ondrejj@salstar.sk> Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net')
-rw-r--r--src/net/tcp/httpcore.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/net/tcp/httpcore.c b/src/net/tcp/httpcore.c
index d40633aa..57b89762 100644
--- a/src/net/tcp/httpcore.c
+++ b/src/net/tcp/httpcore.c
@@ -189,8 +189,8 @@ char * http_token ( char **line, char **value ) {
if ( value )
*value = NULL;
- /* Skip any initial whitespace */
- while ( isspace ( **line ) )
+ /* Skip any initial whitespace or commas */
+ while ( ( isspace ( **line ) ) || ( **line == ',' ) )
(*line)++;
/* Check for end of line and record token position */
@@ -201,8 +201,8 @@ char * http_token ( char **line, char **value ) {
/* Scan for end of token */
while ( ( c = **line ) ) {
- /* Terminate if we hit an unquoted whitespace */
- if ( isspace ( c ) && ! quote )
+ /* Terminate if we hit an unquoted whitespace or comma */
+ if ( ( isspace ( c ) || ( c == ',' ) ) && ! quote )
break;
/* Terminate if we hit a closing quote */
@@ -1315,19 +1315,17 @@ http_response_transfer_encoding __http_response_header = {
* @ret rc Return status code
*/
static int http_parse_connection ( struct http_transaction *http, char *line ) {
+ char *token;
/* Check for known connection intentions */
- if ( strcasecmp ( line, "keep-alive" ) == 0 ) {
- http->response.flags |= HTTP_RESPONSE_KEEPALIVE;
- return 0;
- }
- if ( strcasecmp ( line, "close" ) == 0 ) {
- http->response.flags &= ~HTTP_RESPONSE_KEEPALIVE;
- return 0;
+ while ( ( token = http_token ( &line, NULL ) ) ) {
+ if ( strcasecmp ( token, "keep-alive" ) == 0 )
+ http->response.flags |= HTTP_RESPONSE_KEEPALIVE;
+ if ( strcasecmp ( token, "close" ) == 0 )
+ http->response.flags &= ~HTTP_RESPONSE_KEEPALIVE;
}
- DBGC ( http, "HTTP %p unrecognised Connection \"%s\"\n", http, line );
- return -ENOTSUP_CONNECTION;
+ return 0;
}
/** HTTP "Connection" header */