Fix for HTTP/1.0

master
Nicolas Favre-Felix 14 years ago
parent 9538f9f3f9
commit 4f563a0d8a

@ -37,13 +37,15 @@ curl -d "GET/hello" http://127.0.0.1:7379/
* Optional daemonize.
# Ideas, TODO...
* Fix crash on ACL rejection.
* Add better support for PUT, DELETE, HEAD, OPTIONS? How? For which commands?
* MULTI/EXEC/DISCARD/WATCH are disabled at the moment; find a way to use them.
* Support POST of raw Redis protocol data, and execute the whole thing. This could be useful for MULTI/EXEC transactions.
* Enrich config file:
* Provide timeout (maybe for some commands only?). What should the response be? 504 Gateway Timeout? 503 Service Unavailable?
* Multi-server support, using consistent hashing.
* SSL?
* Find a way to handle Redis disconnections properly for pub/sub clients. The current implementation leaves them hanging without any notification.
* Refactor client.c
* Add WebSocket support (with which protocol?).
* Send your ideas using the github tracker, on twitter [@yowgi](http://twitter.com/yowgi) or by mail to n.favrefelix@gmail.com.

@ -125,8 +125,12 @@ http_client_cleanup(struct http_client *c) {
void
http_client_free(struct http_client *c) {
printf("free\n");
event_del(&c->ev);
close(c->fd);
if(c->fd != -1) {
close(c->fd);
}
if(c->sub) {
/* clean up Redis connection */
@ -148,21 +152,19 @@ int
http_client_keep_alive(struct http_client *c) {
/* check disconnection */
int disconnect = 0;
int keep_alive = 0;
if(c->parser.http_major == 0) {
disconnect = 1; /* No version given. */
} else if(c->parser.http_major == 1 && c->parser.http_minor == 0) {
disconnect = 1; /* HTTP 1.0: disconnect by default */
if(c->parser.http_major == 1 && c->parser.http_minor == 1) {
keep_alive = 1; /* HTTP 1.1: keep-alive by default */
}
if(c->input_headers.connection.s) {
if(strncasecmp(c->input_headers.connection.s, "Keep-Alive", 10) == 0) {
disconnect = 0;
keep_alive = 1;
} else if(strncasecmp(c->input_headers.connection.s, "Close", 5) == 0) {
disconnect = 1;
keep_alive = 0;
}
}
return disconnect ? 0 : 1;
return keep_alive;
}
void
@ -409,10 +411,10 @@ http_send_reply(struct http_client *c, short code, const char *msg,
c->state = CLIENT_BROKEN;
} else {
if(c->sub) { /* don't free the client, but monitor fd. */
} else if(code == 200 && http_client_keep_alive(c)) { /* reset client */
http_client_reset(c);
} else {
} else if(code != 200 || !http_client_keep_alive(c)) { /* reset client */
c->state = CLIENT_BROKEN; /* error or HTTP < 1.1: close */
close(c->fd);
c->fd = -1;
}
}
http_client_serve(c);

Loading…
Cancel
Save