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
d34b57a9
Kaydet (Commit)
d34b57a9
authored
May 19, 2012
tarafından
Senthil Kumaran
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge - Fix Issue14721: Send Content-length: 0 for empty body () in the http.client requests
üst
15e848b0
5fa4a896
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
1 deletion
+32
-1
client.py
Lib/http/client.py
+1
-1
test_httplib.py
Lib/test/test_httplib.py
+28
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/http/client.py
Dosyayı görüntüle @
d34b57a9
...
...
@@ -1076,7 +1076,7 @@ class HTTPConnection:
self
.
putrequest
(
method
,
url
,
**
skips
)
if
body
and
(
'content-length'
not
in
header_names
):
if
body
is
not
None
and
(
'content-length'
not
in
header_names
):
self
.
_set_content_length
(
body
)
for
hdr
,
value
in
headers
.
items
():
self
.
putheader
(
hdr
,
value
)
...
...
Lib/test/test_httplib.py
Dosyayı görüntüle @
d34b57a9
...
...
@@ -99,6 +99,34 @@ class HeaderTests(TestCase):
conn
.
request
(
'POST'
,
'/'
,
body
,
headers
)
self
.
assertEqual
(
conn
.
_buffer
.
count
[
header
.
lower
()],
1
)
def
test_content_length_0
(
self
):
class
ContentLengthChecker
(
list
):
def
__init__
(
self
):
list
.
__init__
(
self
)
self
.
content_length
=
None
def
append
(
self
,
item
):
kv
=
item
.
split
(
b
':'
,
1
)
if
len
(
kv
)
>
1
and
kv
[
0
]
.
lower
()
==
b
'content-length'
:
self
.
content_length
=
kv
[
1
]
.
strip
()
list
.
append
(
self
,
item
)
# POST with empty body
conn
=
client
.
HTTPConnection
(
'example.com'
)
conn
.
sock
=
FakeSocket
(
None
)
conn
.
_buffer
=
ContentLengthChecker
()
conn
.
request
(
'POST'
,
'/'
,
''
)
self
.
assertEqual
(
conn
.
_buffer
.
content_length
,
b
'0'
,
'Header Content-Length not set'
)
# PUT request with empty body
conn
=
client
.
HTTPConnection
(
'example.com'
)
conn
.
sock
=
FakeSocket
(
None
)
conn
.
_buffer
=
ContentLengthChecker
()
conn
.
request
(
'PUT'
,
'/'
,
''
)
self
.
assertEqual
(
conn
.
_buffer
.
content_length
,
b
'0'
,
'Header Content-Length not set'
)
def
test_putheader
(
self
):
conn
=
client
.
HTTPConnection
(
'example.com'
)
conn
.
sock
=
FakeSocket
(
None
)
...
...
Misc/NEWS
Dosyayı görüntüle @
d34b57a9
...
...
@@ -38,6 +38,9 @@ Core and Builtins
Library
-------
- Issue #14721: Send the correct '
Content
-
length
:
0
' header when the body is an
empty string ''. Initial Patch contributed by Arve Knudsen.
- Issue #9374: Generic parsing of query and fragment portions of url for any
scheme. Supported both by RFC3986 and RFC2396.
...
...
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