We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
environ["SERVER_PORT"] can't be "None"
### Checklist

<!-- Please make sure you check all these items before submitting your bug report. -->

- [x] The bug is reproducible against the latest release and/or `master`.
- [x] There are no similar issues or pull requests to fix it yet.

### Describe the bug

https://github.com/abersheeran/a2wsgi/issues/8

```python
=================================== FAILURES ===================================
____________ test_convert_asgi_to_wsgi[app1-a2wsgi-ASGIMiddleware] _____________

app = <a2wsgi.asgi.ASGIMiddleware object at 0x7fced147eb80>
name = 'a2wsgi-ASGIMiddleware'

    @pytest.mark.parametrize(
        "app, name",
        [(wsgi_echo, "pure-WSGI"), (ASGIMiddleware(asgi_echo), "a2wsgi-ASGIMiddleware")],
    )
    def test_convert_asgi_to_wsgi(app, name):
        with httpx.Client(app=app, base_url="http://testserver") as client:
            start_time = time.time_ns()
            for _ in range(100):
>               client.post("/", data=b"hello world")

a2wsgi/benchmark.py:99:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/local/lib/python3.8/site-packages/httpx/_client.py:992: in post
    return self.request(
/usr/local/lib/python3.8/site-packages/httpx/_client.py:733: in request
    return self.send(
/usr/local/lib/python3.8/site-packages/httpx/_client.py:767: in send
    response = self._send_handling_auth(
/usr/local/lib/python3.8/site-packages/httpx/_client.py:805: in _send_handling_auth
    response = self._send_handling_redirects(
/usr/local/lib/python3.8/site-packages/httpx/_client.py:837: in _send_handling_redirects
    response = self._send_single_request(request, timeout)
/usr/local/lib/python3.8/site-packages/httpx/_client.py:861: in _send_single_request
    (status_code, headers, stream, ext) = transport.request(
/usr/local/lib/python3.8/site-packages/httpx/_transports/wsgi.py:113: in request
    result = _skip_leading_empty_chunks(result)
/usr/local/lib/python3.8/site-packages/httpx/_transports/wsgi.py:10: in _skip_leading_empty_chunks
    for chunk in body:
a2wsgi/a2wsgi/asgi.py:160: in __call__
    self.app(build_scope(environ), self.asgi_receive, self.asgi_send)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

environ = {'CONTENT_LENGTH': '11', 'HTTP_ACCEPT': '*/*', 'HTTP_ACCEPT_ENCODING': 'gzip, deflate', 'HTTP_CONNECTION': 'keep-alive', ...}

    def build_scope(environ: Environ) -> Scope:
        headers = [
            (
                each[5:].lower().replace("_", "-").encode("latin1"),
                environ[each].encode("latin1"),
            )
            for each in environ.keys()
            if each.startswith("HTTP_")
        ]
        if environ.get("CONTENT_TYPE"):
            headers.append((b"content-type", environ["CONTENT_TYPE"].encode("latin1")))
        if environ.get("CONTENT_LENGTH"):
            headers.append((b"content-length", environ["CONTENT_LENGTH"].encode("latin1")))

        if environ.get("REMOTE_ADDR") and environ.get("REMOTE_PORT"):
            client = (environ.get("REMOTE_ADDR"), int(environ.get("REMOTE_PORT")))
        else:
            client = None

        return {
            "type": "http",
            "asgi": {"version": "3.0", "spec_version": "3.0"},
            "http_version": environ.get("SERVER_PROTOCOL", "http/1.0").split("/")[1],
            "method": environ["REQUEST_METHOD"],
            "scheme": environ.get("wsgi.url_scheme", "http"),
            "path": environ["PATH_INFO"].encode("latin1").decode("utf8"),
            "query_string": environ["QUERY_STRING"].encode("ascii"),
            "root_path": environ.get("SCRIPT_NAME", "").encode("latin1").decode("utf8"),
            "client": client,
>           "server": (environ["SERVER_NAME"], int(environ["SERVER_PORT"])),
            "headers": headers,
        }
E       ValueError: invalid literal for int() with base 10: 'None'

a2wsgi/a2wsgi/asgi.py:94: ValueError
=========================== short test summary info ============================
FAILED a2wsgi/benchmark.py::test_convert_asgi_to_wsgi[app1-a2wsgi-ASGIMiddleware]
==================== 1 failed, 5 passed in 95.47s (0:01:35) ====================
```

