I'm starting a new project using the HTTP bits of libevent, and so far
it's going well. The HTTP stuff seems to have been designed in a way
that makes it simple to use, which I appreciate.

However, I ran into a problem where I wasn't getting gzipped data back
from an HTTP request even when I had set the "Accept-Encoding: gzip"
header. Using curl I would get gzipped data as expected.

Digging into the source code of http.c I discovered the reason. My jaw
is still hanging slackly.

Here's the relevant segment of code:
------------------
/*
* Create the headers need for an HTTP request
*/
static void
evhttp_make_header_request(struct evhttp_connection *evcon,
   struct evhttp_request *req)
{
char line[1024];
const char *method;

evhttp_remove_header(req->output_headers, "Accept-Encoding");
evhttp_remove_header(req->output_headers, "Proxy-Connection");
-------------

Note the line: evhttp_remove_header(req->output_headers, "Accept-Encoding");

That line automatically strips out the Accept-Encoding header that I
am adding to my requests, hence the non-gzip-encoded responses I was
getting.

Why, in the name of all that is holy and just, does that line exist in
the source code?

Is there a good reason why it has been pre-ordained that users of
libevent must not be allowed to traffic in gzip-encoded data?

I commented the line out and recompiled and everything (apparently)
works fine, i.e., I can now request and receive gzipped data. But now
I have my own private patched version of libevent, which is not
something I want.

Why is that line there? (And I suppose I could ask the same about the
line that removes Proxy-Connection.)

Curiously yours,
Jon
_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users

Reply via email to