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):
|
||||
protocol_version = "HTTP/1.1"
|
||||
|
||||
REMOTE_DOMAIN = ""
|
||||
UPSTREAM_IP = ""
|
||||
UPSTREAM_PORT = 0
|
||||
REMOTE_DOMAIN: str = ""
|
||||
UPSTREAM_IP: str = ""
|
||||
UPSTREAM_PORT: int = 0
|
||||
|
||||
def _proxy_request(self, target_host, target_port, target_path, body=None):
|
||||
body_len = int(self.headers.get("Content-Length", 0))
|
||||
@@ -39,12 +39,12 @@ class ProxyHandler(http.server.BaseHTTPRequestHandler):
|
||||
if kl in ("transfer-encoding", "connection"):
|
||||
continue
|
||||
if kl == "content-length":
|
||||
self.send_header(k, len(resp_body))
|
||||
self.send_header(k, str(len(resp_body)))
|
||||
sent_cl = True
|
||||
continue
|
||||
self.send_header(k, v)
|
||||
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.wfile.write(resp_body)
|
||||
finally:
|
||||
@@ -73,8 +73,8 @@ class ProxyHandler(http.server.BaseHTTPRequestHandler):
|
||||
|
||||
do_GET = do_POST = do_PUT = do_DELETE = do_HEAD = do_PATCH = _do
|
||||
|
||||
def log_message(self, fmt, *args):
|
||||
logger.info("%s - %s", self.address_string(), fmt % args)
|
||||
def log_message(self, format, *args):
|
||||
logger.info("%s - %s", self.address_string(), format % args)
|
||||
|
||||
|
||||
def create_server(config):
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import os
|
||||
import tempfile
|
||||
import pytest
|
||||
from unittest.mock import patch, MagicMock
|
||||
from unittest.mock import patch
|
||||
from jianda_proxy.daemon import (
|
||||
read_pid,
|
||||
write_pid,
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import threading
|
||||
import http.client
|
||||
import time
|
||||
import pytest
|
||||
from unittest.mock import MagicMock, patch
|
||||
from jianda_proxy.proxy import create_server
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user