Awesome Open Source
Awesome Open Source

request_parser  Build Status

request_parser is an HTTP request parsing library in Python providing an easy API to access information in HTTP requests.

Getting Started


Requires six and future. These can be installed as below.

pip install six
pip install future


To use the library, git clone the repository and copy the library directory request_parser to a location that is present in PYTHONPATH or copy somewhere and add that location to PYTHONPATH.

Once the library is setup, it can be used as shown below.

from request_parser.http.request import HttpRequest
from io import BytesIO

def parse_request_example(request=None):
    if request is None:
    # create an iterable object out of request bytes
    request_stream = BytesIO(request)
    # create an HttpRequest object for the request
    http_request = HttpRequest(request_stream=request_stream)

    # parse request header
    # parse request body

    # do stuff with parsed information from the HttpRequest object
    print "This is a request to: "+http_request.get_host()

It is also possible to use the parse() method of HttpRequest object to parse the request header and the body in a single call.

Following picture shows how the infromation contained in an HttpRequest object looks like after successfully parsing a multipart/form-data request.

alt text

For more documentation, please see the wiki.


The master branch is compatible only with Python 2.7. The python3 branch works with Python 3.5 and above.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Http (5,591
Parser (4,917
Requests (1,963
Http Proxy (377
Http Requests (332
Related Projects