comparison MoinMoin/support/flup/client/scgi_app.py @ 5804:2e7f76626b58

update flup to repo tip (no release since 1.0.2 / 2.5y)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 01 Dec 2011 02:38:57 +0100
parents eb463542664e
children
comparison
equal deleted inserted replaced
5803:6446873d152f 5804:2e7f76626b58
29 29
30 import select 30 import select
31 import struct 31 import struct
32 import socket 32 import socket
33 import errno 33 import errno
34 import types
34 35
35 __all__ = ['SCGIApp'] 36 __all__ = ['SCGIApp']
36 37
37 def encodeNetstring(s): 38 def encodeNetstring(s):
38 return ''.join([str(len(s)), ':', s, ',']) 39 return ''.join([str(len(s)), ':', s, ','])
134 # Set WSGI status, headers, and return result. 135 # Set WSGI status, headers, and return result.
135 start_response(status, headers) 136 start_response(status, headers)
136 return [result] 137 return [result]
137 138
138 def _getConnection(self): 139 def _getConnection(self):
139 if type(self._connect) is str: 140 if isinstance(self._connect, types.StringTypes):
140 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 141 sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
142 sock.connect(self._connect)
143 elif hasattr(socket, 'create_connection'):
144 sock = socket.create_connection(self._connect)
141 else: 145 else:
142 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 146 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
143 sock.connect(self._connect) 147 sock.connect(self._connect)
144 return sock 148 return sock
145 149
146 _environPrefixes = ['SERVER_', 'HTTP_', 'REQUEST_', 'REMOTE_', 'PATH_', 150 _environPrefixes = ['SERVER_', 'HTTP_', 'REQUEST_', 'REMOTE_', 'PATH_',
147 'CONTENT_'] 151 'CONTENT_']
148 _environCopies = ['SCRIPT_NAME', 'QUERY_STRING', 'AUTH_TYPE'] 152 _environCopies = ['SCRIPT_NAME', 'QUERY_STRING', 'AUTH_TYPE']