#!/usr/bin/env python3 import json import urllib.error import urllib.request BASE = "https://game.xworld.ren" CASES = [ ("POST /login empty json", "POST", "/login", {"Content-Type": "application/json"}, b"{}"), ("POST /login guest", "POST", "/login", {"Content-Type": "application/json"}, json.dumps({"mode": "guest", "pid": "m2"}).encode()), ("POST /login device", "POST", "/login", {"Content-Type": "application/json"}, json.dumps({"deviceId": "m2_probe", "platform": "editor"}).encode()), ("POST /login user", "POST", "/login", {"Content-Type": "application/json"}, json.dumps({"username": "test", "password": "test"}).encode()), ("POST /api/v1/login", "POST", "/api/v1/login", {"Content-Type": "application/json"}, json.dumps({"deviceId": "m2"}).encode()), ("POST /auth/login", "POST", "/auth/login", {"Content-Type": "application/json"}, json.dumps({"deviceId": "m2"}).encode()), ("POST /ws/token", "POST", "/ws/token", {"Content-Type": "application/json"}, json.dumps({"pid": "m2"}).encode()), ("GET /login", "GET", "/login", {}, None), ("OPTIONS /login", "OPTIONS", "/login", {"Origin": "https://www.xworld.ren"}, None), ] def hit(method, path, headers, body): req = urllib.request.Request(BASE + path, data=body, method=method) for k, v in headers.items(): req.add_header(k, v) try: with urllib.request.urlopen(req, timeout=10) as resp: data = resp.read() print(f"OK {method} {path} {resp.status} {data[:500]!r}") except urllib.error.HTTPError as e: body = e.read() print(f"HTTP {e.code} {method} {path} headers={dict(e.headers)} body={body[:500]!r}") except Exception as e: print(f"ERR {method} {path}: {type(e).__name__} {e}") def main(): for name, method, path, headers, body in CASES: print("---", name) hit(method, path, headers, body) if __name__ == "__main__": main()