Merge pull request #118 from boothj5/connection-close

Handle Connection:close header
master
Nicolas Favre-Felix 9 years ago
commit 45fd72b15b

@ -180,7 +180,9 @@ http_client_on_message_complete(struct http_parser *p) {
struct http_client *c = p->data;
/* keep-alive detection */
if(c->parser.http_major == 1 && c->parser.http_minor == 1) { /* 1.1 */
if (c->parser.flags & F_CONNECTION_CLOSE) {
c->keep_alive = 0;
} else if(c->parser.http_major == 1 && c->parser.http_minor == 1) { /* 1.1 */
c->keep_alive = 1;
}
c->http_version = c->parser.http_minor;

@ -288,16 +288,6 @@ enum header_states
};
enum flags
{ F_CHUNKED = 1 << 0
, F_CONNECTION_KEEP_ALIVE = 1 << 1
, F_CONNECTION_CLOSE = 1 << 2
, F_TRAILING = 1 << 3
, F_UPGRADE = 1 << 4
, F_SKIPBODY = 1 << 5
};
#define CR '\r'
#define LF '\n'
#define LOWER(c) (unsigned char)(c | 0x20)

@ -155,6 +155,16 @@ struct http_parser_settings {
};
enum flags
{ F_CHUNKED = 1 << 0
, F_CONNECTION_KEEP_ALIVE = 1 << 1
, F_CONNECTION_CLOSE = 1 << 2
, F_TRAILING = 1 << 3
, F_UPGRADE = 1 << 4
, F_SKIPBODY = 1 << 5
};
void http_parser_init(http_parser *parser, enum http_parser_type type);

@ -63,6 +63,8 @@ worker_can_read(int fd, short event, void *p) {
if(c->failed_alloc) {
slog(c->w->s, WEBDIS_DEBUG, "503", 3);
http_send_error(c, 503, "Service Unavailable");
} else if (c->parser.flags & F_CONNECTION_CLOSE) {
c->broken = 1;
} else if(c->is_websocket) {
/* we need to use the remaining (unparsed) data as the body. */
if(nparsed < ret) {

Loading…
Cancel
Save