MCPcopy
hub / github.com/pallets/werkzeug / Response

Class Response

src/werkzeug/sansio/response.py:64–763  ·  view source on GitHub ↗

Represents the non-IO parts of an HTTP response, specifically the status and headers but not the body. This class is not meant for general use. It should only be used when implementing WSGI, ASGI, or another HTTP application spec. Werkzeug provides a WSGI implementation at :cls:`wer

Source from the content-addressed store, hash-verified

62
63
64class Response:
65 """Represents the non-IO parts of an HTTP response, specifically the
66 status and headers but not the body.
67
68 This class is not meant for general use. It should only be used when
69 implementing WSGI, ASGI, or another HTTP application spec. Werkzeug
70 provides a WSGI implementation at :cls:`werkzeug.wrappers.Response`.
71
72 :param status: The status code for the response. Either an int, in
73 which case the default status message is added, or a string in
74 the form ``{code} {message}``, like ``404 Not Found``. Defaults
75 to 200.
76 :param headers: A :class:`~werkzeug.datastructures.Headers` object,
77 or a list of ``(key, value)`` tuples that will be converted to a
78 ``Headers`` object.
79 :param mimetype: The mime type (content type without charset or
80 other parameters) of the response. If the value starts with
81 ``text/`` (or matches some other special cases), the charset
82 will be added to create the ``content_type``.
83 :param content_type: The full content type of the response.
84 Overrides building the value from ``mimetype``.
85
86 .. versionchanged:: 3.0
87 The ``charset`` attribute was removed.
88
89 .. versionadded:: 2.0
90 """
91
92 #: the default status if none is provided.
93 default_status = 200
94
95 #: the default mimetype if none is provided.
96 default_mimetype: str | None = "text/plain"
97
98 #: Warn if a cookie header exceeds this size. The default, 4093, should be
99 #: safely `supported by most browsers <cookie_>`_. A cookie larger than
100 #: this size will still be sent, but it may be ignored or handled
101 #: incorrectly by some browsers. Set to 0 to disable this check.
102 #:
103 #: .. versionadded:: 0.13
104 #:
105 #: .. _`cookie`: http://browsercookielimits.squawky.net/
106 max_cookie_size = 4093
107
108 # A :class:`Headers` object representing the response headers.
109 headers: Headers
110
111 def __init__(
112 self,
113 status: int | str | HTTPStatus | None = None,
114 headers: t.Mapping[str, str | t.Iterable[str]]
115 | t.Iterable[tuple[str, str]]
116 | None = None,
117 mimetype: str | None = None,
118 content_type: str | None = None,
119 ) -> None:
120 if isinstance(headers, Headers):
121 self.headers = headers

Callers 10

request_demo_appFunction · 0.90
test_appFunction · 0.50
redirectFunction · 0.50
get_responseMethod · 0.50
debug_applicationMethod · 0.50
execute_commandMethod · 0.50
display_consoleMethod · 0.50
pin_authMethod · 0.50
log_pin_requestMethod · 0.50

Calls 4

header_propertyClass · 0.85
_set_propertyFunction · 0.85
COOPClass · 0.85
COEPClass · 0.85

Tested by 3

request_demo_appFunction · 0.72
test_appFunction · 0.40