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
|
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.http
|
||||||
import language.websockets
|
import language.websockets
|
||||||
|
@ -66,25 +66,6 @@ class SSLInfo(object):
|
||||||
return "\n".join(parts)
|
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):
|
class WebsocketFrameReader(threading.Thread):
|
||||||
|
|
||||||
|
@ -429,17 +410,14 @@ class Pathoc(tcp.TCPClient):
|
||||||
|
|
||||||
if self.use_http2:
|
if self.use_http2:
|
||||||
status_code, headers, body = self.protocol.read_response()
|
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:
|
else:
|
||||||
resp = list(
|
resp = http.read_response(
|
||||||
http.read_response(
|
|
||||||
self.rfile,
|
self.rfile,
|
||||||
req["method"],
|
req["method"],
|
||||||
None
|
None
|
||||||
)
|
)
|
||||||
)
|
resp.sslinfo = self.sslinfo
|
||||||
resp.append(self.sslinfo)
|
|
||||||
resp = Response(*resp)
|
|
||||||
except http.HttpError as v:
|
except http.HttpError as v:
|
||||||
lg("Invalid server response: %s" % v)
|
lg("Invalid server response: %s" % v)
|
||||||
raise
|
raise
|
||||||
|
|
|
@ -4,13 +4,13 @@ import re
|
||||||
import OpenSSL
|
import OpenSSL
|
||||||
from mock import Mock
|
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
|
from libpathod import pathoc, test, version, pathod, language
|
||||||
import tutils
|
import tutils
|
||||||
|
|
||||||
|
|
||||||
def test_response():
|
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)
|
assert repr(r)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue