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
e82338dd
Kaydet (Commit)
e82338dd
authored
Kas 19, 2016
tarafından
Martin Panter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #28548: Parse HTTP request version even if too many words received
üst
dc0e6f9e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
15 deletions
+31
-15
server.py
Lib/http/server.py
+18
-15
test_httpservers.py
Lib/test/test_httpservers.py
+10
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/http/server.py
Dosyayı görüntüle @
e82338dd
...
...
@@ -267,8 +267,8 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
are in self.command, self.path, self.request_version and
self.headers.
Return True for success, False for failure; on failure, an
error
is
sent back.
Return True for success, False for failure; on failure, an
y relevant
error
response has already been
sent back.
"""
self
.
command
=
None
# set in case of error on the first line
...
...
@@ -278,10 +278,13 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
requestline
=
requestline
.
rstrip
(
'
\r\n
'
)
self
.
requestline
=
requestline
words
=
requestline
.
split
()
if
len
(
words
)
==
3
:
command
,
path
,
version
=
words
if
len
(
words
)
==
0
:
return
False
if
len
(
words
)
>=
3
:
# Enough to determine protocol version
version
=
words
[
-
1
]
try
:
if
version
[:
5
]
!=
'HTTP/'
:
if
not
version
.
startswith
(
'HTTP/'
)
:
raise
ValueError
base_version_number
=
version
.
split
(
'/'
,
1
)[
1
]
version_number
=
base_version_number
.
split
(
"."
)
...
...
@@ -306,22 +309,22 @@ class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
HTTPStatus
.
HTTP_VERSION_NOT_SUPPORTED
,
"Invalid HTTP version (
%
s)"
%
base_version_number
)
return
False
elif
len
(
words
)
==
2
:
command
,
path
=
words
self
.
request_version
=
version
if
not
2
<=
len
(
words
)
<=
3
:
self
.
send_error
(
HTTPStatus
.
BAD_REQUEST
,
"Bad request syntax (
%
r)"
%
requestline
)
return
False
command
,
path
=
words
[:
2
]
if
len
(
words
)
==
2
:
self
.
close_connection
=
True
if
command
!=
'GET'
:
self
.
send_error
(
HTTPStatus
.
BAD_REQUEST
,
"Bad HTTP/0.9 request type (
%
r)"
%
command
)
return
False
elif
not
words
:
return
False
else
:
self
.
send_error
(
HTTPStatus
.
BAD_REQUEST
,
"Bad request syntax (
%
r)"
%
requestline
)
return
False
self
.
command
,
self
.
path
,
self
.
request_version
=
command
,
path
,
version
self
.
command
,
self
.
path
=
command
,
path
# Examine the headers and look for a Connection directive.
try
:
...
...
Lib/test/test_httpservers.py
Dosyayı görüntüle @
e82338dd
...
...
@@ -822,6 +822,16 @@ class BaseHTTPRequestHandlerTestCase(unittest.TestCase):
self
.
assertEqual
(
result
[
0
],
b
'<html><body>Data</body></html>
\r\n
'
)
self
.
verify_get_called
()
def
test_extra_space
(
self
):
result
=
self
.
send_typical_request
(
b
'GET /spaced out HTTP/1.1
\r\n
'
b
'Host: dummy
\r\n
'
b
'
\r\n
'
)
self
.
assertTrue
(
result
[
0
]
.
startswith
(
b
'HTTP/1.1 400 '
))
self
.
verify_expected_headers
(
result
[
1
:
result
.
index
(
b
'
\r\n
'
)])
self
.
assertFalse
(
self
.
handler
.
get_called
)
def
test_with_continue_1_0
(
self
):
result
=
self
.
send_typical_request
(
b
'GET / HTTP/1.0
\r\n
Expect: 100-continue
\r\n\r\n
'
)
self
.
verify_http_server_response
(
result
[
0
])
...
...
Misc/NEWS
Dosyayı görüntüle @
e82338dd
...
...
@@ -128,6 +128,9 @@ Core and Builtins
Library
-------
- Issue #28548: In the "http.server" module, parse the protocol version if
possible, to avoid using HTTP 0.9 in some error responses.
- Issue #19717: Makes Path.resolve() succeed on paths that do not exist.
Patch by Vajrasky Kok
...
...
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