[Twisted-web] reactor.listenSSL() question

Jean-Paul Calderone exarkun at divmod.com
Tue Apr 21 14:13:00 EDT 2009

On Tue, 21 Apr 2009 13:47:06 -0400, vitaly at synapticvision.com wrote:
>I'm trying to make work the following client/server, but the
>server always return: HTTP/1.1 400 Bad Request.

You seem to be connecting something which is not an HTTP client to an
HTTP server.  So the HTTP server complains because what is being sent
to it is not an HTTP request.

> [snip - setup]
>      reactor.listenSSL(8050, server.Site(root), ServerContextFactory())
>      reactor.run()

There's your HTTP server.

> [snip - imports]
>class EchoClient(LineReceiver):
>      end="Bye-bye!"
>      def connectionMade(self):
>          self.sendLine("Hello, world!")
>          self.sendLine("What a fine day it is.")
>          self.sendLine(self.end)
> [snip - more stuff]
>      factory = EchoClientFactory()
>      reactor.connectSSL('localhost', 8050, factory,
>ssl.ClientContextFactory(), timeout=3)
>      reactor.run()

And there's your client - something which isn't going to send HTTP
requests to the server it connects to.

So a 400 response is precisely what you should expect here. :)


More information about the Twisted-web mailing list