Hi all, I have an http server using libevent-1.4.13-stable, running on
Linux (Fedora 11).  When I use curl to send a one-shot http request, my
server sends two responses on the wire!  This does not cause any errors in
the client, but it concerns me that the state handling in the http server
is not right and distracts me every time I wireshark.

Has anyone else noticed this problem?  Am I doing something wrong?

I am debugging, but haven't gotten far yet.  I do know this problem did
not happen with an ancient version of libevent I have stashed (svn trunk
r309).  Any assistance would be much appreciated.

My test is:

     $ curl -i localhost:18090/echo

and what I see on the wire is the expected response plus one more:

     # ngrep -d lo -W byline port 18090
     interface: lo (
     filter: (ip) and ( port 18090 )
     T -> [AP]
     GET /echo HTTP/1.1.
     User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5  
OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5.
     Host: localhost:18090.
     Accept: */*.

     T -> [AP]
     HTTP/1.1 200 OK.
     content-length: 13.
     Date: Tue, 08 Dec 2009 14:08:23 GMT.
     Content-Type: text/html; charset=ISO-8859-1.
     we are here!

     T -> [AP]
     HTTP/1.1 400 Bad Request.
     Content-Type: text/html.
     Connection: close.
     Date: Tue, 08 Dec 2009 14:08:23 GMT.
     Content-Length: 134.
     <TITLE>400 Bad Request</TITLE>
     <H1>Method Not Implemented</H1>
     Invalid method in request<P>

//---------------------program below-----------------------

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include "evhttp.h"

static void
req_set_clen(struct evhttp_request *req)
     char buf[11];
     snprintf(buf, sizeof(buf), "%ld",
     evhttp_add_header(req->output_headers, "content-length", buf);

static void
echo_cb(struct evhttp_request *req, void *arg)
     evbuffer_add_printf(req->output_buffer, "we are here!\n");
     evhttp_send_reply(req, HTTP_OK, "OK", NULL);

main(int argc, const char **argv)
     struct evhttp *http_srv = evhttp_start(NULL, 18090);
     evhttp_set_cb(http_srv, "/echo", echo_cb, NULL);
     return 0;

Libevent-users mailing list

Reply via email to