Don't put should_keep_alive messages in front of messages

event_stream
Ryan Dahl 15 years ago
parent 8f52d451a6
commit 5b37977e32

@ -1250,19 +1250,19 @@ size_t parse (http_parser *parser, const char *data, size_t len, int start_state
CALLBACK2(headers_complete); CALLBACK2(headers_complete);
if (parser->flags & F_CHUNKED) { if (parser->flags & F_CHUNKED) {
/* chunked encoding - ignore content-lenght header */ /* chunked encoding - ignore Content-Length header */
state = s_chunk_size_start; state = s_chunk_size_start;
} else { } else {
if (parser->content_length == 0) { if (parser->content_length == 0) {
/* content-length header given, but zero: Content-Length: 0\r\n */ /* Content-Length header given but zero: Content-Length: 0\r\n */
CALLBACK2(message_complete); CALLBACK2(message_complete);
state = start_state; state = start_state;
} else if (parser->content_length > 0) { } else if (parser->content_length > 0) {
/* content-length header given, and positive */ /* Content-Length header given and non-zero */
state = s_body_identity; state = s_body_identity;
} else { } else {
/* No content-length header, not chunked */ /* No Content-Length header, not chunked */
if (parser->http_major > 0) { if (parser->http_major > 0 && parser->http_minor > 0) {
/* HTTP/1.0 or HTTP/1.1 */ /* HTTP/1.0 or HTTP/1.1 */
if (parser->flags & F_CONNECTION_CLOSE) { if (parser->flags & F_CONNECTION_CLOSE) {
/* Read body until EOF */ /* Read body until EOF */
@ -1273,7 +1273,7 @@ size_t parse (http_parser *parser, const char *data, size_t len, int start_state
state = start_state; state = start_state;
} }
} else { } else {
/* HTTP/0.9 or earlier */ /* HTTP/1.0 or earlier */
if (parser->flags & F_CONNECTION_KEEP_ALIVE) { if (parser->flags & F_CONNECTION_KEEP_ALIVE) {
/* Message is done - read the next */ /* Message is done - read the next */
CALLBACK2(message_complete); CALLBACK2(message_complete);

@ -854,7 +854,11 @@ test_multiple3 (const struct message *r1, const struct message *r2, const struct
exit(1); exit(1);
} }
assert(num_messages == 3); if (3 != num_messages) {
fprintf(stderr, "\n\n*** Parser didn't see 3 messages only %d *** \n", num_messages);
exit(1);
}
if (!message_eq(0, r1)) exit(1); if (!message_eq(0, r1)) exit(1);
if (!message_eq(1, r2)) exit(1); if (!message_eq(1, r2)) exit(1);
if (!message_eq(2, r3)) exit(1); if (!message_eq(2, r3)) exit(1);
@ -980,6 +984,16 @@ main (void)
test_message(&responses[i]); test_message(&responses[i]);
} }
for (i = 0; i < response_count; i++) {
if (!responses[i].should_keep_alive) continue;
for (j = 0; j < response_count; j++) {
if (!responses[j].should_keep_alive) continue;
for (k = 0; k < response_count; k++) {
test_multiple3(&responses[i], &responses[j], &responses[k]);
}
}
}
printf("response scan 1/1 "); printf("response scan 1/1 ");
test_scan( &responses[TRAILING_SPACE_ON_CHUNKED_BODY] test_scan( &responses[TRAILING_SPACE_ON_CHUNKED_BODY]
, &responses[NO_HEADERS_NO_BODY_404] , &responses[NO_HEADERS_NO_BODY_404]
@ -1055,7 +1069,9 @@ main (void)
for (i = 0; i < request_count; i++) { for (i = 0; i < request_count; i++) {
if (!requests[i].should_keep_alive) continue;
for (j = 0; j < request_count; j++) { for (j = 0; j < request_count; j++) {
if (!requests[j].should_keep_alive) continue;
for (k = 0; k < request_count; k++) { for (k = 0; k < request_count; k++) {
test_multiple3(&requests[i], &requests[j], &requests[k]); test_multiple3(&requests[i], &requests[j], &requests[k]);
} }

Loading…
Cancel
Save