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
7d49bba9
Kaydet (Commit)
7d49bba9
authored
Mar 02, 2009
tarafından
Benjamin Peterson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
give httplib.IncompleteRead a more sane repr #4308
üst
ce45a967
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
2 deletions
+34
-2
httplib.py
Lib/httplib.py
+11
-2
test_httplib.py
Lib/test/test_httplib.py
+19
-0
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/httplib.py
Dosyayı görüntüle @
7d49bba9
...
...
@@ -626,7 +626,7 @@ class HTTPResponse:
while
amt
>
0
:
chunk
=
self
.
fp
.
read
(
min
(
amt
,
MAXAMOUNT
))
if
not
chunk
:
raise
IncompleteRead
(
s
)
raise
IncompleteRead
(
''
.
join
(
s
),
amt
)
s
.
append
(
chunk
)
amt
-=
len
(
chunk
)
return
''
.
join
(
s
)
...
...
@@ -1161,9 +1161,18 @@ class UnimplementedFileMode(HTTPException):
pass
class
IncompleteRead
(
HTTPException
):
def
__init__
(
self
,
partial
):
def
__init__
(
self
,
partial
,
expected
=
None
):
self
.
args
=
partial
,
self
.
partial
=
partial
self
.
expected
=
expected
def
__repr__
(
self
):
if
self
.
expected
is
not
None
:
e
=
',
%
i more expected'
%
self
.
expected
else
:
e
=
''
return
'IncompleteRead(
%
i bytes read
%
s)'
%
(
len
(
self
.
partial
),
e
)
def
__str__
(
self
):
return
repr
(
self
)
class
ImproperConnectionState
(
HTTPException
):
pass
...
...
Lib/test/test_httplib.py
Dosyayı görüntüle @
7d49bba9
...
...
@@ -185,6 +185,8 @@ class BasicTest(TestCase):
resp
.
read
()
except
httplib
.
IncompleteRead
,
i
:
self
.
assertEquals
(
i
.
partial
,
'hello world'
)
self
.
assertEqual
(
repr
(
i
),
'IncompleteRead(11 bytes read)'
)
self
.
assertEqual
(
str
(
i
),
'IncompleteRead(11 bytes read)'
)
else
:
self
.
fail
(
'IncompleteRead expected'
)
finally
:
...
...
@@ -198,6 +200,23 @@ class BasicTest(TestCase):
self
.
assertEquals
(
resp
.
read
(),
'Hello
\r\n
'
)
resp
.
close
()
def
test_incomplete_read
(
self
):
sock
=
FakeSocket
(
'HTTP/1.1 200 OK
\r\n
Content-Length: 10
\r\n\r\n
Hello
\r\n
'
)
resp
=
httplib
.
HTTPResponse
(
sock
,
method
=
"GET"
)
resp
.
begin
()
try
:
resp
.
read
()
except
httplib
.
IncompleteRead
as
i
:
self
.
assertEquals
(
i
.
partial
,
'Hello
\r\n
'
)
self
.
assertEqual
(
repr
(
i
),
"IncompleteRead(7 bytes read, 3 more expected)"
)
self
.
assertEqual
(
str
(
i
),
"IncompleteRead(7 bytes read, 3 more expected)"
)
else
:
self
.
fail
(
'IncompleteRead expected'
)
finally
:
resp
.
close
()
class
OfflineTest
(
TestCase
):
def
test_responses
(
self
):
...
...
Misc/ACKS
Dosyayı görüntüle @
7d49bba9
...
...
@@ -765,6 +765,7 @@ Dik Winter
Blake Winton
Jean-Claude Wippler
Lars Wirzenius
Chris Withers
Stefan Witzel
David Wolever
Klaus-Juergen Wolf
...
...
Misc/NEWS
Dosyayı görüntüle @
7d49bba9
...
...
@@ -168,6 +168,9 @@ Core and Builtins
Library
-------
- Issue #4308: httplib.IncompleteRead's repr doesn't include all of the data all
ready received.
- Issue #5401: Fixed a performance problem in mimetypes when ``from mimetypes
import guess_extension`` was used.
...
...
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