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
6cb15a05
Kaydet (Commit)
6cb15a05
authored
Haz 22, 1995
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
add User-agent hdr; read and close the file upon http error
üst
2ab19920
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
urllib.py
Lib/urllib.py
+14
-3
No files found.
Lib/urllib.py
Dosyayı görüntüle @
6cb15a05
...
...
@@ -19,6 +19,9 @@ import socket
import
regex
__version__
=
'1.0'
# This really consists of two pieces:
# (1) a class which handles opening of all sorts of URLs
# (plus assorted utilities etc.)
...
...
@@ -51,7 +54,8 @@ class URLopener:
# Constructor
def
__init__
(
self
):
self
.
addheaders
=
[]
server_version
=
"Python-urllib/
%
s"
%
__version__
self
.
addheaders
=
[(
'User-agent'
,
server_version
)]
self
.
tempcache
=
None
# Undocumented feature: if you assign {} to tempcache,
# it is used to cache files retrieved with
...
...
@@ -146,9 +150,15 @@ class URLopener:
h
=
httplib
.
HTTP
(
host
)
h
.
putrequest
(
'GET'
,
selector
)
for
args
in
self
.
addheaders
:
apply
(
h
.
putheader
,
args
)
h
.
endheaders
()
errcode
,
errmsg
,
headers
=
h
.
getreply
()
if
errcode
==
200
:
return
addinfo
(
h
.
getfile
(),
headers
)
else
:
raise
IOError
,
(
'http error'
,
errcode
,
errmsg
,
headers
)
fp
=
h
.
getfile
()
if
errcode
==
200
:
return
addinfo
(
fp
,
headers
)
else
:
n
=
len
(
fp
.
read
())
fp
.
close
()
raise
IOError
,
(
'http error'
,
errcode
,
errmsg
,
headers
)
# Use Gopher protocol
def
open_gopher
(
self
,
url
):
...
...
@@ -322,6 +332,7 @@ class addbase:
self
.
readline
=
None
self
.
readlines
=
None
self
.
fileno
=
None
if
self
.
fp
:
self
.
fp
.
close
()
self
.
fp
=
None
# Class to add a close hook to an open file
...
...
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