Skip to content
Myr

Added text_response_server classmethod to TestServer and updated basic_response_server to use it

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Braulio Valdivielso Martínez · committed by Braulio Valdivielso Martínez · parent 5ecf789 · Browse files · 1 file+13 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+13 added−8 removed

  • other:+13 added−8 removed

1 file+13 added−8 removed

modified:testserver/server.py+13 added-8 removed
21 unmodified lines
22 self.ready_event = threading.Event()23 self.stop_event = threading.Event()2425 @classmethod26 def basic_response_server(cls, **kwargs):27 def basic_response_handler(sock):28 sock.send(29 b'HTTP/1.1 200 OK\r\n'30 b'Content-Length: 0\r\n'31 b'\r\n'32 )26 def text_response_server(cls, text, **kwargs):27 def text_response_handler(sock):28 sock.send(text.encode())2934 server = Server(basic_response_handler, **kwargs)30 server = Server(text_response_handler, **kwargs)3132 return server3334 @classmethod35 def basic_response_server(cls, **kwargs):36 server = cls.text_response_server(37 "HTTP/1.1 200 OK\r\n" +38 "Content-Length: 0\r\n\r\n", **kwargs39 )4041 return server4243 def run(self):44 try:45 sock = self._create_socket_and_bind()46 # in case self.port = 0
37 unmodified lines