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
f1349cd0
Kaydet (Commit)
f1349cd0
authored
Mar 28, 2006
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Bug #1459963: urllib2 now normalizes HTTP header names correctly
with title().
üst
240ec6b9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
25 deletions
+31
-25
test_urllib2.py
Lib/test/test_urllib2.py
+6
-6
urllib.py
Lib/urllib.py
+6
-6
urllib2.py
Lib/urllib2.py
+13
-13
NEWS
Misc/NEWS
+6
-0
No files found.
Lib/test/test_urllib2.py
Dosyayı görüntüle @
f1349cd0
...
...
@@ -493,11 +493,11 @@ class HandlerTests(unittest.TestCase):
r
=
MockResponse
(
200
,
"OK"
,
{},
""
)
newreq
=
h
.
do_request_
(
req
)
if
data
is
None
:
# GET
self
.
assert_
(
"Content-
l
ength"
not
in
req
.
unredirected_hdrs
)
self
.
assert_
(
"Content-
t
ype"
not
in
req
.
unredirected_hdrs
)
self
.
assert_
(
"Content-
L
ength"
not
in
req
.
unredirected_hdrs
)
self
.
assert_
(
"Content-
T
ype"
not
in
req
.
unredirected_hdrs
)
else
:
# POST
self
.
assertEqual
(
req
.
unredirected_hdrs
[
"Content-
l
ength"
],
"0"
)
self
.
assertEqual
(
req
.
unredirected_hdrs
[
"Content-
t
ype"
],
self
.
assertEqual
(
req
.
unredirected_hdrs
[
"Content-
L
ength"
],
"0"
)
self
.
assertEqual
(
req
.
unredirected_hdrs
[
"Content-
T
ype"
],
"application/x-www-form-urlencoded"
)
# XXX the details of Host could be better tested
self
.
assertEqual
(
req
.
unredirected_hdrs
[
"Host"
],
"example.com"
)
...
...
@@ -509,8 +509,8 @@ class HandlerTests(unittest.TestCase):
req
.
add_unredirected_header
(
"Host"
,
"baz"
)
req
.
add_unredirected_header
(
"Spam"
,
"foo"
)
newreq
=
h
.
do_request_
(
req
)
self
.
assertEqual
(
req
.
unredirected_hdrs
[
"Content-
l
ength"
],
"foo"
)
self
.
assertEqual
(
req
.
unredirected_hdrs
[
"Content-
t
ype"
],
"bar"
)
self
.
assertEqual
(
req
.
unredirected_hdrs
[
"Content-
L
ength"
],
"foo"
)
self
.
assertEqual
(
req
.
unredirected_hdrs
[
"Content-
T
ype"
],
"bar"
)
self
.
assertEqual
(
req
.
unredirected_hdrs
[
"Host"
],
"baz"
)
self
.
assertEqual
(
req
.
unredirected_hdrs
[
"Spam"
],
"foo"
)
...
...
Lib/urllib.py
Dosyayı görüntüle @
f1349cd0
...
...
@@ -118,7 +118,7 @@ class URLopener:
self
.
proxies
=
proxies
self
.
key_file
=
x509
.
get
(
'key_file'
)
self
.
cert_file
=
x509
.
get
(
'cert_file'
)
self
.
addheaders
=
[(
'User-
a
gent'
,
self
.
version
)]
self
.
addheaders
=
[(
'User-
A
gent'
,
self
.
version
)]
self
.
__tempfiles
=
[]
self
.
__unlink
=
os
.
unlink
# See cleanup()
self
.
tempcache
=
None
...
...
@@ -314,8 +314,8 @@ class URLopener:
h
=
httplib
.
HTTP
(
host
)
if
data
is
not
None
:
h
.
putrequest
(
'POST'
,
selector
)
h
.
putheader
(
'Content-
t
ype'
,
'application/x-www-form-urlencoded'
)
h
.
putheader
(
'Content-
l
ength'
,
'
%
d'
%
len
(
data
))
h
.
putheader
(
'Content-
T
ype'
,
'application/x-www-form-urlencoded'
)
h
.
putheader
(
'Content-
L
ength'
,
'
%
d'
%
len
(
data
))
else
:
h
.
putrequest
(
'GET'
,
selector
)
if
proxy_auth
:
h
.
putheader
(
'Proxy-Authorization'
,
'Basic
%
s'
%
proxy_auth
)
...
...
@@ -400,9 +400,9 @@ class URLopener:
cert_file
=
self
.
cert_file
)
if
data
is
not
None
:
h
.
putrequest
(
'POST'
,
selector
)
h
.
putheader
(
'Content-
t
ype'
,
h
.
putheader
(
'Content-
T
ype'
,
'application/x-www-form-urlencoded'
)
h
.
putheader
(
'Content-
l
ength'
,
'
%
d'
%
len
(
data
))
h
.
putheader
(
'Content-
L
ength'
,
'
%
d'
%
len
(
data
))
else
:
h
.
putrequest
(
'GET'
,
selector
)
if
proxy_auth
:
h
.
putheader
(
'Proxy-Authorization: Basic
%
s'
%
proxy_auth
)
...
...
@@ -584,7 +584,7 @@ class URLopener:
data
=
base64
.
decodestring
(
data
)
else
:
data
=
unquote
(
data
)
msg
.
append
(
'Content-
l
ength:
%
d'
%
len
(
data
))
msg
.
append
(
'Content-
L
ength:
%
d'
%
len
(
data
))
msg
.
append
(
''
)
msg
.
append
(
data
)
msg
=
'
\n
'
.
join
(
msg
)
...
...
Lib/urllib2.py
Dosyayı görüntüle @
f1349cd0
...
...
@@ -254,11 +254,11 @@ class Request:
def
add_header
(
self
,
key
,
val
):
# useful for something like authentication
self
.
headers
[
key
.
capitaliz
e
()]
=
val
self
.
headers
[
key
.
titl
e
()]
=
val
def
add_unredirected_header
(
self
,
key
,
val
):
# will not be added to a redirected request
self
.
unredirected_hdrs
[
key
.
capitaliz
e
()]
=
val
self
.
unredirected_hdrs
[
key
.
titl
e
()]
=
val
def
has_header
(
self
,
header_name
):
return
(
header_name
in
self
.
headers
or
...
...
@@ -277,7 +277,7 @@ class Request:
class
OpenerDirector
:
def
__init__
(
self
):
client_version
=
"Python-urllib/
%
s"
%
__version__
self
.
addheaders
=
[(
'User-
a
gent'
,
client_version
)]
self
.
addheaders
=
[(
'User-
A
gent'
,
client_version
)]
# manage the individual handlers
self
.
handlers
=
[]
self
.
handle_open
=
{}
...
...
@@ -592,7 +592,7 @@ class ProxyHandler(BaseHandler):
user
,
password
=
user_pass
.
split
(
':'
,
1
)
user_pass
=
base64
.
encodestring
(
'
%
s:
%
s'
%
(
unquote
(
user
),
unquote
(
password
)))
.
strip
()
req
.
add_header
(
'Proxy-
a
uthorization'
,
'Basic '
+
user_pass
)
req
.
add_header
(
'Proxy-
A
uthorization'
,
'Basic '
+
user_pass
)
host
=
unquote
(
host
)
req
.
set_proxy
(
host
,
type
)
if
orig_type
==
type
:
...
...
@@ -755,7 +755,7 @@ class HTTPBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
class
ProxyBasicAuthHandler
(
AbstractBasicAuthHandler
,
BaseHandler
):
auth_header
=
'Proxy-
a
uthorization'
auth_header
=
'Proxy-
A
uthorization'
def
http_error_407
(
self
,
req
,
fp
,
code
,
msg
,
headers
):
host
=
req
.
get_host
()
...
...
@@ -955,20 +955,20 @@ class AbstractHTTPHandler(BaseHandler):
if
request
.
has_data
():
# POST
data
=
request
.
get_data
()
if
not
request
.
has_header
(
'Content-
t
ype'
):
if
not
request
.
has_header
(
'Content-
T
ype'
):
request
.
add_unredirected_header
(
'Content-
t
ype'
,
'Content-
T
ype'
,
'application/x-www-form-urlencoded'
)
if
not
request
.
has_header
(
'Content-
l
ength'
):
if
not
request
.
has_header
(
'Content-
L
ength'
):
request
.
add_unredirected_header
(
'Content-
l
ength'
,
'
%
d'
%
len
(
data
))
'Content-
L
ength'
,
'
%
d'
%
len
(
data
))
scheme
,
sel
=
splittype
(
request
.
get_selector
())
sel_host
,
sel_path
=
splithost
(
sel
)
if
not
request
.
has_header
(
'Host'
):
request
.
add_unredirected_header
(
'Host'
,
sel_host
or
host
)
for
name
,
value
in
self
.
parent
.
addheaders
:
name
=
name
.
capitaliz
e
()
name
=
name
.
titl
e
()
if
not
request
.
has_header
(
name
):
request
.
add_unredirected_header
(
name
,
value
)
...
...
@@ -1145,7 +1145,7 @@ class FileHandler(BaseHandler):
modified
=
email
.
Utils
.
formatdate
(
stats
.
st_mtime
,
usegmt
=
True
)
mtype
=
mimetypes
.
guess_type
(
file
)[
0
]
headers
=
mimetools
.
Message
(
StringIO
(
'Content-
type:
%
s
\n
Content-length:
%
d
\n
Last-m
odified:
%
s
\n
'
%
'Content-
Type:
%
s
\n
Content-Length:
%
d
\n
Last-M
odified:
%
s
\n
'
%
(
mtype
or
'text/plain'
,
size
,
modified
)))
if
host
:
host
,
port
=
splitport
(
host
)
...
...
@@ -1198,9 +1198,9 @@ class FTPHandler(BaseHandler):
headers
=
""
mtype
=
mimetypes
.
guess_type
(
req
.
get_full_url
())[
0
]
if
mtype
:
headers
+=
"Content-
t
ype:
%
s
\n
"
%
mtype
headers
+=
"Content-
T
ype:
%
s
\n
"
%
mtype
if
retrlen
is
not
None
and
retrlen
>=
0
:
headers
+=
"Content-
l
ength:
%
d
\n
"
%
retrlen
headers
+=
"Content-
L
ength:
%
d
\n
"
%
retrlen
sf
=
StringIO
(
headers
)
headers
=
mimetools
.
Message
(
sf
)
return
addinfourl
(
fp
,
headers
,
req
.
get_full_url
())
...
...
Misc/NEWS
Dosyayı görüntüle @
f1349cd0
...
...
@@ -483,6 +483,12 @@ Extension Modules
Library
-------
- Bug #1459963: urllib2 now normalizes HTTP header names correctly
with title().
- Bug #1459963: urllib2 now normalizes HTTP header names correctly
with title().
- Queue.Queue objects now support .task_done() and .join() methods
to make it easier to monitor when daemon threads have completed
processing all enqueued tasks. Patch #1455676.
...
...
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