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
d44a5afa
Kaydet (Commit)
d44a5afa
authored
Tem 25, 2007
tarafından
Nick Coghlan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
More buildbot cleanup - let the OS assign the port for test_urllib2_localnet
üst
16ed5b4b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
29 deletions
+11
-29
test_urllib2_localnet.py
Lib/test/test_urllib2_localnet.py
+11
-29
No files found.
Lib/test/test_urllib2_localnet.py
Dosyayı görüntüle @
d44a5afa
...
@@ -40,14 +40,16 @@ class LoopbackHttpServer(BaseHTTPServer.HTTPServer):
...
@@ -40,14 +40,16 @@ class LoopbackHttpServer(BaseHTTPServer.HTTPServer):
class
LoopbackHttpServerThread
(
threading
.
Thread
):
class
LoopbackHttpServerThread
(
threading
.
Thread
):
"""Stoppable thread that runs a loopback http server."""
"""Stoppable thread that runs a loopback http server."""
def
__init__
(
self
,
port
,
RequestHandlerClass
):
def
__init__
(
self
,
request_handler
):
threading
.
Thread
.
__init__
(
self
)
threading
.
Thread
.
__init__
(
self
)
self
.
_RequestHandlerClass
=
RequestHandlerClass
self
.
_stop
=
False
self
.
_stop
=
False
self
.
_port
=
port
self
.
_server_address
=
(
'127.0.0.1'
,
self
.
_port
)
self
.
ready
=
threading
.
Event
()
self
.
ready
=
threading
.
Event
()
self
.
error
=
None
request_handler
.
protocol_version
=
"HTTP/1.0"
self
.
httpd
=
LoopbackHttpServer
((
'127.0.0.1'
,
0
),
request_handler
)
#print "Serving HTTP on %s port %s" % (self.httpd.server_name,
# self.httpd.server_port)
self
.
port
=
self
.
httpd
.
server_port
def
stop
(
self
):
def
stop
(
self
):
"""Stops the webserver if it's currently running."""
"""Stops the webserver if it's currently running."""
...
@@ -58,24 +60,9 @@ class LoopbackHttpServerThread(threading.Thread):
...
@@ -58,24 +60,9 @@ class LoopbackHttpServerThread(threading.Thread):
self
.
join
()
self
.
join
()
def
run
(
self
):
def
run
(
self
):
protocol
=
"HTTP/1.0"
try
:
self
.
_RequestHandlerClass
.
protocol_version
=
protocol
httpd
=
LoopbackHttpServer
(
self
.
_server_address
,
self
.
_RequestHandlerClass
)
sa
=
httpd
.
socket
.
getsockname
()
#print "Serving HTTP on", sa[0], "port", sa[1], "..."
except
:
# Fail "gracefully" if we are unable to start.
self
.
ready
.
set
()
self
.
error
=
sys
.
exc_info
()[
1
]
raise
self
.
ready
.
set
()
self
.
ready
.
set
()
while
not
self
.
_stop
:
while
not
self
.
_stop
:
httpd
.
handle_request
()
self
.
httpd
.
handle_request
()
# Authentication infrastructure
# Authentication infrastructure
...
@@ -232,26 +219,21 @@ class FakeProxyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
...
@@ -232,26 +219,21 @@ class FakeProxyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
class
ProxyAuthTests
(
unittest
.
TestCase
):
class
ProxyAuthTests
(
unittest
.
TestCase
):
URL
=
"http://www.foo.com"
URL
=
"http://www.foo.com"
PORT
=
8080
USER
=
"tester"
USER
=
"tester"
PASSWD
=
"test123"
PASSWD
=
"test123"
REALM
=
"TestRealm"
REALM
=
"TestRealm"
PROXY_URL
=
"http://127.0.0.1:
%
d"
%
PORT
def
setUp
(
self
):
def
setUp
(
self
):
FakeProxyHandler
.
digest_auth_handler
.
set_users
({
FakeProxyHandler
.
digest_auth_handler
.
set_users
({
self
.
USER
:
self
.
PASSWD
self
.
USER
:
self
.
PASSWD
})
})
FakeProxyHandler
.
digest_auth_handler
.
set_realm
(
self
.
REALM
)
FakeProxyHandler
.
digest_auth_handler
.
set_realm
(
self
.
REALM
)
self
.
server
=
LoopbackHttpServerThread
(
self
.
PORT
,
FakeProxyHandler
)
self
.
server
=
LoopbackHttpServerThread
(
FakeProxyHandler
)
self
.
server
.
start
()
self
.
server
.
start
()
self
.
server
.
ready
.
wait
()
self
.
server
.
ready
.
wait
()
if
self
.
server
.
error
:
proxy_url
=
"http://127.0.0.1:
%
d"
%
self
.
server
.
port
raise
self
.
server
.
error
handler
=
urllib2
.
ProxyHandler
({
"http"
:
proxy_url
})
handler
=
urllib2
.
ProxyHandler
({
"http"
:
self
.
PROXY_URL
})
self
.
_digest_auth_handler
=
urllib2
.
ProxyDigestAuthHandler
()
self
.
_digest_auth_handler
=
urllib2
.
ProxyDigestAuthHandler
()
self
.
opener
=
urllib2
.
build_opener
(
handler
,
self
.
_digest_auth_handler
)
self
.
opener
=
urllib2
.
build_opener
(
handler
,
self
.
_digest_auth_handler
)
...
...
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