+
Skip to content

teh/python-http11

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is it

This is a hacky, unfinished python binding for mongrel2's ragel-powered parser. The parser is a "push" state machine instead of a "pull" parser. That means instead of blokcing on a read you can push bytes into the parser and it will return immediately. After pushing in bytes you can query the error and finished states and act accordingly.

Example

import http11

q = """\
GET /echo HTTP/1.1\r
User-Agent: curl/7.21.0\r
Host: www.local:7999\r
Accept: */*\r
\r
"""

parser = http11.HttpParser()
parser.execute(q, len(q))
print parser.is_finished(), parser.has_error()
print parser.headers
print parser.method, parser.path, parser.version

# 1 0
# {'host': 'www.local:7999', 'accept': '*/*', 'user-agent': 'curl/7.21.0'}
# GET /echo HTTP/1.1

Licence

This is mostly mongrel2 stuff, so those bits are BSD. Any additional code is BSD as well.

About

Python binding for mongrel2's http 1.1 parser

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载