Skip to content
Myr

Ensure all WSGITransport environs have a SERVER_PROTOCOL (#2708)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Peter Lazorchak · committed by GitHub · parent fcf1bc7 · Browse files · 2 files+18 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+18 added−0 removed

  • tests:+17 added−0 removed
  • other:+1 added−0 removed

2 files+18 added−0 removed

modified:httpx/_transports/wsgi.py+1 added
100 unmodified lines
101 "PATH_INFO": request.url.path,102 "QUERY_STRING": request.url.query.decode("ascii"),103 "SERVER_NAME": request.url.host,104 "SERVER_PORT": str(port),105 "SERVER_PROTOCOL": "HTTP/1.1",106 "REMOTE_ADDR": self.remote_addr,107 }108 for header_key, header_value in request.headers.raw:109 key = header_key.decode("ascii").upper().replace("-", "_")
35 unmodified lines
modified:tests/test_wsgi.py+17 added
171 unmodified lines
172 response = client.get(url)173 assert response.status_code == 200174 assert response.text == "Hello, World!"175 assert server_port == expected_server_port176177178def test_wsgi_server_protocol():179 server_protocol = None180181 def app(environ, start_response):182 nonlocal server_protocol183 server_protocol = environ["SERVER_PROTOCOL"]184 start_response("200 OK", [("Content-Type", "text/plain")])185 return [b"success"]186187 with httpx.Client(app=app, base_url="http://testserver") as client:188 response = client.get("/")189190 assert response.status_code == 200191 assert response.text == "success"192 assert server_protocol == "HTTP/1.1"