HTTP layer improvements.

Add HTTP_REQUEST_NO_CONTENT_LENGTH which can be set by
a handler before calling http_response() to avoid Kore
from setting the content-length altogether.

If we are on a SPDY connection do not close the stream
if we do not pass data to http_response().
This commit is contained in:
Joris Vink 2015-05-15 19:12:18 +02:00
parent 0c4dbad2fb
commit cefeaf7992
2 changed files with 6 additions and 2 deletions

View File

@ -167,6 +167,7 @@ struct http_file {
#define HTTP_REQUEST_PGSQL_QUEUE 0x10
#define HTTP_REQUEST_EXPECT_BODY 0x20
#define HTTP_REQUEST_RETAIN_EXTRA 0x40
#define HTTP_REQUEST_NO_CONTENT_LENGTH 0x80
struct kore_task;

View File

@ -1209,7 +1209,9 @@ http_response_spdy(struct http_request *req, struct connection *c,
if (d != NULL)
net_send_queue(c, d, len, s, NETBUF_LAST_CHAIN);
} else {
}
if (req->method == HTTP_METHOD_HEAD) {
spdy_frame_send(c, SPDY_DATA_FRAME, FLAG_FIN, 0, s, 0);
spdy_stream_close(c, s, SPDY_KEEP_NETBUFS);
}
@ -1266,7 +1268,8 @@ http_response_normal(struct http_request *req, struct connection *c,
}
}
if (status != 204 && status >= 200)
if (status != 204 && status >= 200 &&
!(req->flags & HTTP_REQUEST_NO_CONTENT_LENGTH))
kore_buf_appendf(header_buf, "content-length: %d\r\n", len);
kore_buf_append(header_buf, "\r\n", 2);