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

Method set_data

src/werkzeug/wrappers/response.py:289–300  ·  view source on GitHub ↗

Sets a new string as response. The value must be a string or bytes. If a string is set it's encoded to the charset of the response (utf-8 by default). .. versionadded:: 0.9

(self, value: bytes | str)

Source from the content-addressed store, hash-verified

287 return rv
288
289 def set_data(self, value: bytes | str) -> None:
290 """Sets a new string as response. The value must be a string or
291 bytes. If a string is set it's encoded to the charset of the
292 response (utf-8 by default).
293
294 .. versionadded:: 0.9
295 """
296 if isinstance(value, str):
297 value = value.encode()
298 self.response = [value]
299 if self.automatically_set_content_length:
300 self.headers["Content-Length"] = str(len(value))
301
302 data = property(
303 get_data,

Calls

no outgoing calls