MCPcopy Index your code
hub / github.com/microsoft/playwright-python / HTTPSServer

Class HTTPSServer

tests/server.py:308–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306
307
308class HTTPSServer(Server):
309 protocol = "https"
310
311 def __init__(self) -> None:
312 self._listeners: list[Any] = []
313 super().__init__()
314
315 def listen(self, factory: http.HTTPFactory) -> None:
316 cert = ssl.PrivateCertificate.fromCertificateAndKeyPair(
317 ssl.Certificate.loadPEM(
318 (_dirname / "testserver" / "cert.pem").read_bytes()
319 ),
320 ssl.KeyPair.load(
321 (_dirname / "testserver" / "key.pem").read_bytes(), crypto.FILETYPE_PEM
322 ),
323 )
324 contextFactory = cert.options()
325 self._listeners.append(
326 reactor.listenSSL(self.PORT, factory, contextFactory, interface="127.0.0.1")
327 )
328 try:
329 self._listeners.append(
330 reactor.listenSSL(self.PORT, factory, contextFactory, interface="::1")
331 )
332 except Exception:
333 pass
334
335 def stop(self) -> None:
336 for listener in self._listeners:
337 listener.stopListening()
338 self._listeners.clear()
339
340
341class WebSocketProtocol(WebSocketServerProtocol):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected