Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
2  http_parser/__init__.py
@@ -3,5 +3,5 @@
# This file is part of http_parser released under the MIT license.
# See the NOTICE for more information.
-version_info = (0, 7, 4)
+version_info = (0, 7, 5)
__version__ = ".".join(map(str, version_info))
View
10 http_parser/parser.c
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.15.1 on Wed Jan 25 14:28:37 2012 */
+/* Generated by Cython 0.15.1 on Tue Feb 28 11:20:33 2012 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -673,7 +673,7 @@ int __pyx_module_is_main_http_parser__parser = 0;
static PyObject *__pyx_builtin_object;
static PyObject *__pyx_builtin_map;
static char __pyx_k_1[] = "";
-static char __pyx_k_2[] = "%s,%s";
+static char __pyx_k_2[] = "%s, %s";
static char __pyx_k_3[] = "HTTP_%s";
static char __pyx_k_4[] = "-";
static char __pyx_k_6[] = "content-encoding";
@@ -1109,7 +1109,7 @@ static int __pyx_f_11http_parser_6parser_on_header_value_cb(struct http_parser *
* header_value = bytes_to_str(PyBytes_FromStringAndSize(at, length))
*
* if res._last_field in res.headers: # <<<<<<<<<<<<<<
- * header_value = "%s,%s" % (res.headers[res._last_field],
+ * header_value = "%s, %s" % (res.headers[res._last_field],
* header_value)
*/
__pyx_t_2 = PyObject_GetAttr(__pyx_v_res, __pyx_n_s___last_field); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -1124,7 +1124,7 @@ static int __pyx_f_11http_parser_6parser_on_header_value_cb(struct http_parser *
/* "http_parser/parser.pyx":89
*
* if res._last_field in res.headers:
- * header_value = "%s,%s" % (res.headers[res._last_field], # <<<<<<<<<<<<<<
+ * header_value = "%s, %s" % (res.headers[res._last_field], # <<<<<<<<<<<<<<
* header_value)
*
*/
@@ -1139,7 +1139,7 @@ static int __pyx_f_11http_parser_6parser_on_header_value_cb(struct http_parser *
/* "http_parser/parser.pyx":90
* if res._last_field in res.headers:
- * header_value = "%s,%s" % (res.headers[res._last_field],
+ * header_value = "%s, %s" % (res.headers[res._last_field],
* header_value) # <<<<<<<<<<<<<<
*
* # update wsgi environ
View
2  http_parser/parser.pyx
@@ -86,7 +86,7 @@ cdef int on_header_value_cb(http_parser *parser, char *at,
header_value = bytes_to_str(PyBytes_FromStringAndSize(at, length))
if res._last_field in res.headers:
- header_value = "%s,%s" % (res.headers[res._last_field],
+ header_value = "%s, %s" % (res.headers[res._last_field],
header_value)
# update wsgi environ
View
48 http_parser/pyparser.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -
#
-# This file is part of http-parser released under the MIT license.
+# This file is part of http-parser released under the MIT license.
# See the NOTICE for more information.
import os
@@ -40,9 +40,9 @@ def __init__(self, kind=2, decompress=False):
# errors vars
self.errno = None
self.errstr = ""
-
+
# protected variables
- self._buf = []
+ self._buf = []
self._version = None
self._method = None
self._status_code = None
@@ -104,7 +104,7 @@ def get_environ(self):
if hkey in environ:
environ[key] = environ.pop(hkey)
- script_name = environ.get('HTTP_SCRIPT_NAME',
+ script_name = environ.get('HTTP_SCRIPT_NAME',
os.environ.get("SCRIPT_NAME", ""))
if script_name:
path_info = self._path.split(script_name, 1)[1]
@@ -120,7 +120,7 @@ def get_environ(self):
environ['wsgi.url_scheme'] = "https"
else:
environ['wsgi.url_scheme'] = "http"
-
+
return environ
def recv_body(self):
@@ -151,7 +151,7 @@ def is_upgrade(self):
return self._headers.get('connection', "") == "upgrade"
def is_headers_complete(self):
- """ return True if all headers have been parsed. """
+ """ return True if all headers have been parsed. """
return self.__on_headers_complete
def is_partial_body(self):
@@ -169,7 +169,7 @@ def is_message_complete(self):
def is_chunked(self):
""" return True if Transfer-Encoding header value is chunked"""
return self._chunked
-
+
def should_keep_alive(self):
""" return True if the connection should be kept alive
"""
@@ -179,7 +179,7 @@ def should_keep_alive(self):
elif hconn == "keep-alive":
return True
return self._version == (1, 1)
-
+
def execute(self, data, length):
# end of body can be passed manually by putting a length of 0
@@ -200,7 +200,7 @@ def execute(self, data, length):
self._buf.append(data[:idx])
first_line = bytes_to_str(b("").join(self._buf))
nb_parsed = nb_parsed + idx + 2
-
+
rest = data[idx+2:]
data = b("")
if self._parse_firstline(first_line):
@@ -219,7 +219,7 @@ def execute(self, data, length):
return length
nb_parsed = nb_parsed + (len(to_parse) - ret)
except InvalidHeader, e:
- self.errno = INVALID_HEADER
+ self.errno = INVALID_HEADER
self.errstr = str(e)
return nb_parsed
elif not self.__on_message_complete:
@@ -266,18 +266,18 @@ def _parse_response_line(self, line):
bits = line.split(None, 1)
if len(bits) != 2:
raise InvalidRequestLine(line)
-
- # version
+
+ # version
matchv = VERSION_RE.match(bits[0])
if matchv is None:
raise InvalidRequestLine("Invalid HTTP version: %s" % bits[0])
self._version = (int(matchv.group(1)), int(matchv.group(2)))
-
+
# status
matchs = STATUS_RE.match(bits[1])
if matchs is None:
raise InvalidRequestLine("Invalid status %" % bits[1])
-
+
self._status = bits[1]
self._status_code = int(matchs.group(1))
self._reason = matchs.group(2)
@@ -298,7 +298,7 @@ def _parse_request_line(self, line):
self._path = parts.path or ""
self._query_string = parts.query or ""
self._fragment = parts.fragment or ""
-
+
# Version
match = VERSION_RE.match(bits[2])
if match is None:
@@ -312,7 +312,7 @@ def _parse_request_line(self, line):
"RAW_URI": self._url,
"REQUEST_METHOD": self._method,
"SERVER_PROTOCOL": bits[2]})
-
+
def _parse_headers(self, data):
idx = data.find(b("\r\n\r\n"))
if idx < 0: # we don't have all headers
@@ -321,7 +321,7 @@ def _parse_headers(self, data):
# Split lines on \r\n keeping the \r\n on each line
lines = [bytes_to_str(line) + "\r\n" for line in
data[:idx].split(b("\r\n"))]
-
+
# Parse headers into key/value pairs paying attention
# to continuation lines.
while len(lines):
@@ -334,15 +334,15 @@ def _parse_headers(self, data):
if HEADER_RE.search(name):
raise InvalidHeader("invalid header name %s" % name)
name, value = name.strip(), [value.lstrip()]
-
+
# Consume value continuation lines
while len(lines) and lines[0].startswith((" ", "\t")):
value.append(lines.pop(0))
value = ''.join(value).rstrip()
-
+
# multiple headers
if name in self._headers:
- value = "%s,%s" % (self._headers[name], value)
+ value = "%s, %s" % (self._headers[name], value)
# store new header value
self._headers[name] = value
@@ -365,13 +365,13 @@ def _parse_headers(self, data):
if not self._chunked:
self._clen_rest = sys.maxint
- # detect encoding and set decompress object
+ # detect encoding and set decompress object
encoding = self._headers.get('content-encoding')
if encoding == "gzip":
self.__decompress_obj = zlib.decompressobj(16+zlib.MAX_WBITS)
elif encoding == "deflate":
self.__decompress_obj = zlib.decompressobj()
-
+
rest = data[idx+4:]
self._buf = [rest]
self.__on_headers_complete = True
@@ -392,7 +392,7 @@ def _parse_body(self):
if self._clen_rest <= 0:
self.__on_message_complete = True
- return
+ return
else:
data = b("").join(self._buf)
try:
@@ -408,7 +408,7 @@ def _parse_body(self):
if size is None or len(rest) < size:
return None
-
+
body_part, rest = rest[:size], rest[size:]
if len(rest) < 2:

No commit comments for this range

Something went wrong with that request. Please try again.