Here are the examples of the python api pando.http.request.Request taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2 Examples
3
Example 1
def make_body(raw, headers=None, content_type=WWWFORM):
if not isinstance(raw, bytes):
raw = raw.encode('ascii')
if headers is None:
defaults = { FORMDATA: b"multipart/form-data; boundary=AaB03x",
WWWFORM: b"application/x-www-form-urlencoded" }
headers = {b"Content-Type": defaults.get(content_type, content_type)}
if not b'Content-Length' in headers:
headers[b'Content-Length'] = str(len(raw)).encode('ascii')
headers[b'Host'] = b'Blah'
website = Website()
request = Request(website, body=BytesIO(raw), headers=headers)
return request.body
0
Example 2
Project: pando.py Source File: test_request.py
def test_raw_is_raw():
request = Request(None)
expected = "GET / HTTP/1.1\r\nHost: localhost\r\n\r\n"
actual = str(request)
assert actual == expected