Commit f1351dcb authored by Łukasz Nowak's avatar Łukasz Nowak

caddy-frontend: Allow to have simple backend

Just running test.py with ip and port allows to expose the internal testing
backend. IPv4 and IPv6 are supported.
parent cc4d556b
No related merge requests found
...@@ -48,6 +48,7 @@ from slapos.recipe.librecipe import generateHashFromFiles ...@@ -48,6 +48,7 @@ from slapos.recipe.librecipe import generateHashFromFiles
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
import urlparse import urlparse
import socket import socket
import sys
try: try:
...@@ -430,6 +431,9 @@ def fakeHTTPResult(domain, real_ip, path, port=HTTP_PORT, ...@@ -430,6 +431,9 @@ def fakeHTTPResult(domain, real_ip, path, port=HTTP_PORT,
class TestHandler(BaseHTTPRequestHandler): class TestHandler(BaseHTTPRequestHandler):
identification = None identification = None
def do_POST(self):
return self.do_GET()
def do_GET(self): def do_GET(self):
timeout = int(self.headers.dict.get('timeout', '0')) timeout = int(self.headers.dict.get('timeout', '0'))
compress = int(self.headers.dict.get('compress', '0')) compress = int(self.headers.dict.get('compress', '0'))
...@@ -7080,3 +7084,19 @@ class TestPassedRequestParameter(HttpFrontendTestCase): ...@@ -7080,3 +7084,19 @@ class TestPassedRequestParameter(HttpFrontendTestCase):
expected_partition_parameter_dict_dict, expected_partition_parameter_dict_dict,
partition_parameter_dict_dict partition_parameter_dict_dict
) )
if __name__ == '__main__':
class HTTP6Server(HTTPServer):
address_family = socket.AF_INET6
ip, port = sys.argv[1], int(sys.argv[2])
if ':' in ip:
klass = HTTP6Server
url_template = 'http://[%s]:%s/'
else:
klass = HTTPServer
url_template = 'http://%s:%s/'
server = klass((ip, port), TestHandler)
print url_template % server.server_address[:2]
server.serve_forever()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment