MCPcopy
hub / github.com/scrapy/scrapy / make_response

Method make_response

tests/test_http2_client_protocol.py:104–117  ·  view source on GitHub ↗
(request: TxRequest, extra_data: str)

Source from the content-addressed store, hash-verified

102class PostDataJsonMixin:
103 @staticmethod
104 def make_response(request: TxRequest, extra_data: str) -> bytes:
105 assert request.content is not None
106 response = {
107 "request-headers": {},
108 "request-body": json.loads(request.content.read()),
109 "extra-data": extra_data,
110 }
111 for k, v in request.requestHeaders.getAllRawHeaders():
112 response["request-headers"][str(k, "utf-8")] = str(v[0], "utf-8")
113
114 response_bytes = bytes(json.dumps(response), "utf-8")
115 request.setHeader("Content-Type", "application/json; charset=UTF-8")
116 request.setHeader("Content-Encoding", "UTF-8")
117 return response_bytes
118
119
120class PostDataJsonSmall(LeafResource, PostDataJsonMixin):

Callers 2

render_POSTMethod · 0.80
render_POSTMethod · 0.80

Calls 1

readMethod · 0.80

Tested by

no test coverage detected