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

Method _send_informational

gunicorn/asgi/protocol.py:1226–1252  ·  view source on GitHub ↗

Send an informational response (1xx) such as 103 Early Hints. Args: status: HTTP status code (100-199) headers: List of (name, value) header tuples request: The parsed request object Note: Informational responses are only sent for HTTP/1.1 or lat

(self, status, headers, request)

Source from the content-addressed store, hash-verified

1224 return scope
1225
1226 def _send_informational(self, status, headers, request):
1227 """Send an informational response (1xx) such as 103 Early Hints.
1228
1229 Args:
1230 status: HTTP status code (100-199)
1231 headers: List of (name, value) header tuples
1232 request: The parsed request object
1233
1234 Note: Informational responses are only sent for HTTP/1.1 or later.
1235 HTTP/1.0 clients do not support 1xx responses.
1236 """
1237 # Don't send informational responses to HTTP/1.0 clients
1238 if request.version < (1, 1):
1239 return
1240
1241 reason = self._get_reason_phrase(status)
1242 response = f"HTTP/{request.version[0]}.{request.version[1]} {status} {reason}\r\n"
1243
1244 for name, value in headers:
1245 if isinstance(name, bytes):
1246 name = name.decode("latin-1")
1247 if isinstance(value, bytes):
1248 value = value.decode("latin-1")
1249 response += f"{name}: {value}\r\n"
1250
1251 response += "\r\n"
1252 self._safe_write(response.encode("latin-1"))
1253
1254 def _send_response_start(self, status, headers, request):
1255 """Send HTTP response status and headers.

Calls 4

_get_reason_phraseMethod · 0.95
_safe_writeMethod · 0.95
decodeMethod · 0.80
encodeMethod · 0.80