RichardC | 3 Dec 01:05

Re: Multiple ports and SSL


So it turns out that if you create two instances of CherryPyWSGIServer
they will share the same environment dictionary 'environ', which
causes problem when one is for HTTP and the other is for HTTPS. This
confused the hell out of me all morning. Here is the change so they
have separate 'environ's.

diff -ru cherrypyp1/wsgiserver/__init__.py cherrypyp2/wsgiserver/
__init__.py
--- cherrypyp1/wsgiserver/__init__.py	2008-12-01 13:36:18.000000000
+1300
+++ cherrypyp2/wsgiserver/__init__.py	2008-12-03 12:56:33.000000000
+1300
@@ -1464,7 +1464,7 @@
     nodelay = True

     ConnectionClass = HTTPConnection
-    environ = {}
+    environ = None

     # Paths to certificate and private key files
     ssl_certificate = None
@@ -1474,6 +1474,9 @@
                  max=-1, request_queue_size=5, timeout=10,
shutdown_timeout=5):
         self.requests = ThreadPool(self, min=numthreads or 1,
max=max)

+        if not self.environ:
+            self.environ = {}
(Continue reading)

Tim Roberts | 3 Dec 01:25

Re: Multiple ports and SSL


RichardC wrote:
> So it turns out that if you create two instances of CherryPyWSGIServer
> they will share the same environment dictionary 'environ', which
> causes problem when one is for HTTP and the other is for HTTPS. This
> confused the hell out of me all morning. Here is the change so they
> have separate 'environ's.
>
>
> diff -ru cherrypyp1/wsgiserver/__init__.py cherrypyp2/wsgiserver/
> __init__.py
> --- cherrypyp1/wsgiserver/__init__.py	2008-12-01 13:36:18 +1300
> +++ cherrypyp2/wsgiserver/__init__.py	2008-12-03 12:56:33 +1300
> @@ -1464,7 +1464,7 @@
>      nodelay = True
>
>      ConnectionClass = HTTPConnection
> -    environ = {}
> +    environ = None
>
>      # Paths to certificate and private key files
>      ssl_certificate = None
> @@ -1474,6 +1474,9 @@
>                   max=-1, request_queue_size=5, timeout=10,
> shutdown_timeout=5):
>          self.requests = ThreadPool(self, min=numthreads or 1,
> max=max)
>
> +        if not self.environ:
> +            self.environ = {}
(Continue reading)

Robert Brewer | 3 Dec 01:46
Favicon
Gravatar

Re: Multiple ports and SSL


Tim Roberts wrote:
> RichardC wrote:
> > So it turns out that if you create two instances of
> > CherryPyWSGIServer
> > they will share the same environment dictionary 'environ', which
> > causes problem when one is for HTTP and the other is for HTTPS. This
> > confused the hell out of me all morning.

Sorry about that, Richard.

> > Here is the change so they
> > have separate 'environ's.
> >
> >
> > diff -ru cherrypyp1/wsgiserver/__init__.py cherrypyp2/wsgiserver/
> > __init__.py
> > --- cherrypyp1/wsgiserver/__init__.py	2008-12-01 13:36:18
+1300
> > +++ cherrypyp2/wsgiserver/__init__.py	2008-12-03 12:56:33
+1300
> > @@ -1464,7 +1464,7 @@
> >      nodelay = True
> >
> >      ConnectionClass = HTTPConnection
> > -    environ = {}
> > +    environ = None
> >
> >      # Paths to certificate and private key files
> >      ssl_certificate = None
(Continue reading)

RichardC | 3 Dec 22:03

Re: Multiple ports and SSL


> @@ -1474,6 +1474,9 @@
>                   max=-1, request_queue_size=5, timeout=10,
> shutdown_timeout=5):
>          self.requests = ThreadPool(self, min=numthreads or 1,
> max=max)
> +        self.environ = self.environ.copy()
>
Yes that's a much smarter way of doing it.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-users@...
To unsubscribe from this group, send email to cherrypy-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Gmane