[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] Corrupted http request flags?
- To: Libevent MailingList <libevent-users@xxxxxxxx>
- Subject: [Libevent-users] Corrupted http request flags?
- From: Marco <marco.tijuana@xxxxxxxxx>
- Date: Tue, 27 Jul 2010 10:27:06 -0700
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Tue, 27 Jul 2010 13:27:12 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=X0T7fBjzRrKEPmfZcQaIskV6mdxX6tbTrQBiq19/pqI=; b=pZVqFFqSVO1MxTLvSIBfWPj3+ST9z2pEPFADoObSYz6ECoiwDxy9ULjCZZOd7SYDRE ryY+FsHLG2MgzAd/HckuSLHwAIcASQhbd1oB6a/I/yUYweBPXtn6sWU8TCXtT4VcX8/C u8FqP/J6usOOIuOI1zvg7k4RlDdY3Hk6caPBo=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=L1iUjVS0ZPPEmBuwD0ccAY8hmsdqX75XxqltjL2nr0HaUZ4bmFXoAVSoFysyGU1yCw Hy3bC+D4UlWcvHZmE+l98e07QzdhaZKssOYgQhlJvTJtOMdO9gNFkoM3uyFCLj4tdpBy LwVmCoZYfLaavG6P2eNbhaXp47rbtKtQwHEpw=
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
I'm trying to understand why a simple http server closes the connection after each answer, even if i set the keepalive header.I might have found a bug, but you guys should check..
On the client side, i generate simple requests as following:
r1 = evhttp_request_new(client_handle_response, NULL);
evhttp_add_header(r1->output_headers, "TestRequestType", "R1");
evhttp_add_header(r1->output_headers, "Connection", "keep-alive");
assert(!(r1->flags & EVHTTP_PROXY_REQUEST)) // <<< NOTICE THIS
evhttp_make_request(client_chan, r1, EVHTTP_REQ_GET, "foo");
On the server side, just to be sure, I re-add the keepalive
const char * request_id = evhttp_find_header(req->input_headers, "TestRequestType");
evhttp_add_header(req->output_headers, "TestRequestType", request_id);
evhttp_add_header(req->output_headers, "Connection", "keep-alive");
evhttp_send_reply(req, HTTP_OK, "OK!", req->output_buffer);
However the connection is always closed.
The internal is_keepalive function returns 1, however is_connection_close returns 1 too, and that's probably the problem.
From http.c, line 400
static int
evhttp_is_connection_close(int flags, struct evkeyvalq* headers)
{
if (flags & EVHTTP_PROXY_REQUEST) {
/* proxy connection */
const char *connection = evhttp_find_header(headers, "Proxy-Connection");
return (connection == NULL || strcasecmp(connection, "keep-alive") != 0);
} else {
const char *connection = evhttp_find_header(headers, "Connection");
return (connection != NULL && strcasecmp(connection, "close") == 0);
}
}
Running with GDB reveals that the FIRST case is executed, i.e. it enters the IF rather than the ELSE.
So somehow EVHTTP_PROXY_REQUEST is set in the request flags.
I'm (almost) sure the client is NOT setting this flag, as you can see from the assert() in the client code.
Is this my fault or is it a bug?
I'm using the latest stable from the website 1.4.14b-stable on MacOSX 10.6