Replaced hacked Python server modules with ones which
subclass the python modules.
This commit is contained in:
50
apps/sam/python/src/i2p/I2PBaseHTTPServer.py
Normal file
50
apps/sam/python/src/i2p/I2PBaseHTTPServer.py
Normal file
@ -0,0 +1,50 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
import BaseHTTPServer
|
||||
|
||||
import i2p.sam
|
||||
|
||||
import I2PSocketServer
|
||||
|
||||
import sys
|
||||
import BaseHTTPServer
|
||||
|
||||
import i2p.sam
|
||||
import I2PSocketServer
|
||||
|
||||
__version__ = "0.3"
|
||||
|
||||
__all__ = ["HTTPServer", "BaseHTTPRequestHandler"]
|
||||
|
||||
DEFAULT_ERROR_MESSAGE = BaseHTTPServer.DEFAULT_ERROR_MESSAGE
|
||||
|
||||
class HTTPServer(I2PSocketServer.TCPServer, BaseHTTPServer.HTTPServer):
|
||||
pass
|
||||
class BaseHTTPRequestHandler(
|
||||
I2PSocketServer.StreamRequestHandler,
|
||||
BaseHTTPServer.BaseHTTPRequestHandler):
|
||||
pass
|
||||
def test(HandlerClass = BaseHTTPRequestHandler,
|
||||
ServerClass = HTTPServer, protocol="HTTP/1.0"):
|
||||
"""Test the HTTP request handler class.
|
||||
|
||||
This runs an HTTP server on port 8000 (or the first command line
|
||||
argument).
|
||||
|
||||
"""
|
||||
|
||||
if sys.argv[1:]:
|
||||
server_address = sys.argv[1]
|
||||
else:
|
||||
server_address = "mytestxxx.i2p"
|
||||
|
||||
HandlerClass.protocol_version = protocol
|
||||
httpd = ServerClass(server_address, HandlerClass)
|
||||
|
||||
print "Serving HTTP on", server_address, "..."
|
||||
print "Destination follows:"
|
||||
print httpd.socket.dest
|
||||
httpd.serve_forever()
|
||||
|
||||
if __name__ == '__main__':
|
||||
test()
|
16
apps/sam/python/src/i2p/I2PCGIHTTPServer.py
Normal file
16
apps/sam/python/src/i2p/I2PCGIHTTPServer.py
Normal file
@ -0,0 +1,16 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
import CGIHTTPServer
|
||||
from CGIHTTPServer import nobody_uid, executable
|
||||
|
||||
import I2PBaseHTTPServer, I2PSimpleHTTPServer
|
||||
|
||||
class CGIHTTPRequestHandler(CGIHTTPServer.CGIHTTPRequestHandler):
|
||||
pass
|
||||
def test(HandlerClass = CGIHTTPRequestHandler,
|
||||
ServerClass = I2PBaseHTTPServer.HTTPServer):
|
||||
I2PSimpleHTTPServer.test(HandlerClass, ServerClass)
|
||||
|
||||
if __name__ == '__main__':
|
||||
test()
|
||||
|
19
apps/sam/python/src/i2p/I2PSimpleHTTPServer.py
Normal file
19
apps/sam/python/src/i2p/I2PSimpleHTTPServer.py
Normal file
@ -0,0 +1,19 @@
|
||||
#! /usr/bin/env python
|
||||
|
||||
import SimpleHTTPServer
|
||||
|
||||
import I2PBaseHTTPServer
|
||||
|
||||
__version__ = "0.1.0"
|
||||
|
||||
__all__ = ["SimpleHTTPRequestHandler"]
|
||||
|
||||
class SimpleHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||
pass
|
||||
|
||||
def test(HandlerClass = SimpleHTTPRequestHandler,
|
||||
ServerClass = I2PBaseHTTPServer.BaseHTTPServer):
|
||||
I2PBaseHTTPServer.test(HandlerClass, ServerClass)
|
||||
|
||||
if __name__ == '__main__':
|
||||
test()
|
47
apps/sam/python/src/i2p/I2PSocketServer.py
Normal file
47
apps/sam/python/src/i2p/I2PSocketServer.py
Normal file
@ -0,0 +1,47 @@
|
||||
import SocketServer
|
||||
|
||||
import i2p.sam
|
||||
class BaseServer(SocketServer.BaseServer):
|
||||
pass
|
||||
class TCPServer(SocketServer.TCPServer, BaseServer):
|
||||
|
||||
socket_type = i2p.sam.SOCK_STREAM
|
||||
|
||||
def __init__(self, server_address, RequestHandlerClass):
|
||||
"""Constructor. May be extended, do not override."""
|
||||
BaseServer.__init__(self, server_address, RequestHandlerClass)
|
||||
|
||||
#self.socket = socket.socket(self.address_family,
|
||||
# self.socket_type)
|
||||
self.server_address = server_address
|
||||
self.socket = i2p.sam.socket(server_address, self.socket_type)
|
||||
|
||||
self.server_bind()
|
||||
self.server_activate()
|
||||
class UDPServer(TCPServer, SocketServer.UDPServer):
|
||||
|
||||
pass
|
||||
class ForkingMixIn(SocketServer.ForkingMixIn):
|
||||
|
||||
pass
|
||||
class ThreadingMixIn(SocketServer.ThreadingMixIn):
|
||||
|
||||
pass
|
||||
class ForkingUDPServer(ForkingMixIn, UDPServer): pass
|
||||
|
||||
class ForkingTCPServer(ForkingMixIn, TCPServer): pass
|
||||
class ThreadingUDPServer(ThreadingMixIn, UDPServer): pass
|
||||
|
||||
class ThreadingTCPServer(ThreadingMixIn, TCPServer): pass
|
||||
|
||||
class BaseRequestHandler(SocketServer.BaseRequestHandler):
|
||||
pass
|
||||
|
||||
class StreamRequestHandler(SocketServer.StreamRequestHandler):
|
||||
|
||||
pass
|
||||
class DatagramRequestHandler(SocketServer.DatagramRequestHandler):
|
||||
|
||||
pass
|
||||
|
||||
|
Reference in New Issue
Block a user