Skip to content

Instantly share code, notes, and snippets.

@knot126
Created June 2, 2023 05:56
Show Gist options
  • Save knot126/190ce3c343ad2f05d7829e2265adb2d1 to your computer and use it in GitHub Desktop.
Save knot126/190ce3c343ad2f05d7829e2265adb2d1 to your computer and use it in GitHub Desktop.
Awful hack for making Karen's cydia repo work on iOS 5 after SSL errors
"""
Run this locally (make sure firewall is off) and add http://<YOUR-IP>:8000/ to Cydia.
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import time
import requests
host = "https://cydia.akemi.ai"
serverPort = 8000
class MyServer(BaseHTTPRequestHandler):
def do_GET(self):
url = f"{host}{self.path}"
print(f"Actually fetching URL: {url}")
response = requests.get(url)
self.send_response(response.status_code)
for header in response.headers:
if (header != "alt-svc" and header != "Connection" and header != "Transfer-Encoding" and header != "Content-Encoding" and header != "Content-Length"):
self.send_header(header, response.headers[header])
self.send_header("Content-Length", len(response.content))
self.end_headers()
self.wfile.write(response.content)
# print(f"{response.text}\n\n{response.encoding}\n\n{response.headers}")
def do_HEAD(self):
url = f"{host}{self.path}"
print(f"Actually fetching URL: {url}")
response = requests.get(url)
self.send_response(response.status_code)
for header in response.headers:
if (header != "alt-svc" and header != "Connection" and header != "Transfer-Encoding" and header != "Content-Encoding" and header != "Content-Length"):
self.send_header(header, response.headers[header])
self.send_header("Content-Length", len(response.content))
self.end_headers()
if __name__ == "__main__":
webServer = HTTPServer(("0.0.0.0", serverPort), MyServer)
try:
webServer.serve_forever()
except KeyboardInterrupt:
pass
webServer.server_close()
print("Server stopped.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment