def server(listener): sock = listener.accept()[0] read_request(sock) sock.send('HTTP/1.1 200 OK\r\n' 'Content-Type: text/plain\r\n' 'Content-Length: 8\r\n' '\r\n' 'Inspire.') sock.close()
def server(listener): for i in 0, 1: sock = listener.accept()[0] read_request(sock) body = 'Response %d' % i sock.send('HTTP/1.1 200 OK\r\n' 'Content-Type: text/plain\r\n' 'Content-Length: %d\r\n' '\r\n' '%s' % (len(body), body)) sock.close() # simulate a server timing out, closing socket done_closing.set() # let the test know it can proceed