MCPcopy
hub / github.com/benoitc/gunicorn / test_parse_headers

Method test_parse_headers

tests/test_uwsgi.py:116–133  ·  view source on GitHub ↗

Test that HTTP_* vars become headers.

(self)

Source from the content-addressed store, hash-verified

114 assert req.body.read() == body
115
116 def test_parse_headers(self):
117 """Test that HTTP_* vars become headers."""
118 packet = make_uwsgi_packet({
119 'REQUEST_METHOD': 'GET',
120 'PATH_INFO': '/',
121 'HTTP_HOST': 'example.com',
122 'HTTP_USER_AGENT': 'TestClient/1.0',
123 'HTTP_ACCEPT': 'text/html',
124 })
125 unreader = IterUnreader([packet])
126 cfg = MockConfig()
127
128 req = UWSGIRequest(cfg, unreader, ('127.0.0.1', 12345))
129
130 headers_dict = dict(req.headers)
131 assert headers_dict['HOST'] == 'example.com'
132 assert headers_dict['USER-AGENT'] == 'TestClient/1.0'
133 assert headers_dict['ACCEPT'] == 'text/html'
134
135 def test_parse_content_type_header(self):
136 """Test that CONTENT_TYPE becomes a header."""

Callers

nothing calls this directly

Calls 4

IterUnreaderClass · 0.90
UWSGIRequestClass · 0.90
make_uwsgi_packetFunction · 0.85
MockConfigClass · 0.70

Tested by

no test coverage detected