Support 'Proxy-Connection' header

See http://www.http-stats.com/Proxy-Connection
event_stream
Ryan Dahl 15 years ago
parent caef58793e
commit 9cbd66e49a

@ -97,6 +97,7 @@ static inline int message_complete_callback (http_parser *parser)
return parser->on_message_complete(parser);
}
#define PROXY_CONNECTION "proxy-connection"
#define CONNECTION "connection"
#define CONTENT_LENGTH "content-length"
#define TRANSFER_ENCODING "transfer-encoding"
@ -218,6 +219,7 @@ enum header_states
, h_CON
, h_matching_connection
, h_matching_proxy_connection
, h_matching_content_length
, h_matching_transfer_encoding
@ -953,6 +955,10 @@ size_t http_parser_execute (http_parser *parser,
header_state = h_C;
break;
case 'p':
header_state = h_matching_proxy_connection;
break;
case 't':
header_state = h_matching_transfer_encoding;
break;
@ -1010,6 +1016,18 @@ size_t http_parser_execute (http_parser *parser,
}
break;
/* proxy-connection */
case h_matching_proxy_connection:
index++;
if (index > sizeof(PROXY_CONNECTION)-1
|| c != PROXY_CONNECTION[index]) {
header_state = h_general;
} else if (index == sizeof(PROXY_CONNECTION)-2) {
header_state = h_connection;
}
break;
/* content-length */
case h_matching_content_length:

@ -597,6 +597,31 @@ const struct message responses[] =
,.body= "these headers are from http://news.ycombinator.com/"
}
#define PROXY_CONNECTION 6
, {.name="proxy connection"
,.type= HTTP_RESPONSE
,.raw= "HTTP/1.1 200 OK\r\n"
"Content-Type: text/html; charset=UTF-8\r\n"
"Content-Length: 11\r\n"
"Proxy-Connection: close\r\n"
"Date: Thu, 31 Dec 2009 20:55:48 +0000\r\n"
"\r\n"
"hello world"
,.should_keep_alive= FALSE
,.message_complete_on_eof= FALSE
,.http_major= 1
,.http_minor= 1
,.status_code= 200
,.num_headers= 4
,.headers=
{ {"Content-Type", "text/html; charset=UTF-8" }
, {"Content-Length", "11" }
, {"Proxy-Connection", "close" }
, {"Date", "Thu, 31 Dec 2009 20:55:48 +0000"}
}
,.body= "hello world"
}
, {.name= NULL } /* sentinel */
};

Loading…
Cancel
Save