From 906360f63f2afb4991dd2b38528798ad4efd0618 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 17 Sep 2015 15:16:33 +0200 Subject: code -> status_code, httpversion -> http_version --- libmproxy/console/common.py | 4 ++-- libmproxy/console/flowview.py | 6 +++--- libmproxy/filt.py | 2 +- libmproxy/models/http.py | 22 +++++++++++----------- libmproxy/protocol/http.py | 12 ++++++------ libmproxy/protocol/http_replay.py | 2 +- libmproxy/web/app.py | 8 ++++---- libmproxy/web/static/app.js | 8 ++++---- 8 files changed, 32 insertions(+), 32 deletions(-) (limited to 'libmproxy') diff --git a/libmproxy/console/common.py b/libmproxy/console/common.py index 13374b25..4a2310c9 100644 --- a/libmproxy/console/common.py +++ b/libmproxy/console/common.py @@ -393,7 +393,7 @@ def format_flow(f, focus, extended=False, hostheader=False, padding=2, req_url = f.request.pretty_url(hostheader=hostheader), err_msg = f.error.msg if f.error else None, - resp_code = f.response.code if f.response else None, + resp_code = f.response.status_code if f.response else None, marked = marked, ) @@ -410,7 +410,7 @@ def format_flow(f, focus, extended=False, hostheader=False, padding=2, roundtrip = utils.pretty_duration(duration) d.update(dict( - resp_code = f.response.code, + resp_code = f.response.status_code, resp_is_replay = f.response.is_replay, resp_clen = contentdesc, roundtrip = roundtrip, diff --git a/libmproxy/console/flowview.py b/libmproxy/console/flowview.py index 8220c1e7..a95f23a3 100644 --- a/libmproxy/console/flowview.py +++ b/libmproxy/console/flowview.py @@ -298,7 +298,7 @@ class FlowView(tabs.Tabs): def set_resp_code(self, code): response = self.flow.response try: - response.code = int(code) + response.status_code = int(code) except ValueError: return None import BaseHTTPServer @@ -357,7 +357,7 @@ class FlowView(tabs.Tabs): else: if not self.flow.response: self.flow.response = HTTPResponse( - self.flow.request.httpversion, + self.flow.request.http_version, 200, "OK", Headers(), "" ) self.flow.response.reply = controller.DummyReply() @@ -447,7 +447,7 @@ class FlowView(tabs.Tabs): elif part == "o": signals.status_prompt.send( prompt = "Code", - text = str(message.code), + text = str(message.status_code), callback = self.set_resp_code ) elif part == "m": diff --git a/libmproxy/filt.py b/libmproxy/filt.py index 7cd0f4df..acbf4ef9 100644 --- a/libmproxy/filt.py +++ b/libmproxy/filt.py @@ -270,7 +270,7 @@ class FCode(_Int): help = "HTTP response code" def __call__(self, f): - if f.response and f.response.code == self.num: + if f.response and f.response.status_code == self.num: return True diff --git a/libmproxy/models/http.py b/libmproxy/models/http.py index 0769d2d0..7e46c834 100644 --- a/libmproxy/models/http.py +++ b/libmproxy/models/http.py @@ -14,7 +14,7 @@ from .flow import Flow class MessageMixin(stateobject.StateObject): _stateobject_attributes = dict( - httpversion=bytes, + http_version=bytes, headers=Headers, body=bytes, timestamp_start=float, @@ -119,7 +119,7 @@ class HTTPRequest(MessageMixin, Request): path: Path portion of the URL (not present in authority-form) - httpversion: HTTP version, e.g. "HTTP/1.1" + http_version: HTTP version, e.g. "HTTP/1.1" headers: Headers object @@ -152,7 +152,7 @@ class HTTPRequest(MessageMixin, Request): host, port, path, - httpversion, + http_version, headers, body, timestamp_start=None, @@ -167,7 +167,7 @@ class HTTPRequest(MessageMixin, Request): host, port, path, - httpversion, + http_version, headers, body, timestamp_start, @@ -230,7 +230,7 @@ class HTTPRequest(MessageMixin, Request): host=request.host, port=request.port, path=request.path, - httpversion=request.httpversion, + http_version=request.http_version, headers=request.headers, body=request.body, timestamp_start=request.timestamp_start, @@ -266,7 +266,7 @@ class HTTPResponse(MessageMixin, Response): Exposes the following attributes: - httpversion: HTTP version, e.g. "HTTP/1.1" + http_version: HTTP version, e.g. "HTTP/1.1" status_code: HTTP response status code @@ -285,7 +285,7 @@ class HTTPResponse(MessageMixin, Response): def __init__( self, - httpversion, + http_version, status_code, msg, headers, @@ -295,7 +295,7 @@ class HTTPResponse(MessageMixin, Response): ): Response.__init__( self, - httpversion, + http_version, status_code, msg, headers, @@ -333,7 +333,7 @@ class HTTPResponse(MessageMixin, Response): @classmethod def wrap(self, response): resp = HTTPResponse( - httpversion=response.httpversion, + http_version=response.http_version, status_code=response.status_code, msg=response.msg, headers=response.headers, @@ -547,13 +547,13 @@ def make_connect_request(address): ) -def make_connect_response(httpversion): +def make_connect_response(http_version): headers = Headers( Content_Length="0", Proxy_Agent=version.NAMEVERSION ) return HTTPResponse( - httpversion, + http_version, 200, "Connection established", headers, diff --git a/libmproxy/protocol/http.py b/libmproxy/protocol/http.py index 53609f26..a1b2605f 100644 --- a/libmproxy/protocol/http.py +++ b/libmproxy/protocol/http.py @@ -102,16 +102,16 @@ class Http1Layer(_StreamingHttpLayer): def check_close_connection(self, flow): request_close = http1.connection_close( - flow.request.httpversion, + flow.request.http_version, flow.request.headers ) response_close = http1.connection_close( - flow.response.httpversion, + flow.response.http_version, flow.response.headers ) read_until_eof = http1.expected_http_body_size(flow.request, flow.response) == -1 close_connection = request_close or response_close or read_until_eof - if flow.request.form_in == "authority" and flow.response.code == 200: + if flow.request.form_in == "authority" and flow.response.status_code == 200: # Workaround for https://github.com/mitmproxy/mitmproxy/issues/313: # Charles Proxy sends a CONNECT response with HTTP/1.0 # and no Content-Length header @@ -258,7 +258,7 @@ class UpstreamConnectLayer(Layer): def _send_connect_request(self): self.send_request(self.connect_request) resp = self.read_response(self.connect_request) - if resp.code != 200: + if resp.status_code != 200: raise ProtocolException("Reconnect: Upstream server refuses CONNECT request") def connect(self): @@ -345,7 +345,7 @@ class HttpLayer(Layer): return # Upstream Proxy Mode: Handle CONNECT - if flow.request.form_in == "authority" and flow.response.code == 200: + if flow.request.form_in == "authority" and flow.response.status_code == 200: self.handle_upstream_mode_connect(flow.request.copy()) return @@ -377,7 +377,7 @@ class HttpLayer(Layer): def handle_regular_mode_connect(self, request): self.set_server((request.host, request.port)) - self.send_response(make_connect_response(request.httpversion)) + self.send_response(make_connect_response(request.http_version)) layer = self.ctx.next_layer(self) layer() diff --git a/libmproxy/protocol/http_replay.py b/libmproxy/protocol/http_replay.py index 9e2a9735..00b0b82b 100644 --- a/libmproxy/protocol/http_replay.py +++ b/libmproxy/protocol/http_replay.py @@ -56,7 +56,7 @@ class RequestReplayThread(threading.Thread): connect_request, body_size_limit=self.config.body_size_limit ) - if resp.code != 200: + if resp.status_code != 200: raise ReplayException("Upstream server refuses CONNECT request") server.establish_ssl( self.config.clientcerts, diff --git a/libmproxy/web/app.py b/libmproxy/web/app.py index 8eee6dce..5c80584d 100644 --- a/libmproxy/web/app.py +++ b/libmproxy/web/app.py @@ -128,7 +128,7 @@ class FlowHandler(RequestHandler): if a == "request": request = flow.request for k, v in b.iteritems(): - if k in ["method", "scheme", "host", "path", "httpversion"]: + if k in ["method", "scheme", "host", "path", "http_version"]: setattr(request, k, str(v)) elif k == "port": request.port = int(v) @@ -143,9 +143,9 @@ class FlowHandler(RequestHandler): if k == "msg": response.msg = str(v) elif k == "code": - response.code = int(v) - elif k == "httpversion": - response.httpversion = str(v) + response.status_code = int(v) + elif k == "http_version": + response.http_version = str(v) elif k == "headers": response.headers.load_state(v) else: diff --git a/libmproxy/web/static/app.js b/libmproxy/web/static/app.js index b9767153..edcc95ba 100644 --- a/libmproxy/web/static/app.js +++ b/libmproxy/web/static/app.js @@ -2098,7 +2098,7 @@ var RequestLine = React.createClass({displayName: "RequestLine", render: function () { var flow = this.props.flow; var url = flowutils.RequestUtils.pretty_url(flow.request); - var httpver = "HTTP/" + flow.request.httpversion.join("."); + var httpver = "HTTP/" + flow.request.http_version.join("."); return React.createElement("div", {className: "first-line request-line"}, React.createElement(ValueEditor, { @@ -2144,7 +2144,7 @@ var RequestLine = React.createClass({displayName: "RequestLine", var ver = flowutils.parseHttpVersion(nextVer); actions.FlowActions.update( this.props.flow, - {request: {httpversion: ver}} + {request: {http_version: ver}} ); } }); @@ -2152,7 +2152,7 @@ var RequestLine = React.createClass({displayName: "RequestLine", var ResponseLine = React.createClass({displayName: "ResponseLine", render: function () { var flow = this.props.flow; - var httpver = "HTTP/" + flow.response.httpversion.join("."); + var httpver = "HTTP/" + flow.response.http_version.join("."); return React.createElement("div", {className: "first-line response-line"}, React.createElement(ValueEditor, { ref: "httpVersion", @@ -5734,4 +5734,4 @@ module.exports = { },{"./actions.js":2,"jquery":"jquery","lodash":"lodash","react":"react"}]},{},[3]) -//# sourceMappingURL=app.js.map \ No newline at end of file +//# sourceMappingURL=app.js.map -- cgit v1.2.3