| OLD | NEW |
| 1 """HTTP server base class. | 1 """HTTP server base class. |
| 2 | 2 |
| 3 Note: the class in this module doesn't implement any HTTP request; see | 3 Note: the class in this module doesn't implement any HTTP request; see |
| 4 SimpleHTTPServer for simple implementations of GET, HEAD and POST | 4 SimpleHTTPServer for simple implementations of GET, HEAD and POST |
| 5 (including CGI scripts). It does, however, optionally implement HTTP/1.1 | 5 (including CGI scripts). It does, however, optionally implement HTTP/1.1 |
| 6 persistent connections, as of version 0.3. | 6 persistent connections, as of version 0.3. |
| 7 | 7 |
| 8 Contents: | 8 Contents: |
| 9 | 9 |
| 10 - BaseHTTPRequestHandler: HTTP request handler base class | 10 - BaseHTTPRequestHandler: HTTP request handler base class |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 # (Actually, the latter is only true if you know the server configuration | 66 # (Actually, the latter is only true if you know the server configuration |
| 67 # at the time the request was made!) | 67 # at the time the request was made!) |
| 68 | 68 |
| 69 __version__ = "0.3" | 69 __version__ = "0.3" |
| 70 | 70 |
| 71 __all__ = ["HTTPServer", "BaseHTTPRequestHandler"] | 71 __all__ = ["HTTPServer", "BaseHTTPRequestHandler"] |
| 72 | 72 |
| 73 import sys | 73 import sys |
| 74 import time | 74 import time |
| 75 import socket # For gethostbyaddr() | 75 import socket # For gethostbyaddr() |
| 76 from test.test_support import catch_warning | 76 from warnings import filterwarnings, catch_warnings |
| 77 from warnings import filterwarnings | 77 with catch_warnings(): |
| 78 with catch_warning(record=False): | 78 if sys.py3kwarning: |
| 79 filterwarnings("ignore", ".*mimetools has been removed", | 79 filterwarnings("ignore", ".*mimetools has been removed", |
| 80 DeprecationWarning) | 80 DeprecationWarning) |
| 81 import mimetools | 81 import mimetools |
| 82 import SocketServer | 82 import SocketServer |
| 83 | 83 |
| 84 # Default error message template | 84 # Default error message template |
| 85 DEFAULT_ERROR_MESSAGE = """\ | 85 DEFAULT_ERROR_MESSAGE = """\ |
| 86 <head> | 86 <head> |
| 87 <title>Error response</title> | 87 <title>Error response</title> |
| 88 </head> | 88 </head> |
| 89 <body> | 89 <body> |
| 90 <h1>Error response</h1> | 90 <h1>Error response</h1> |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 HandlerClass.protocol_version = protocol | 583 HandlerClass.protocol_version = protocol |
| 584 httpd = ServerClass(server_address, HandlerClass) | 584 httpd = ServerClass(server_address, HandlerClass) |
| 585 | 585 |
| 586 sa = httpd.socket.getsockname() | 586 sa = httpd.socket.getsockname() |
| 587 print "Serving HTTP on", sa[0], "port", sa[1], "..." | 587 print "Serving HTTP on", sa[0], "port", sa[1], "..." |
| 588 httpd.serve_forever() | 588 httpd.serve_forever() |
| 589 | 589 |
| 590 | 590 |
| 591 if __name__ == '__main__': | 591 if __name__ == '__main__': |
| 592 test() | 592 test() |
| OLD | NEW |