update
This commit is contained in:
@@ -2,9 +2,10 @@ import logging
|
||||
from abc import ABC, abstractmethod
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from client.ResponseHandler import ResponseHandler
|
||||
from client.httpclient import FORMAT, HTTPClient, InvalidResponse, InvalidStatusLine, UnsupportedEncoding
|
||||
|
||||
from client.response_handler import ResponseHandler
|
||||
from client.httpclient import FORMAT, HTTPClient
|
||||
from httplib import parser
|
||||
from httplib.exceptions import InvalidResponse, InvalidStatusLine, UnsupportedEncoding
|
||||
|
||||
class AbstractCommand(ABC):
|
||||
|
||||
@@ -34,7 +35,7 @@ class AbstractCommand(ABC):
|
||||
(host, path) = self.parse_uri()
|
||||
|
||||
client = HTTPClient(host)
|
||||
client.connect((host, int(self.port)))
|
||||
client.conn.connect((host, int(self.port)))
|
||||
|
||||
message = f"{self.command} {path} HTTP/1.1\r\n"
|
||||
message += f"Host: {host}\r\n"
|
||||
@@ -44,7 +45,7 @@ class AbstractCommand(ABC):
|
||||
logging.info("---request begin---\r\n%s---request end---", encoded_msg.decode(FORMAT))
|
||||
|
||||
logging.debug("Sending HTTP message: %r", encoded_msg)
|
||||
client.sendall(encoded_msg)
|
||||
client.conn.sendall(encoded_msg)
|
||||
|
||||
logging.info("HTTP request sent, awaiting response...")
|
||||
|
||||
@@ -118,9 +119,9 @@ class GetCommand(AbstractCommand):
|
||||
return "GET"
|
||||
|
||||
def _await_response(self, client):
|
||||
(version, status, msg) = ResponseHandler.get_status_line(client)
|
||||
(version, status, msg) = parser.get_status_line(client)
|
||||
logging.debug("Parsed status-line: version: %s, status: %s", version, status)
|
||||
headers = ResponseHandler.get_headers(client)
|
||||
headers = parser.get_headers(client)
|
||||
logging.debug("Parsed headers: %r", headers)
|
||||
|
||||
handler = ResponseHandler.create(client, headers, status, self.url)
|
||||
|
Reference in New Issue
Block a user