fix read HEAD HTTP REQUESTS

master
serkus01 2 years ago
parent 2e0c03ae0a
commit abc9a0e5c5

@ -18,7 +18,7 @@ def main():
with open('./pkgs.json', 'tr') as fn:
data = fn.read()
pkg_list = json.loads(data)
print(pkg_list)
#print(pkg_list)
return json.dumps(pkg_list)
except Exception(e):
print(e)
@ -73,6 +73,18 @@ class Handler(BaseHTTPRequestHandler):
self.send_header['Access-Control-Allow-Headers', 'X-Requested-With,content-type']
# self.send_header['Access-Control-Allow-Credentials', true]
self.end_headers()
def response(self):
# return self.r_t to HTTP Rsponse
if self.r_t is not "":
# self._set_response()
# HTTP 2.0 response <<Bynary>> HTTP 1.* response <<Text>>
try:
return self.wfile.write(BytesIO(self.r_t).getvalue())
except TypeError:
#print("TypeError")
return self.wfile.write(bytes(self.r_t, 'UTF-8'))
else:
self.send_response(404)
def get_data(self):
length = int(self.headers['content-length'])
@ -85,11 +97,11 @@ class Handler(BaseHTTPRequestHandler):
def do_HEAD(self):
print("do_HEAD:\n")
print(str(self.path), str(self.headers))
# self.send_header(['Access-Control-Allow-Origin', '*'],
# self.send_header(['Access-Control-Allow-Methods', 'GET'],
# self.send_header(['Access-Control-Allow-Headers', 'X-Requested-With,content-type'])
# self.send_header(['Access-Control-Allow-Credentials', true])
# self.end_headers()
#elf.send_header(['Access-Control-Allow-Origin', '*'],
#self.send_header(['Access-Control-Allow-Methods', 'GET'],
#self.send_header(['Access-Control-Allow-Headers', 'X-Requested-With,content-type'])
#self.send_header(['Access-Control-Allow-Credentials', true])
self.end_headers()
def do_REQUEST(self):
print("do_REQUEST:\n")
@ -104,7 +116,7 @@ class Handler(BaseHTTPRequestHandler):
# print(Router.parse_url(self))
# print("data:\t" + self.rfile.read())
# request = Router.parse_url(self)
self.send_response(200)
#self.send_response(200)
self.p_list = []
self.r_t = ""
# length = int(self.headers['content-length'])
@ -189,15 +201,4 @@ class Handler(BaseHTTPRequestHandler):
# Send the html message
# self.wfile.write(bytes(self.r_t, "utf-8"))
def response(self):
# return self.r_t to HTTP Rsponse
if self.r_t not "":
self._set_response()
# HTTP 2.0 response <<Bynary>> HTTP 1.* response <<Text>>
try:
return self.wfile.write(BytesIO(self.r_t).getvalue())
except TypeError:
#print("TypeError")
return self.wfile.write(bytes(self.r_t, 'UTF-8'))
else:
self.send_response(404)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save