Back to index

python3.2  3.2.2
Classes | Functions | Variables
test.test_urllib2_localnet Namespace Reference

Classes

class  LoopbackHttpServer
class  LoopbackHttpServerThread
class  DigestAuthHandler
class  FakeProxyHandler
class  ProxyAuthTests
class  TestUrlopen

Functions

def GetRequestHandler
def test_main

Variables

tuple threading = support.import_module('threading')
tuple here = os.path.dirname(__file__)
tuple CERT_localhost = os.path.join(here, 'keycert.pem')
tuple CERT_fakehostname = os.path.join(here, 'keycert2.pem')

Function Documentation

Definition at line 301 of file test_urllib2_localnet.py.

00301 
00302 def GetRequestHandler(responses):
00303 
00304     class FakeHTTPRequestHandler(http.server.BaseHTTPRequestHandler):
00305 
00306         server_version = "TestHTTP/"
00307         requests = []
00308         headers_received = []
00309         port = 80
00310 
00311         def do_GET(self):
00312             body = self.send_head()
00313             while body:
00314                 done = self.wfile.write(body)
00315                 body = body[done:]
00316 
00317         def do_POST(self):
00318             content_length = self.headers["Content-Length"]
00319             post_data = self.rfile.read(int(content_length))
00320             self.do_GET()
00321             self.requests.append(post_data)
00322 
00323         def send_head(self):
00324             FakeHTTPRequestHandler.headers_received = self.headers
00325             self.requests.append(self.path)
00326             response_code, headers, body = responses.pop(0)
00327 
00328             self.send_response(response_code)
00329 
00330             for (header, value) in headers:
00331                 self.send_header(header, value % {'port':self.port})
00332             if body:
00333                 self.send_header("Content-type", "text/plain")
00334                 self.end_headers()
00335                 return body
00336             self.end_headers()
00337 
00338         def log_message(self, *args):
00339             pass
00340 
00341 
00342     return FakeHTTPRequestHandler
00343 

Here is the caller graph for this function:

Definition at line 560 of file test_urllib2_localnet.py.

00560 
00561 def test_main():
00562     support.run_unittest(ProxyAuthTests, TestUrlopen)


Variable Documentation

Definition at line 18 of file test_urllib2_localnet.py.

Definition at line 16 of file test_urllib2_localnet.py.

tuple test.test_urllib2_localnet.here = os.path.dirname(__file__)

Definition at line 14 of file test_urllib2_localnet.py.

Definition at line 11 of file test_urllib2_localnet.py.