Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
4271372a
Kaydet (Commit)
4271372a
authored
Eki 03, 2010
tarafından
Senthil Kumaran
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix Issue9272 - Change CGIHTTPServer to give the child program a copy of os.environ
üst
388f956c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
server.py
Lib/http/server.py
+5
-4
test_httpservers.py
Lib/test/test_httpservers.py
+8
-0
No files found.
Lib/http/server.py
Dosyayı görüntüle @
4271372a
...
...
@@ -99,6 +99,7 @@ import socketserver
import
sys
import
time
import
urllib.parse
import
copy
# Default error message template
DEFAULT_ERROR_MESSAGE
=
"""
\
...
...
@@ -994,7 +995,7 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
# Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html
# XXX Much of the following could be prepared ahead of time!
env
=
{}
env
=
copy
.
deepcopy
(
os
.
environ
)
env
[
'SERVER_SOFTWARE'
]
=
self
.
version_string
()
env
[
'SERVER_NAME'
]
=
self
.
server
.
server_name
env
[
'GATEWAY_INTERFACE'
]
=
'CGI/1.1'
...
...
@@ -1059,7 +1060,6 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
for
k
in
(
'QUERY_STRING'
,
'REMOTE_HOST'
,
'CONTENT_LENGTH'
,
'HTTP_USER_AGENT'
,
'HTTP_COOKIE'
,
'HTTP_REFERER'
):
env
.
setdefault
(
k
,
""
)
os
.
environ
.
update
(
env
)
self
.
send_response
(
200
,
"Script output follows"
)
...
...
@@ -1091,7 +1091,7 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
pass
os
.
dup2
(
self
.
rfile
.
fileno
(),
0
)
os
.
dup2
(
self
.
wfile
.
fileno
(),
1
)
os
.
execve
(
scriptfile
,
args
,
os
.
environ
)
os
.
execve
(
scriptfile
,
args
,
env
)
except
:
self
.
server
.
handle_error
(
self
.
request
,
self
.
client_address
)
os
.
_exit
(
127
)
...
...
@@ -1116,7 +1116,8 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
p
=
subprocess
.
Popen
(
cmdline
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
stderr
=
subprocess
.
PIPE
,
env
=
env
)
if
self
.
command
.
lower
()
==
"post"
and
nbytes
>
0
:
data
=
self
.
rfile
.
read
(
nbytes
)
...
...
Lib/test/test_httpservers.py
Dosyayı görüntüle @
4271372a
...
...
@@ -402,6 +402,14 @@ class CGIHTTPServerTestCase(BaseTestCase):
self
.
assertEqual
((
b
'Hello World
\n
'
,
'text/html'
,
200
),
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
def
test_os_environ_is_not_altered
(
self
):
signature
=
"Test CGI Server"
os
.
environ
[
'SERVER_SOFTWARE'
]
=
signature
res
=
self
.
request
(
'/cgi-bin/file1.py'
)
self
.
assertEqual
((
b
'Hello World
\n
'
,
'text/html'
,
200
),
(
res
.
read
(),
res
.
getheader
(
'Content-type'
),
res
.
status
))
self
.
assertEqual
(
os
.
environ
[
'SERVER_SOFTWARE'
],
signature
)
class
SocketlessRequestHandler
(
SimpleHTTPRequestHandler
):
def
__init__
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment