> Hello.
>
> I'm trying to setup HTTP keepalive and, although my application appears to
> send all the right headers, the connection is always closed when the
> client issues requests with a body, like POSTs or PUTs. GETs keep the
> connection open.
I do not remember if there is a specific reason:
else if (!uwsgi_strncmp("CONTENT_LENGTH", 14, hh, keylen)) {
hr->content_length = uwsgi_str_num(val, vallen);
hr->session.can_keepalive = 0;
}
basically if there is a content_length the keepalive is disabled.
Content-Length: 0 should be ignored (as you expected), so:
else if (!uwsgi_strncmp("CONTENT_LENGTH", 14, hh, keylen)) {
hr->content_length = uwsgi_str_num(val, vallen);
if (hr->content_length > 0) {
hr->session.can_keepalive = 0;
}
}
would be a better pattern.
I need only to double check if there was some reason to brutally drop on
Content-Length or if it is a bug.
>
> Example (even with a content-length of 0 this breaks the connection):
>
> Connected to localhost.
> Escape character is '^]'.
> POST /XXX HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0
> OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:8000
> Accept: */*
> Content-Length: 0
> Expect: 100-continue
>
> HTTP/1.1 200 OK
> Date: Fri, 17 May 2013 15:52:23 GMT
> Vary: Accept-Language, Cookie
> Content-Length: 413
> Content-Type: application/json
> Content-Language: pt
> Connection: Keep-Alive
>
> {"bytes": 0, "thumb_exists": false, "rev":
> "c3dcd9eb-bf09-11e2-9267-406c8f001c8a", "modified": "Fri, 17 May 2013
> 15:52:23 +0000", "cursor":
> "action_upload,event_c3dc7f2e-bf09-11e2-95e7-406c8f001c8a,d1508fef-7bec-4641-a2ed-571abf52606b_c3dcfef3-bf09-11e2-8c83-406c8f001c8a",
> "path": "/11232", "is_dir": false, "icon": "page_white.gif", "root":
> "dropbox", "mime_type": "application/octet-stream", "size": "0
> bytes"}Connection closed by foreign host. <-----------
>
>
> I have added to my config:
>
> add-header: Connection: Keep-Alive
> http-keepalive: 1
> http-auto-chunked: 1
>
> On another note, I've noticed that by connecting to the http socket and
> sending just carriage returns, my WSGI application is invoked with invalid
> arguments. The connection is broken after the first corrupted request. In
> the case of Django, it blows up with:
>
> Traceback (most recent call last):
> File
> "/Users/andre/work/penv/discosite/lib/python2.7/site-packages/django/core/handlers/wsgi.py",
> line 245, in __call__
> request = self.request_class(environ)
> File
> "/Users/andre/work/penv/discosite/lib/python2.7/site-packages/django/core/handlers/wsgi.py",
> line 147, in __init__
> self.method = environ['REQUEST_METHOD'].upper()
> KeyError: u'REQUEST_METHOD'
>
>
> Is this permitted by the WSGI spec? If I send a GET first, and the
> connection is kept alive, I'm allowed to just keep sending carriage
> returns, generating errors, and the connection is not broken.
>
> Best regards,
> André
> _______________________________________________
> uWSGI mailing list
> [email protected]
> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
>
--
Roberto De Ioris
http://unbit.it
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi