mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Fix a bug where headers arriving in multiple packets were not parsed; fix from Jiang Hong; test by me.
svn:r928
This commit is contained in:
parent
b89a3de044
commit
c968eb3e01
@ -121,6 +121,7 @@ Changes in current version:
|
|||||||
o Fix a problem with epoll() and reinit; problem report by Alexander Drozdov.
|
o Fix a problem with epoll() and reinit; problem report by Alexander Drozdov.
|
||||||
o Fix off-by-one errors in devpoll; from Ian Bell
|
o Fix off-by-one errors in devpoll; from Ian Bell
|
||||||
o Make event_add not change any state if it fails; reported by Ian Bell.
|
o Make event_add not change any state if it fails; reported by Ian Bell.
|
||||||
|
o Fix a bug where headers arriving in multiple packets were not parsed; fix from Jiang Hong; test by me.
|
||||||
|
|
||||||
Changes in 1.4.0:
|
Changes in 1.4.0:
|
||||||
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.
|
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.
|
||||||
|
1
http.c
1
http.c
@ -1584,6 +1584,7 @@ evhttp_read_firstline(struct evhttp_connection *evcon,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
evcon->state = EVCON_READING_HEADERS;
|
||||||
evhttp_read_header(evcon, req);
|
evhttp_read_header(evcon, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,9 +312,20 @@ http_chunked_cb(struct evhttp_request *req, void *arg)
|
|||||||
event_once(-1, EV_TIMEOUT, http_chunked_trickle_cb, state, &when);
|
event_once(-1, EV_TIMEOUT, http_chunked_trickle_cb, state, &when);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
http_complete_write(int fd, short what, void *arg)
|
||||||
|
{
|
||||||
|
struct bufferevent *bev = arg;
|
||||||
|
const char *http_request = "host\r\n"
|
||||||
|
"Connection: close\r\n"
|
||||||
|
"\r\n";
|
||||||
|
bufferevent_write(bev, http_request, strlen(http_request));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
http_basic_test(void)
|
http_basic_test(void)
|
||||||
{
|
{
|
||||||
|
struct timeval tv;
|
||||||
struct bufferevent *bev;
|
struct bufferevent *bev;
|
||||||
int fd;
|
int fd;
|
||||||
const char *http_request;
|
const char *http_request;
|
||||||
@ -337,17 +348,19 @@ http_basic_test(void)
|
|||||||
bev = bufferevent_new(fd, http_readcb, http_writecb,
|
bev = bufferevent_new(fd, http_readcb, http_writecb,
|
||||||
http_errorcb, NULL);
|
http_errorcb, NULL);
|
||||||
|
|
||||||
|
/* first half of the http request */
|
||||||
http_request =
|
http_request =
|
||||||
"GET /test HTTP/1.1\r\n"
|
"GET /test HTTP/1.1\r\n"
|
||||||
"Host: somehost\r\n"
|
"Host: some";
|
||||||
"Connection: close\r\n"
|
|
||||||
"\r\n";
|
|
||||||
|
|
||||||
bufferevent_write(bev, http_request, strlen(http_request));
|
bufferevent_write(bev, http_request, strlen(http_request));
|
||||||
|
timerclear(&tv);
|
||||||
|
tv.tv_usec = 10000;
|
||||||
|
event_once(-1, EV_TIMEOUT, http_complete_write, bev, &tv);
|
||||||
|
|
||||||
event_dispatch();
|
event_dispatch();
|
||||||
|
|
||||||
if (test_ok != 2) {
|
if (test_ok != 3) {
|
||||||
fprintf(stdout, "FAILED\n");
|
fprintf(stdout, "FAILED\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -377,7 +390,7 @@ http_basic_test(void)
|
|||||||
|
|
||||||
evhttp_free(http);
|
evhttp_free(http);
|
||||||
|
|
||||||
if (test_ok != 4) {
|
if (test_ok != 5) {
|
||||||
fprintf(stdout, "FAILED\n");
|
fprintf(stdout, "FAILED\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user