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

Method connect

tests/conftest.py:136–158  ·  view source on GitHub ↗

Create a connection to the server, without sending a request. Useful if a test requires lower level methods to try something that ``HTTPClient.request`` will not do. If the server's scheme is HTTPS and the TLS ``context`` argument is not given, a default permissive c

(self, **kwargs: t.Any)

Source from the content-addressed store, hash-verified

134 self._log_write = None
135
136 def connect(self, **kwargs: t.Any) -> http.client.HTTPConnection:
137 """Create a connection to the server, without sending a request.
138 Useful if a test requires lower level methods to try something that
139 ``HTTPClient.request`` will not do.
140
141 If the server's scheme is HTTPS and the TLS ``context`` argument is not
142 given, a default permissive context is used.
143
144 :param kwargs: Arguments to :class:`http.client.HTTPConnection`.
145 """
146 if self.scheme == "https":
147 if "context" not in kwargs:
148 context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
149 context.check_hostname = False
150 context.verify_mode = ssl.CERT_NONE
151 kwargs["context"] = context
152
153 return http.client.HTTPSConnection(self.addr, **kwargs)
154
155 if self.scheme == "unix":
156 return UnixSocketHTTPConnection(self.addr, **kwargs)
157
158 return http.client.HTTPConnection(self.addr, **kwargs)
159
160 def request(self, url: str = "", **kwargs: t.Any) -> DataHTTPResponse:
161 """Open a connection and make a request to the server, returning the

Callers 7

requestMethod · 0.95
get_interface_ipFunction · 0.45
applicationMethod · 0.45
test_chunked_requestFunction · 0.45
connectMethod · 0.45

Calls 1

Tested by

no test coverage detected