(self)
| 166 | return self.server._server_version |
| 167 | |
| 168 | def make_environ(self) -> WSGIEnvironment: |
| 169 | request_url = urlsplit(self.path) |
| 170 | url_scheme = "http" if self.server.ssl_context is None else "https" |
| 171 | |
| 172 | if not self.client_address: |
| 173 | self.client_address = ("<local>", 0) |
| 174 | elif isinstance(self.client_address, str): |
| 175 | self.client_address = (self.client_address, 0) |
| 176 | |
| 177 | # If there was no scheme but the path started with two slashes, |
| 178 | # the first segment may have been incorrectly parsed as the |
| 179 | # netloc, prepend it to the path again. |
| 180 | if not request_url.scheme and request_url.netloc: |
| 181 | path_info = f"/{request_url.netloc}{request_url.path}" |
| 182 | else: |
| 183 | path_info = request_url.path |
| 184 | |
| 185 | path_info = unquote(path_info) |
| 186 | |
| 187 | environ: WSGIEnvironment = { |
| 188 | "wsgi.version": (1, 0), |
| 189 | "wsgi.url_scheme": url_scheme, |
| 190 | "wsgi.input": self.rfile, |
| 191 | "wsgi.errors": sys.stderr, |
| 192 | "wsgi.multithread": self.server.multithread, |
| 193 | "wsgi.multiprocess": self.server.multiprocess, |
| 194 | "wsgi.run_once": False, |
| 195 | "werkzeug.socket": self.connection, |
| 196 | "SERVER_SOFTWARE": self.server_version, |
| 197 | "REQUEST_METHOD": self.command, |
| 198 | "SCRIPT_NAME": "", |
| 199 | "PATH_INFO": _wsgi_encoding_dance(path_info), |
| 200 | "QUERY_STRING": _wsgi_encoding_dance(request_url.query), |
| 201 | # Non-standard, added by mod_wsgi, uWSGI |
| 202 | "REQUEST_URI": _wsgi_encoding_dance(self.path), |
| 203 | # Non-standard, added by gunicorn |
| 204 | "RAW_URI": _wsgi_encoding_dance(self.path), |
| 205 | "REMOTE_ADDR": self.address_string(), |
| 206 | "REMOTE_PORT": self.port_integer(), |
| 207 | "SERVER_NAME": self.server.server_address[0], |
| 208 | "SERVER_PORT": str(self.server.server_address[1]), |
| 209 | "SERVER_PROTOCOL": self.request_version, |
| 210 | } |
| 211 | |
| 212 | for key, value in self.headers.items(): |
| 213 | if "_" in key: |
| 214 | continue |
| 215 | |
| 216 | key = key.upper().replace("-", "_") |
| 217 | value = value.replace("\r\n", "") |
| 218 | if key not in ("CONTENT_TYPE", "CONTENT_LENGTH"): |
| 219 | key = f"HTTP_{key}" |
| 220 | if key in environ: |
| 221 | value = f"{environ[key]},{value}" |
| 222 | environ[key] = value |
| 223 | |
| 224 | if "chunked" in parse_set_header(environ.get("HTTP_TRANSFER_ENCODING")): |
| 225 | environ["wsgi.input_terminated"] = True |
no test coverage detected