"""
import socket as _socket
+import urlparse as _urlparse
__version__ = '0.1'
content_length = len(data)
except TypeError:
content_length = 0
+ # From RFC 2616, section 5.1.2:
+ # REQUEST_URI is hex-encoded absolute path
+ # From Nginx HttpCoreModule docs:
+ # $document_uri
+ # The same as $uri.
+ # $request_uri
+ # This variable is equal to the *original* request URI as
+ # received from the client including the args. It cannot be
+ # modified. Look at $uri for the post-rewrite/altered
+ # URI. Does not include host name. Example:
+ # "/foo/bar.php?arg=baz"
+ # $uri
+ # This variable is the current request URI, without any
+ # arguments (see $args for those). This variable will reflect
+ # any modifications done so far by internal redirects or the
+ # index module. Note this may be different from $request_uri,
+ # as $request_uri is what was originally sent by the browser
+ # before any such modifications. Does not include the protocol
+ # or host name. Example: /foo/bar.html
+ scheme,netloc,path,params,query,fragment = _urlparse.urlparse(uri)
+ # <scheme>://<netloc>/<path>;<params>?<query>#<fragment>
+ scheme = netloc = ''
+ request_uri = _urlparse.urlunparse(
+ (scheme, netloc, path, params, query, fragment))
+ document_uri = path
strings = [
'CONTENT_LENGTH\x00{}\x00'.format(content_length),
'SCGI\x00{}\x00'.format(1),
'REQUEST_METHOD\x00{}\x00'.format(method),
- 'REQUEST_URI\x00{}\x00'.format(uri),
+ 'REQUEST_URI\x00{}\x00'.format(request_uri),
+ 'DOCUMENT_URI\x00{}\x00'.format(document_uri),
]
return ''.join(strings)