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
55c12d4d
Kaydet (Commit)
55c12d4d
authored
Agu 09, 2001
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
SF patch #403640: incomplete proxy handling in URLLIB
Look specific to Windows. Don't know whether it works.
üst
f0713d3f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
urllib.py
Lib/urllib.py
+62
-0
No files found.
Lib/urllib.py
Dosyayı görüntüle @
55c12d4d
...
...
@@ -269,6 +269,9 @@ class URLopener:
user_passwd
,
realhost
=
splituser
(
realhost
)
if
user_passwd
:
selector
=
"
%
s://
%
s
%
s"
%
(
urltype
,
realhost
,
rest
)
if
proxy_bypass
(
realhost
):
host
=
realhost
#print "proxy via http:", host, selector
if
not
host
:
raise
IOError
,
(
'http error'
,
'no host given'
)
if
user_passwd
:
...
...
@@ -1252,6 +1255,9 @@ if os.name == 'mac':
# Gopher: XXXX To be done.
return
proxies
def
proxy_bypass
(
x
):
return
0
elif
os
.
name
==
'nt'
:
def
getproxies_registry
():
"""Return a dictionary of scheme -> proxy server URL mappings.
...
...
@@ -1302,10 +1308,66 @@ elif os.name == 'nt':
"""
return
getproxies_environment
()
or
getproxies_registry
()
def
proxy_bypass
(
host
):
try
:
import
_winreg
import
re
import
socket
except
ImportError
:
# Std modules, so should be around - but you never know!
return
0
try
:
internetSettings
=
_winreg
.
OpenKey
(
_winreg
.
HKEY_CURRENT_USER
,
r'Software\Microsoft\Windows\CurrentVersion\Internet Settings'
)
proxyEnable
=
_winreg
.
QueryValueEx
(
internetSettings
,
'ProxyEnable'
)[
0
]
proxyOverride
=
str
(
_winreg
.
QueryValueEx
(
internetSettings
,
'ProxyOverride'
)[
0
])
# ^^^^ Returned as Unicode but problems if not converted to ASCII
except
WindowsError
:
return
0
if
not
proxyEnable
or
not
proxyOverride
:
return
0
# try to make a host list from name and IP address.
host
=
[
host
]
try
:
addr
=
socket
.
gethostbyname
(
host
[
0
])
if
addr
!=
host
:
host
.
append
(
addr
)
except
socket
.
error
:
pass
# make a check value list from the registry entry: replace the
# '<local>' string by the localhost entry and the corresponding
# canonical entry.
proxyOverride
=
proxyOverride
.
split
(
';'
)
i
=
0
while
i
<
len
(
proxyOverride
):
if
proxyOverride
[
i
]
==
'<local>'
:
proxyOverride
[
i
:
i
+
1
]
=
[
'localhost'
,
'127.0.0.1'
,
socket
.
gethostname
(),
socket
.
gethostbyname
(
socket
.
gethostname
())]
i
+=
1
# print proxyOverride
# now check if we match one of the registry values.
for
test
in
proxyOverride
:
test
=
test
.
replace
(
"."
,
r"\."
)
# mask dots
test
=
test
.
replace
(
"*"
,
r".*"
)
# change glob sequence
test
=
test
.
replace
(
"?"
,
r"."
)
# change glob char
for
val
in
host
:
# print "%s <--> %s" %( test, val )
if
re
.
match
(
test
,
val
,
re
.
I
):
return
1
return
0
else
:
# By default use environment variables
getproxies
=
getproxies_environment
def
proxy_bypass
(
host
):
return
0
# Test and time quote() and unquote()
def
test1
():
...
...
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