Example #1
0
File: wsgi.py Project: lzimm/360io
 def setupEnvironment(self, request):
     # Called in IO thread
     env = createCGIEnvironment(request)
     env['wsgi.version']      = (1, 0)
     env['wsgi.url_scheme']   = env['REQUEST_SCHEME']
     env['wsgi.input']        = InputStream(request.stream)
     env['wsgi.errors']       = ErrorStream()
     env['wsgi.multithread']  = True
     env['wsgi.multiprocess'] = False
     env['wsgi.run_once']     = False
     env['wsgi.file_wrapper'] = FileWrapper
     self.environment = env
Example #2
0
 def connectionMade(self):
     # Ooh, look someone did all the hard work for me :).
     env = twcgi.createCGIEnvironment(self.request)
     # Send the headers. The Content-Length header should always be sent
     # first and must be 0 if not present.
     # The whole lot is sent as one big netstring with each name and value
     # separated by a '\0'.
     contentLength = str(env.pop('CONTENT_LENGTH', 0))
     env['SCGI'] = '1'
     scgiHeaders = []
     scgiHeaders.append('%s\x00%s\x00'%('CONTENT_LENGTH', str(contentLength)))
     scgiHeaders.append('SCGI\x001\x00')
     for name, value in env.iteritems():
         if name in ('CONTENT_LENGTH', 'SCGI'):
             continue
         scgiHeaders.append('%s\x00%s\x00'%(name,value))
     scgiHeaders = ''.join(scgiHeaders)
     self.transport.write('%d:%s,' % (len(scgiHeaders), scgiHeaders))
     stream.StreamProducer(self.request.stream).beginProducing(self.transport)
Example #3
0
 def connectionMade(self):
     # Ooh, look someone did all the hard work for me :).
     env = twcgi.createCGIEnvironment(self.request)
     # Send the headers. The Content-Length header should always be sent
     # first and must be 0 if not present.
     # The whole lot is sent as one big netstring with each name and value
     # separated by a '\0'.
     contentLength = str(env.pop('CONTENT_LENGTH', 0))
     env['SCGI'] = '1'
     scgiHeaders = []
     scgiHeaders.append('%s\x00%s\x00' %
                        ('CONTENT_LENGTH', str(contentLength)))
     scgiHeaders.append('SCGI\x001\x00')
     for name, value in env.iteritems():
         if name in ('CONTENT_LENGTH', 'SCGI'):
             continue
         scgiHeaders.append('%s\x00%s\x00' % (name, value))
     scgiHeaders = ''.join(scgiHeaders)
     self.transport.write('%d:%s,' % (len(scgiHeaders), scgiHeaders))
     stream.StreamProducer(self.request.stream).beginProducing(
         self.transport)