use netlib.http_semantics for generic data
This commit is contained in:
parent
9a1bee31d6
commit
78ae3e4a00
|
@ -11,7 +11,7 @@ import threading
|
|||
|
||||
import OpenSSL.crypto
|
||||
|
||||
from netlib import tcp, http, http2, certutils, websockets, socks
|
||||
from netlib import tcp, http, http2, http_semantics, certutils, websockets, socks
|
||||
|
||||
import language.http
|
||||
import language.websockets
|
||||
|
@ -66,25 +66,6 @@ class SSLInfo(object):
|
|||
return "\n".join(parts)
|
||||
|
||||
|
||||
class Response(object):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
httpversion,
|
||||
status_code,
|
||||
msg,
|
||||
headers,
|
||||
content,
|
||||
sslinfo
|
||||
):
|
||||
self.httpversion, self.status_code = httpversion, status_code
|
||||
self.msg = msg
|
||||
self.headers, self.content = headers, content
|
||||
self.sslinfo = sslinfo
|
||||
|
||||
def __repr__(self):
|
||||
return "Response(%s - %s)" % (self.status_code, self.msg)
|
||||
|
||||
|
||||
class WebsocketFrameReader(threading.Thread):
|
||||
|
||||
|
@ -429,17 +410,14 @@ class Pathoc(tcp.TCPClient):
|
|||
|
||||
if self.use_http2:
|
||||
status_code, headers, body = self.protocol.read_response()
|
||||
resp = Response("HTTP/2", status_code, "", headers, body, self.sslinfo)
|
||||
resp = http_semantics.Response("HTTP/2", status_code, "", headers, body, self.sslinfo)
|
||||
else:
|
||||
resp = list(
|
||||
http.read_response(
|
||||
resp = http.read_response(
|
||||
self.rfile,
|
||||
req["method"],
|
||||
None
|
||||
)
|
||||
)
|
||||
resp.append(self.sslinfo)
|
||||
resp = Response(*resp)
|
||||
resp.sslinfo = self.sslinfo
|
||||
except http.HttpError as v:
|
||||
lg("Invalid server response: %s" % v)
|
||||
raise
|
||||
|
|
|
@ -4,13 +4,13 @@ import re
|
|||
import OpenSSL
|
||||
from mock import Mock
|
||||
|
||||
from netlib import tcp, http, http2, socks
|
||||
from netlib import tcp, http, http2, http_semantics, socks
|
||||
from libpathod import pathoc, test, version, pathod, language
|
||||
import tutils
|
||||
|
||||
|
||||
def test_response():
|
||||
r = pathoc.Response("1.1", 200, "Message", {}, None, None)
|
||||
r = http_semantics.Response("1.1", 200, "Message", {}, None, None)
|
||||
assert repr(r)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue