mirror of
https://github.com/python/cpython.git
synced 2025-07-28 21:55:21 +00:00
Patch #1481079: Support of HTTP_REFERER in CGIHTTPServer.py
This commit is contained in:
parent
a30fcb4dae
commit
83b2bf6d9a
1 changed files with 4 additions and 1 deletions
|
@ -197,6 +197,9 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||||
length = self.headers.getheader('content-length')
|
length = self.headers.getheader('content-length')
|
||||||
if length:
|
if length:
|
||||||
env['CONTENT_LENGTH'] = length
|
env['CONTENT_LENGTH'] = length
|
||||||
|
referer = self.headers.getheader('referer')
|
||||||
|
if referer:
|
||||||
|
env['HTTP_REFERER'] = referer
|
||||||
accept = []
|
accept = []
|
||||||
for line in self.headers.getallmatchingheaders('accept'):
|
for line in self.headers.getallmatchingheaders('accept'):
|
||||||
if line[:1] in "\t\n\r ":
|
if line[:1] in "\t\n\r ":
|
||||||
|
@ -214,7 +217,7 @@ class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||||
# Since we're setting the env in the parent, provide empty
|
# Since we're setting the env in the parent, provide empty
|
||||||
# values to override previously set values
|
# values to override previously set values
|
||||||
for k in ('QUERY_STRING', 'REMOTE_HOST', 'CONTENT_LENGTH',
|
for k in ('QUERY_STRING', 'REMOTE_HOST', 'CONTENT_LENGTH',
|
||||||
'HTTP_USER_AGENT', 'HTTP_COOKIE'):
|
'HTTP_USER_AGENT', 'HTTP_COOKIE', 'HTTP_REFERER'):
|
||||||
env.setdefault(k, "")
|
env.setdefault(k, "")
|
||||||
os.environ.update(env)
|
os.environ.update(env)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue