mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
Patch #727483: Add AUTH_TYPE and REMOTE_USER.
This commit is contained in:
parent
061f132898
commit
a28b3e6dfb
1 changed files with 15 additions and 2 deletions
|
@ -153,8 +153,21 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||||
if host != self.client_address[0]:
|
if host != self.client_address[0]:
|
||||||
env['REMOTE_HOST'] = host
|
env['REMOTE_HOST'] = host
|
||||||
env['REMOTE_ADDR'] = self.client_address[0]
|
env['REMOTE_ADDR'] = self.client_address[0]
|
||||||
# XXX AUTH_TYPE
|
authorization = self.headers.getheader("authorization")
|
||||||
# XXX REMOTE_USER
|
if authorization:
|
||||||
|
authorization = authorization.split()
|
||||||
|
if len(authorization) == 2:
|
||||||
|
import base64, binascii
|
||||||
|
env['AUTH_TYPE'] = authorization[0]
|
||||||
|
if authorization[0].lower() == "basic":
|
||||||
|
try:
|
||||||
|
authorization = base64.decodestring(authorization[1])
|
||||||
|
except binascii.Error:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
authorization = authorization.split(':')
|
||||||
|
if len(authorization) == 2:
|
||||||
|
env['REMOTE_USER'] = authorization[0]
|
||||||
# XXX REMOTE_IDENT
|
# XXX REMOTE_IDENT
|
||||||
if self.headers.typeheader is None:
|
if self.headers.typeheader is None:
|
||||||
env['CONTENT_TYPE'] = self.headers.type
|
env['CONTENT_TYPE'] = self.headers.type
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue