fix: clean up type annotations and unused imports
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -9,9 +9,9 @@ logger = logging.getLogger("jianda_proxy")
|
|||||||
class ProxyHandler(http.server.BaseHTTPRequestHandler):
|
class ProxyHandler(http.server.BaseHTTPRequestHandler):
|
||||||
protocol_version = "HTTP/1.1"
|
protocol_version = "HTTP/1.1"
|
||||||
|
|
||||||
REMOTE_DOMAIN = ""
|
REMOTE_DOMAIN: str = ""
|
||||||
UPSTREAM_IP = ""
|
UPSTREAM_IP: str = ""
|
||||||
UPSTREAM_PORT = 0
|
UPSTREAM_PORT: int = 0
|
||||||
|
|
||||||
def _proxy_request(self, target_host, target_port, target_path, body=None):
|
def _proxy_request(self, target_host, target_port, target_path, body=None):
|
||||||
body_len = int(self.headers.get("Content-Length", 0))
|
body_len = int(self.headers.get("Content-Length", 0))
|
||||||
@@ -39,12 +39,12 @@ class ProxyHandler(http.server.BaseHTTPRequestHandler):
|
|||||||
if kl in ("transfer-encoding", "connection"):
|
if kl in ("transfer-encoding", "connection"):
|
||||||
continue
|
continue
|
||||||
if kl == "content-length":
|
if kl == "content-length":
|
||||||
self.send_header(k, len(resp_body))
|
self.send_header(k, str(len(resp_body)))
|
||||||
sent_cl = True
|
sent_cl = True
|
||||||
continue
|
continue
|
||||||
self.send_header(k, v)
|
self.send_header(k, v)
|
||||||
if not sent_cl:
|
if not sent_cl:
|
||||||
self.send_header("Content-Length", len(resp_body))
|
self.send_header("Content-Length", str(len(resp_body)))
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(resp_body)
|
self.wfile.write(resp_body)
|
||||||
finally:
|
finally:
|
||||||
@@ -73,8 +73,8 @@ class ProxyHandler(http.server.BaseHTTPRequestHandler):
|
|||||||
|
|
||||||
do_GET = do_POST = do_PUT = do_DELETE = do_HEAD = do_PATCH = _do
|
do_GET = do_POST = do_PUT = do_DELETE = do_HEAD = do_PATCH = _do
|
||||||
|
|
||||||
def log_message(self, fmt, *args):
|
def log_message(self, format, *args):
|
||||||
logger.info("%s - %s", self.address_string(), fmt % args)
|
logger.info("%s - %s", self.address_string(), format % args)
|
||||||
|
|
||||||
|
|
||||||
def create_server(config):
|
def create_server(config):
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import os
|
|
||||||
import tempfile
|
|
||||||
import pytest
|
import pytest
|
||||||
from unittest.mock import patch, MagicMock
|
from unittest.mock import patch
|
||||||
from jianda_proxy.daemon import (
|
from jianda_proxy.daemon import (
|
||||||
read_pid,
|
read_pid,
|
||||||
write_pid,
|
write_pid,
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
import threading
|
|
||||||
import http.client
|
|
||||||
import time
|
|
||||||
import pytest
|
import pytest
|
||||||
from unittest.mock import MagicMock, patch
|
|
||||||
from jianda_proxy.proxy import create_server
|
from jianda_proxy.proxy import create_server
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user