I think my earlier email has the fix:

Hi, there,

I suspect there is a typo/bug here. Can someone confirm one way or another?

[hz...@dev066 hphp-external]$ svn diff
downloads/libevent-1.4.11-stable/http.c
Index: downloads/libevent-1.4.11-stable/http.c
===================================================================
--- downloads/libevent-1.4.11-stable/http.c     (revision 193628)
+++ downloads/libevent-1.4.11-stable/http.c     (working copy)
@@ -934,7 +934,7 @@
                return;
        } else if (n == 0) {
                /* Connection closed */
-               evhttp_connection_done(evcon);
+               evhttp_connection_reset(evcon);
                return;
        }

-Haiping




On 12/8/09 6:11 AM, "Kenneth Cox" <kens...@gmail.com> wrote:

> 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 (127.0.0.0/255.0.0.0)
>      filter: (ip) and ( port 18090 )
>      ####
>      T 127.0.0.1:50506 -> 127.0.0.1:18090 [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 127.0.0.1:18090 -> 127.0.0.1:50506 [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 127.0.0.1:18090 -> 127.0.0.1:50506 [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.
>      .
>      <HTML><HEAD>
>      <TITLE>400 Bad Request</TITLE>
>      </HEAD><BODY>
>      <H1>Method Not Implemented</H1>
>      Invalid method in request<P>
>      </BODY></HTML>
> 
> //---------------------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",
>               (long)EVBUFFER_LENGTH(req->output_buffer));
>      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");
>      req_set_clen(req);
>      evhttp_send_reply(req, HTTP_OK, "OK", NULL);
> }
> 
> int
> main(int argc, const char **argv)
> {
>      event_init();
>      struct evhttp *http_srv = evhttp_start(NULL, 18090);
>      evhttp_set_cb(http_srv, "/echo", echo_cb, NULL);
>      event_dispatch();
>      return 0;
> }
> 
> //--------------------------------------------
> _______________________________________________
> Libevent-users mailing list
> Libevent-users@monkey.org
> http://lists.monkey.org:8080/listinfo/libevent-users

_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://lists.monkey.org:8080/listinfo/libevent-users

Reply via email to