### Expected behavior

https://www.python.org/dev/peps/pep-3333/#environ-variables

`SERVER_PORT` must be a valid integer value for URL splicing. In the WSGI application test, it may not have a real value, but we should give a default value, such as 80.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `httpx/_transports/wsgi.py`
Content:
```
1 import io
2 import itertools
3 import typing
4 from urllib.parse import unquote
5 
6 import httpcore
7 
8 
9 def _skip_leading_empty_chunks(body: typing.Iterable) -> typing.Iterable:
10     body = iter(body)
11     for chunk in body:
12         if chunk:
13             return itertools.chain([chunk], body)
14     return []
15 
16 
17 class WSGITransport(httpcore.SyncHTTPTransport):
18     """
19     A custom transport that handles sending requests directly to an WSGI app.
20     The simplest way to use this functionality is to use the `app` argument.
21 
22     ```
23     client = httpx.Client(app=app)
24     ```
25 
26     Alternatively, you can setup the transport instance explicitly.
27     This allows you to include any additional configuration arguments specific
28     to the WSGITransport class:
29 
30     ```
31     transport = httpx.WSGITransport(
32         app=app,
33         script_name="/submount",
34         remote_addr="1.2.3.4"
35     )
36     client = httpx.Client(transport=transport)
37     ```
38 
39     Arguments:
40 
41     * `app` - The ASGI application.
42     * `raise_app_exceptions` - Boolean indicating if exceptions in the application
43        should be raised. Default to `True`. Can be set to `False` for use cases
44        such as testing the content of a client 500 response.
45     * `script_name` - The root path on which the ASGI application should be mounted.
46     * `remote_addr` - A string indicating the client IP of incoming requests.
47     ```
48     """
49 
50     def __init__(
51         self,
52         app: typing.Callable,
53         raise_app_exceptions: bool = True,
54         script_name: str = "",
55         remote_addr: str = "127.0.0.1",
56     ) -> None:
57         self.app = app
58         self.raise_app_exceptions = raise_app_exceptions
59         self.script_name = script_name
60         self.remote_addr = remote_addr
61 
62     def request(
63         self,
64         method: bytes,
65         url: typing.Tuple[bytes, bytes, typing.Optional[int], bytes],
66         headers: typing.List[typing.Tuple[bytes, bytes]] = None,
67         stream: httpcore.SyncByteStream = None,
68         ext: dict = None,
69     ) -> typing.Tuple[
70         int, typing.List[typing.Tuple[bytes, bytes]], httpcore.SyncByteStream, dict
71     ]:
72         headers = [] if headers is None else headers
73         stream = httpcore.PlainByteStream(content=b"") if stream is None else stream
74 
75         scheme, host, port, full_path = url
76         path, _, query = full_path.partition(b"?")
77         environ = {
78             "wsgi.version": (1, 0),
79             "wsgi.url_scheme": scheme.decode("ascii"),
80             "wsgi.input": io.BytesIO(b"".join(stream)),
81             "wsgi.errors": io.BytesIO(),
82             "wsgi.multithread": True,
83             "wsgi.multiprocess": False,
84             "wsgi.run_once": False,
85             "REQUEST_METHOD": method.decode(),
86             "SCRIPT_NAME": self.script_name,
87             "PATH_INFO": unquote(path.decode("ascii")),
88             "QUERY_STRING": query.decode("ascii"),
89             "SERVER_NAME": host.decode("ascii"),
90             "SERVER_PORT": str(port),
91             "REMOTE_ADDR": self.remote_addr,
92         }
93         for header_key, header_value in headers:
94             key = header_key.decode("ascii").upper().replace("-", "_")
95             if key not in ("CONTENT_TYPE", "CONTENT_LENGTH"):
96                 key = "HTTP_" + key
97             environ[key] = header_value.decode("ascii")
98 
99         seen_status = None
100         seen_response_headers = None
101         seen_exc_info = None
102 
103         def start_response(
104             status: str, response_headers: list, exc_info: typing.Any = None
105         ) -> None:
106             nonlocal seen_status, seen_response_headers, seen_exc_info
107             seen_status = status
108             seen_response_headers = response_headers
109             seen_exc_info = exc_info
110 
111         result = self.app(environ, start_response)
112         # This is needed because the status returned by start_response
113         # shouldn't be used until the first non-empty chunk has been served.
114         result = _skip_leading_empty_chunks(result)
115 
116         assert seen_status is not None
117         assert seen_response_headers is not None
118         if seen_exc_info and self.raise_app_exceptions:
119             raise seen_exc_info[1]
120 
121         status_code = int(seen_status.split()[0])
122         headers = [
123             (key.encode("ascii"), value.encode("ascii"))
124             for key, value in seen_response_headers
125         ]
126         stream = httpcore.IteratorByteStream(iterator=result)
127         ext = {}
128 
129         return (status_code, headers, stream, ext)
130
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/httpx/_transports/wsgi.py b/httpx/_transports/wsgi.py
--- a/httpx/_transports/wsgi.py
+++ b/httpx/_transports/wsgi.py
@@ -74,6 +74,9 @@
 
         scheme, host, port, full_path = url
         path, _, query = full_path.partition(b"?")
+        if port is None:
+            port = {b"http": 80, b"https": 443}[scheme]
+
         environ = {
             "wsgi.version": (1, 0),
             "wsgi.url_scheme": scheme.decode("ascii"),

{"golden_diff": "diff --git a/httpx/_transports/wsgi.py b/httpx/_transports/wsgi.py\n--- a/httpx/_transports/wsgi.py\n+++ b/httpx/_transports/wsgi.py\n@@ -74,6 +74,9 @@\n \n         scheme, host, port, full_path = url\n         path, _, query = full_path.partition(b\"?\")\n+        if port is None:\n+            port = {b\"http\": 80, b\"https\": 443}[scheme]\n+\n         environ = {\n             \"wsgi.version\": (1, 0),\n             \"wsgi.url_scheme\": scheme.decode(\"ascii\"),\n", "issue": "environ[\"SERVER_PORT\"] can't be \"None\"\n### Checklist\r\n\r\n<!-- Please make sure you check all these items before submitting your bug report. -->\r\n\r\n- [x] The bug is reproducible against the latest release and/or `master`.\r\n- [x] There are no similar issues or pull requests to fix it yet.\r\n\r\n### Describe the bug\r\n\r\nhttps://github.com/abersheeran/a2wsgi/issues/8\r\n\r\n```python\r\n=================================== FAILURES ===================================\r\n____________ test_convert_asgi_to_wsgi[app1-a2wsgi-ASGIMiddleware] _____________\r\n\r\napp = <a2wsgi.asgi.ASGIMiddleware object at 0x7fced147eb80>\r\nname = 'a2wsgi-ASGIMiddleware'\r\n\r\n    @pytest.mark.parametrize(\r\n        \"app, name\",\r\n        [(wsgi_echo, \"pure-WSGI\"), (ASGIMiddleware(asgi_echo), \"a2wsgi-ASGIMiddleware\")],\r\n    )\r\n    def test_convert_asgi_to_wsgi(app, name):\r\n        with httpx.Client(app=app, base_url=\"http://testserver\") as client:\r\n            start_time = time.time_ns()\r\n            for _ in range(100):\r\n>               client.post(\"/\", data=b\"hello world\")\r\n\r\na2wsgi/benchmark.py:99:\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\n/usr/local/lib/python3.8/site-packages/httpx/_client.py:992: in post\r\n    return self.request(\r\n/usr/local/lib/python3.8/site-packages/httpx/_client.py:733: in request\r\n    return self.send(\r\n/usr/local/lib/python3.8/site-packages/httpx/_client.py:767: in send\r\n    response = self._send_handling_auth(\r\n/usr/local/lib/python3.8/site-packages/httpx/_client.py:805: in _send_handling_auth\r\n    response = self._send_handling_redirects(\r\n/usr/local/lib/python3.8/site-packages/httpx/_client.py:837: in _send_handling_redirects\r\n    response = self._send_single_request(request, timeout)\r\n/usr/local/lib/python3.8/site-packages/httpx/_client.py:861: in _send_single_request\r\n    (status_code, headers, stream, ext) = transport.request(\r\n/usr/local/lib/python3.8/site-packages/httpx/_transports/wsgi.py:113: in request\r\n    result = _skip_leading_empty_chunks(result)\r\n/usr/local/lib/python3.8/site-packages/httpx/_transports/wsgi.py:10: in _skip_leading_empty_chunks\r\n    for chunk in body:\r\na2wsgi/a2wsgi/asgi.py:160: in __call__\r\n    self.app(build_scope(environ), self.asgi_receive, self.asgi_send)\r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r\n\r\nenviron = {'CONTENT_LENGTH': '11', 'HTTP_ACCEPT': '*/*', 'HTTP_ACCEPT_ENCODING': 'gzip, deflate', 'HTTP_CONNECTION': 'keep-alive', ...}\r\n\r\n    def build_scope(environ: Environ) -> Scope:\r\n        headers = [\r\n            (\r\n                each[5:].lower().replace(\"_\", \"-\").encode(\"latin1\"),\r\n                environ[each].encode(\"latin1\"),\r\n            )\r\n            for each in environ.keys()\r\n            if each.startswith(\"HTTP_\")\r\n        ]\r\n        if environ.get(\"CONTENT_TYPE\"):\r\n            headers.append((b\"content-type\", environ[\"CONTENT_TYPE\"].encode(\"latin1\")))\r\n        if environ.get(\"CONTENT_LENGTH\"):\r\n            headers.append((b\"content-length\", environ[\"CONTENT_LENGTH\"].encode(\"latin1\")))\r\n\r\n        if environ.get(\"REMOTE_ADDR\") and environ.get(\"REMOTE_PORT\"):\r\n            client = (environ.get(\"REMOTE_ADDR\"), int(environ.get(\"REMOTE_PORT\")))\r\n        else:\r\n            client = None\r\n\r\n        return {\r\n            \"type\": \"http\",\r\n            \"asgi\": {\"version\": \"3.0\", \"spec_version\": \"3.0\"},\r\n            \"http_version\": environ.get(\"SERVER_PROTOCOL\", \"http/1.0\").split(\"/\")[1],\r\n            \"method\": environ[\"REQUEST_METHOD\"],\r\n            \"scheme\": environ.get(\"wsgi.url_scheme\", \"http\"),\r\n            \"path\": environ[\"PATH_INFO\"].encode(\"latin1\").decode(\"utf8\"),\r\n            \"query_string\": environ[\"QUERY_STRING\"].encode(\"ascii\"),\r\n            \"root_path\": environ.get(\"SCRIPT_NAME\", \"\").encode(\"latin1\").decode(\"utf8\"),\r\n            \"client\": client,\r\n>           \"server\": (environ[\"SERVER_NAME\"], int(environ[\"SERVER_PORT\"])),\r\n            \"headers\": headers,\r\n        }\r\nE       ValueError: invalid literal for int() with base 10: 'None'\r\n\r\na2wsgi/a2wsgi/asgi.py:94: ValueError\r\n=========================== short test summary info ============================\r\nFAILED a2wsgi/benchmark.py::test_convert_asgi_to_wsgi[app1-a2wsgi-ASGIMiddleware]\r\n==================== 1 failed, 5 passed in 95.47s (0:01:35) ====================\r\n```\r\n\r\n### Expected behavior\r\n\r\nhttps://www.python.org/dev/peps/pep-3333/#environ-variables\r\n\r\n`SERVER_PORT` must be a valid integer value for URL splicing. In the WSGI application test, it may not have a real value, but we should give a default value, such as 80.\r\n\n", "before_files": [{"content": "import io\nimport itertools\nimport typing\nfrom urllib.parse import unquote\n\nimport httpcore\n\n\ndef _skip_leading_empty_chunks(body: typing.Iterable) -> typing.Iterable:\n    body = iter(body)\n    for chunk in body:\n        if chunk:\n            return itertools.chain([chunk], body)\n    return []\n\n\nclass WSGITransport(httpcore.SyncHTTPTransport):\n    \"\"\"\n    A custom transport that handles sending requests directly to an WSGI app.\n    The simplest way to use this functionality is to use the `app` argument.\n\n    ```\n    client = httpx.Client(app=app)\n    ```\n\n    Alternatively, you can setup the transport instance explicitly.\n    This allows you to include any additional configuration arguments specific\n    to the WSGITransport class:\n\n    ```\n    transport = httpx.WSGITransport(\n        app=app,\n        script_name=\"/submount\",\n        remote_addr=\"1.2.3.4\"\n    )\n    client = httpx.Client(transport=transport)\n    ```\n\n    Arguments:\n\n    * `app` - The ASGI application.\n    * `raise_app_exceptions` - Boolean indicating if exceptions in the application\n       should be raised. Default to `True`. Can be set to `False` for use cases\n       such as testing the content of a client 500 response.\n    * `script_name` - The root path on which the ASGI application should be mounted.\n    * `remote_addr` - A string indicating the client IP of incoming requests.\n    ```\n    \"\"\"\n\n    def __init__(\n        self,\n        app: typing.Callable,\n        raise_app_exceptions: bool = True,\n        script_name: str = \"\",\n        remote_addr: str = \"127.0.0.1\",\n    ) -> None:\n        self.app = app\n        self.raise_app_exceptions = raise_app_exceptions\n        self.script_name = script_name\n        self.remote_addr = remote_addr\n\n    def request(\n        self,\n        method: bytes,\n        url: typing.Tuple[bytes, bytes, typing.Optional[int], bytes],\n        headers: typing.List[typing.Tuple[bytes, bytes]] = None,\n        stream: httpcore.SyncByteStream = None,\n        ext: dict = None,\n    ) -> typing.Tuple[\n        int, typing.List[typing.Tuple[bytes, bytes]], httpcore.SyncByteStream, dict\n    ]:\n        headers = [] if headers is None else headers\n        stream = httpcore.PlainByteStream(content=b\"\") if stream is None else stream\n\n        scheme, host, port, full_path = url\n        path, _, query = full_path.partition(b\"?\")\n        environ = {\n            \"wsgi.version\": (1, 0),\n            \"wsgi.url_scheme\": scheme.decode(\"ascii\"),\n            \"wsgi.input\": io.BytesIO(b\"\".join(stream)),\n            \"wsgi.errors\": io.BytesIO(),\n            \"wsgi.multithread\": True,\n            \"wsgi.multiprocess\": False,\n            \"wsgi.run_once\": False,\n            \"REQUEST_METHOD\": method.decode(),\n            \"SCRIPT_NAME\": self.script_name,\n            \"PATH_INFO\": unquote(path.decode(\"ascii\")),\n            \"QUERY_STRING\": query.decode(\"ascii\"),\n            \"SERVER_NAME\": host.decode(\"ascii\"),\n            \"SERVER_PORT\": str(port),\n            \"REMOTE_ADDR\": self.remote_addr,\n        }\n        for header_key, header_value in headers:\n            key = header_key.decode(\"ascii\").upper().replace(\"-\", \"_\")\n            if key not in (\"CONTENT_TYPE\", \"CONTENT_LENGTH\"):\n                key = \"HTTP_\" + key\n            environ[key] = header_value.decode(\"ascii\")\n\n        seen_status = None\n        seen_response_headers = None\n        seen_exc_info = None\n\n        def start_response(\n            status: str, response_headers: list, exc_info: typing.Any = None\n        ) -> None:\n            nonlocal seen_status, seen_response_headers, seen_exc_info\n            seen_status = status\n            seen_response_headers = response_headers\n            seen_exc_info = exc_info\n\n        result = self.app(environ, start_response)\n        # This is needed because the status returned by start_response\n        # shouldn't be used until the first non-empty chunk has been served.\n        result = _skip_leading_empty_chunks(result)\n\n        assert seen_status is not None\n        assert seen_response_headers is not None\n        if seen_exc_info and self.raise_app_exceptions:\n            raise seen_exc_info[1]\n\n        status_code = int(seen_status.split()[0])\n        headers = [\n            (key.encode(\"ascii\"), value.encode(\"ascii\"))\n            for key, value in seen_response_headers\n        ]\n        stream = httpcore.IteratorByteStream(iterator=result)\n        ext = {}\n\n        return (status_code, headers, stream, ext)\n", "path": "httpx/_transports/wsgi.py"}], "after_files": [{"content": "import io\nimport itertools\nimport typing\nfrom urllib.parse import unquote\n\nimport httpcore\n\n\ndef _skip_leading_empty_chunks(body: typing.Iterable) -> typing.Iterable:\n    body = iter(body)\n    for chunk in body:\n        if chunk:\n            return itertools.chain([chunk], body)\n    return []\n\n\nclass WSGITransport(httpcore.SyncHTTPTransport):\n    \"\"\"\n    A custom transport that handles sending requests directly to an WSGI app.\n    The simplest way to use this functionality is to use the `app` argument.\n\n    ```\n    client = httpx.Client(app=app)\n    ```\n\n    Alternatively, you can setup the transport instance explicitly.\n    This allows you to include any additional configuration arguments specific\n    to the WSGITransport class:\n\n    ```\n    transport = httpx.WSGITransport(\n        app=app,\n        script_name=\"/submount\",\n        remote_addr=\"1.2.3.4\"\n    )\n    client = httpx.Client(transport=transport)\n    ```\n\n    Arguments:\n\n    * `app` - The ASGI application.\n    * `raise_app_exceptions` - Boolean indicating if exceptions in the application\n       should be raised. Default to `True`. Can be set to `False` for use cases\n       such as testing the content of a client 500 response.\n    * `script_name` - The root path on which the ASGI application should be mounted.\n    * `remote_addr` - A string indicating the client IP of incoming requests.\n    ```\n    \"\"\"\n\n    def __init__(\n        self,\n        app: typing.Callable,\n        raise_app_exceptions: bool = True,\n        script_name: str = \"\",\n        remote_addr: str = \"127.0.0.1\",\n    ) -> None:\n        self.app = app\n        self.raise_app_exceptions = raise_app_exceptions\n        self.script_name = script_name\n        self.remote_addr = remote_addr\n\n    def request(\n        self,\n        method: bytes,\n        url: typing.Tuple[bytes, bytes, typing.Optional[int], bytes],\n        headers: typing.List[typing.Tuple[bytes, bytes]] = None,\n        stream: httpcore.SyncByteStream = None,\n        ext: dict = None,\n    ) -> typing.Tuple[\n        int, typing.List[typing.Tuple[bytes, bytes]], httpcore.SyncByteStream, dict\n    ]:\n        headers = [] if headers is None else headers\n        stream = httpcore.PlainByteStream(content=b\"\") if stream is None else stream\n\n        scheme, host, port, full_path = url\n        path, _, query = full_path.partition(b\"?\")\n        if port is None:\n            port = {b\"http\": 80, b\"https\": 443}[scheme]\n\n        environ = {\n            \"wsgi.version\": (1, 0),\n            \"wsgi.url_scheme\": scheme.decode(\"ascii\"),\n            \"wsgi.input\": io.BytesIO(b\"\".join(stream)),\n            \"wsgi.errors\": io.BytesIO(),\n            \"wsgi.multithread\": True,\n            \"wsgi.multiprocess\": False,\n            \"wsgi.run_once\": False,\n            \"REQUEST_METHOD\": method.decode(),\n            \"SCRIPT_NAME\": self.script_name,\n            \"PATH_INFO\": unquote(path.decode(\"ascii\")),\n            \"QUERY_STRING\": query.decode(\"ascii\"),\n            \"SERVER_NAME\": host.decode(\"ascii\"),\n            \"SERVER_PORT\": str(port),\n            \"REMOTE_ADDR\": self.remote_addr,\n        }\n        for header_key, header_value in headers:\n            key = header_key.decode(\"ascii\").upper().replace(\"-\", \"_\")\n            if key not in (\"CONTENT_TYPE\", \"CONTENT_LENGTH\"):\n                key = \"HTTP_\" + key\n            environ[key] = header_value.decode(\"ascii\")\n\n        seen_status = None\n        seen_response_headers = None\n        seen_exc_info = None\n\n        def start_response(\n            status: str, response_headers: list, exc_info: typing.Any = None\n        ) -> None:\n            nonlocal seen_status, seen_response_headers, seen_exc_info\n            seen_status = status\n            seen_response_headers = response_headers\n            seen_exc_info = exc_info\n\n        result = self.app(environ, start_response)\n        # This is needed because the status returned by start_response\n        # shouldn't be used until the first non-empty chunk has been served.\n        result = _skip_leading_empty_chunks(result)\n\n        assert seen_status is not None\n        assert seen_response_headers is not None\n        if seen_exc_info and self.raise_app_exceptions:\n            raise seen_exc_info[1]\n\n        status_code = int(seen_status.split()[0])\n        headers = [\n            (key.encode(\"ascii\"), value.encode(\"ascii\"))\n            for key, value in seen_response_headers\n        ]\n        stream = httpcore.IteratorByteStream(iterator=result)\n        ext = {}\n\n        return (status_code, headers, stream, ext)\n", "path": "httpx/_transports/wsgi.py"}]}