mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
make it more compliant with the spec
This commit is contained in:
parent
50e8355c10
commit
2b556bb830
@ -12,6 +12,8 @@ class ParserError(Exception):
|
|||||||
|
|
||||||
class Parser(object):
|
class Parser(object):
|
||||||
|
|
||||||
|
_should_close = False
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.status = ""
|
self.status = ""
|
||||||
self.headers = []
|
self.headers = []
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
# This file is part of gunicorn released under the MIT license.
|
# This file is part of gunicorn released under the MIT license.
|
||||||
# See the NOTICE for more information.
|
# See the NOTICE for more information.
|
||||||
|
|
||||||
|
import ctypes
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -71,6 +72,29 @@ class Request(object):
|
|||||||
self.socket.send("100 Continue\n")
|
self.socket.send("100 Continue\n")
|
||||||
|
|
||||||
if not self.parser.content_len and not self.parser.is_chunked:
|
if not self.parser.content_len and not self.parser.is_chunked:
|
||||||
|
if self.parser.should_close:
|
||||||
|
# According to the RFC :
|
||||||
|
#
|
||||||
|
# The presence of a message-body in a request is signaled by
|
||||||
|
# the inclusion of a Content-Length or Transfer-Encoding header
|
||||||
|
# field in the request's message-headers. A message-body MUST
|
||||||
|
# NOT be included in a request if the specification of the
|
||||||
|
# request method (section 5.1.1) does not allow sending an
|
||||||
|
# entity-body in requests. A server SHOULD read and forward a
|
||||||
|
# message-body on any request; if the request method does not
|
||||||
|
# include defined semantics for an entity-body, then the
|
||||||
|
# message-body SHOULD be ignored when handling the request.
|
||||||
|
#
|
||||||
|
# So we try to read here the body and just skip it
|
||||||
|
|
||||||
|
l = sock.CHUNK_SIZE
|
||||||
|
while True:
|
||||||
|
b = ctypes.create_string_buffer(l)
|
||||||
|
try:
|
||||||
|
l = self.socket.recv_into(b, l)
|
||||||
|
except socket.error:
|
||||||
|
break
|
||||||
|
|
||||||
wsgi_input = StringIO.StringIO()
|
wsgi_input = StringIO.StringIO()
|
||||||
else:
|
else:
|
||||||
wsgi_input = TeeInput(self.socket, self.parser, buf[i:])
|
wsgi_input = TeeInput(self.socket, self.parser, buf[i:])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user