diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2015-07-15 22:04:25 +0200 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2015-07-22 15:30:33 +0200 |
commit | 2b0465dbb93dd4bf0d6db366db597c05e92121d8 (patch) | |
tree | 5bbb540800a154e840334b2c2141581ecb03de26 /libpathod | |
parent | a2bf19125a92a4fa372708cf2cda7887ab62ac76 (diff) | |
download | mitmproxy-2b0465dbb93dd4bf0d6db366db597c05e92121d8.tar.gz mitmproxy-2b0465dbb93dd4bf0d6db366db597c05e92121d8.tar.bz2 mitmproxy-2b0465dbb93dd4bf0d6db366db597c05e92121d8.zip |
use new netlib module names
Diffstat (limited to 'libpathod')
-rw-r--r-- | libpathod/app.py | 4 | ||||
-rw-r--r-- | libpathod/language/http.py | 8 | ||||
-rw-r--r-- | libpathod/language/http2.py | 6 | ||||
-rw-r--r-- | libpathod/pathoc.py | 11 | ||||
-rw-r--r-- | libpathod/pathoc_cmdline.py | 5 | ||||
-rw-r--r-- | libpathod/pathod.py | 3 | ||||
-rw-r--r-- | libpathod/protocols/http.py | 17 | ||||
-rw-r--r-- | libpathod/protocols/http2.py | 2 | ||||
-rw-r--r-- | libpathod/protocols/websockets.py | 2 |
9 files changed, 31 insertions, 27 deletions
diff --git a/libpathod/app.py b/libpathod/app.py index 4a8d2b63..debebaf2 100644 --- a/libpathod/app.py +++ b/libpathod/app.py @@ -4,7 +4,7 @@ import cStringIO import copy from flask import Flask, jsonify, render_template, request, abort, make_response from . import version, language, utils -from netlib import http_uastrings +from netlib.http import user_agents logging.basicConfig(level="DEBUG") EXAMPLE_HOST = "example.com" @@ -76,7 +76,7 @@ def make_app(noapi, debug): def docs_language(): return render( "docs_lang.html", True, - section="docs", uastrings=http_uastrings.UASTRINGS, + section="docs", uastrings=user_agents.UASTRINGS, subsection="lang" ) diff --git a/libpathod/language/http.py b/libpathod/language/http.py index 0c4d9419..380a5d64 100644 --- a/libpathod/language/http.py +++ b/libpathod/language/http.py @@ -4,7 +4,7 @@ import abc import pyparsing as pp import netlib.websockets -from netlib import http_status, http_uastrings +from netlib.http import status_codes, user_agents from . import base, exceptions, actions, message @@ -78,13 +78,13 @@ class ShortcutLocation(_HeaderMixin, base.Value): class ShortcutUserAgent(_HeaderMixin, base.OptionsOrValue): preamble = "u" - options = [i[1] for i in http_uastrings.UASTRINGS] + options = [i[1] for i in user_agents.UASTRINGS] key = base.TokValueLiteral("User-Agent") def values(self, settings): value = self.value.val if self.option_used: - value = http_uastrings.get_by_shortcut(value.lower())[2] + value = user_agents.get_by_shortcut(value.lower())[2] return self.format_header( self.key.get_generator(settings), @@ -175,7 +175,7 @@ class Response(_HTTPMessage): l.extend(self.reason.values(settings)) else: l.append( - http_status.RESPONSES.get( + status_codes.RESPONSES.get( code, "Unknown code" ) diff --git a/libpathod/language/http2.py b/libpathod/language/http2.py index 6dd93d5f..8aee9931 100644 --- a/libpathod/language/http2.py +++ b/libpathod/language/http2.py @@ -1,6 +1,6 @@ import pyparsing as pp -from netlib import http_status, http_uastrings +from netlib.http import user_agents from . import base, message """ @@ -116,13 +116,13 @@ class ShortcutLocation(_HeaderMixin, base.Value): class ShortcutUserAgent(_HeaderMixin, base.OptionsOrValue): preamble = "u" - options = [i[1] for i in http_uastrings.UASTRINGS] + options = [i[1] for i in user_agents.UASTRINGS] key = base.TokValueLiteral("user-agent") def values(self, settings): value = self.value.val if self.option_used: - value = http_uastrings.get_by_shortcut(value.lower())[2] + value = user_agents.get_by_shortcut(value.lower())[2] return ( self.key.get_generator(settings), diff --git a/libpathod/pathoc.py b/libpathod/pathoc.py index 7f7cbb87..89b0e0c9 100644 --- a/libpathod/pathoc.py +++ b/libpathod/pathoc.py @@ -11,7 +11,8 @@ import threading import OpenSSL.crypto -from netlib import tcp, http, http2, http_semantics, certutils, websockets, socks +from netlib import tcp, http, certutils, websockets, socks +from netlib.http import http1, http2 import language.http import language.websockets @@ -228,12 +229,12 @@ class Pathoc(tcp.TCPClient): l = self.rfile.readline() if not l: raise PathocError("Proxy CONNECT failed") - parsed = http.parse_response_line(l) + parsed = http.http1.parse_response_line(l) if not parsed[1] == 200: raise PathocError( "Proxy CONNECT failed: %s - %s" % (parsed[1], parsed[2]) ) - http.read_headers(self.rfile) + http.http1.read_headers(self.rfile) def socks_connect(self, connect_to): try: @@ -410,9 +411,9 @@ class Pathoc(tcp.TCPClient): if self.use_http2: status_code, headers, body = self.protocol.read_response() - resp = http_semantics.Response("HTTP/2", status_code, "", headers, body, self.sslinfo) + resp = http.Response("HTTP/2", status_code, "", headers, body, self.sslinfo) else: - resp = http.read_response( + resp = http.http1.read_response( self.rfile, req["method"], None diff --git a/libpathod/pathoc_cmdline.py b/libpathod/pathoc_cmdline.py index 8b25b4a1..58963265 100644 --- a/libpathod/pathoc_cmdline.py +++ b/libpathod/pathoc_cmdline.py @@ -3,7 +3,8 @@ import argparse import os import os.path -from netlib import http_uastrings, tcp +from netlib import tcp +from netlib.http import user_agents from . import pathoc, version, language @@ -16,7 +17,7 @@ def args_pathoc(argv, stdout=sys.stdout, stderr=sys.stderr): pa = preparser.parse_known_args(argv)[0] if pa.showua: print >> stdout, "User agent strings:" - for i in http_uastrings.UASTRINGS: + for i in user_agents.UASTRINGS: print >> stdout, " ", i[1], i[0] sys.exit(0) diff --git a/libpathod/pathod.py b/libpathod/pathod.py index 31d821c2..cfedc934 100644 --- a/libpathod/pathod.py +++ b/libpathod/pathod.py @@ -6,7 +6,8 @@ import threading import urllib import time -from netlib import tcp, http, http2, wsgi, certutils, websockets, odict +from netlib import tcp, http, wsgi, certutils, websockets, odict +from netlib.http import http1, http2 from . import version, app, language, utils, log, protocols import language.http diff --git a/libpathod/protocols/http.py b/libpathod/protocols/http.py index bccdc786..363af0fe 100644 --- a/libpathod/protocols/http.py +++ b/libpathod/protocols/http.py @@ -1,4 +1,5 @@ -from netlib import tcp, http, http2, wsgi, certutils, websockets, odict +from netlib import tcp, http, wsgi +from netlib.http import http1 from .. import version, app, language, utils, log class HTTPProtocol: @@ -37,7 +38,7 @@ class HTTPProtocol: """ Handle a CONNECT request. """ - http.read_headers(self.pathod_handler.rfile) + http1.read_headers(self.pathod_handler.rfile) self.pathod_handler.wfile.write( 'HTTP/1.1 200 Connection established\r\n' + ('Proxy-agent: %s\r\n' % version.NAMEVERSION) + @@ -65,31 +66,31 @@ class HTTPProtocol: return self.pathod_handler.handle_http_request, None def read_request(self, lg): - line = http.get_request_line(self.pathod_handler.rfile) + line = http1.get_request_line(self.pathod_handler.rfile) if not line: # Normal termination return dict() m = utils.MemBool() - if m(http.parse_init_connect(line)): + if m(http1.parse_init_connect(line)): return dict(next_handle=self.handle_http_connect(m.v, lg)) - elif m(http.parse_init_proxy(line)): + elif m(http1.parse_init_proxy(line)): method, _, _, _, path, httpversion = m.v - elif m(http.parse_init_http(line)): + elif m(http1.parse_init_http(line)): method, path, httpversion = m.v else: s = "Invalid first line: %s" % repr(line) lg(s) return dict(errors=dict(type="error", msg=s)) - headers = http.read_headers(self.pathod_handler.rfile) + headers = http1.read_headers(self.pathod_handler.rfile) if headers is None: s = "Invalid headers" lg(s) return dict(errors=dict(type="error", msg=s)) try: - body = http.read_http_body( + body = http1.read_http_body( self.pathod_handler.rfile, headers, None, diff --git a/libpathod/protocols/http2.py b/libpathod/protocols/http2.py index 29c4e556..d2c269ed 100644 --- a/libpathod/protocols/http2.py +++ b/libpathod/protocols/http2.py @@ -1,4 +1,4 @@ -from netlib import tcp, http, http2, wsgi, certutils, websockets, odict +from netlib.http import http2 from .. import version, app, language, utils, log class HTTP2Protocol: diff --git a/libpathod/protocols/websockets.py b/libpathod/protocols/websockets.py index 334f9e9c..890f06c8 100644 --- a/libpathod/protocols/websockets.py +++ b/libpathod/protocols/websockets.py @@ -1,6 +1,6 @@ import time -from netlib import tcp, http, http2, wsgi, certutils, websockets, odict +from netlib import tcp, http, wsgi, certutils, websockets, odict from .. import version, app, language, utils, log class WebsocketsProtocol: |