It's not an error if the socket was closed by the protocol
(Don't report a superfluous HTTP parser error).
@@ -554,7 +554,7 @@ static int http1_on_request(http1_parser_s *parser) {
if (p->request.method && !p->stop)
http_finish(&p->request);
h1_reset(p);
- return fio_is_closed(p->p.uuid);
+ return !p->close && fio_is_closed(p->p.uuid);
}
/** called when a response was received. */
static int http1_on_response(http1_parser_s *parser) {
@@ -563,7 +563,7 @@ static int http1_on_response(http1_parser_s *parser) {
if (p->request.status_str && !p->stop)
http_finish(&p->request);
h1_reset(p);
- return fio_is_closed(p->p.uuid);
+ return !p->close && fio_is_closed(p->p.uuid);
}
/** called when a request method is parsed. */
static int http1_on_method(http1_parser_s *parser, char *method,
@@ -666,8 +666,9 @@ static int http1_on_body_chunk(http1_parser_s *parser, char *data,
/** called when a protocol error occurred. */
static int http1_on_error(http1_parser_s *parser) {
- FIO_LOG_DEBUG("HTTP parser error at HTTP/1.1 buffer position %zu",
- parser->state.next - parser2http(parser)->buf);
+ FIO_LOG_DEBUG("HTTP parser error at HTTP/1.1 buffer position %zu/%zu",
+ parser->state.next - parser2http(parser)->buf,
+ parser2http(parser)->buf_len);
fio_close(parser2http(parser)->p.uuid);
return -1;
}
@@ -775,6 +776,7 @@ static void http1_on_data_first_time(intptr_t uuid, fio_protocol_s *protocol) {
/* ensure future reads skip this first time HTTP/2.0 test */
p->p.protocol.on_data = http1_on_data;
+ /* Test fot HTTP/2.0 pre-knowledge */
if (i >= 24 && !memcmp(p->buf, "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n", 24)) {
FIO_LOG_WARNING("client claimed unsupported HTTP/2 prior knowledge.");
fio_close(uuid);
