diff options
author | Henrik Nordstrom <henrik@henriknordstrom.net> | 2010-11-17 12:03:42 +0100 |
---|---|---|
committer | Henrik Nordstrom <henrik@henriknordstrom.net> | 2011-02-10 02:59:51 +0100 |
commit | bd01126b2ba2e0aa39ef1619c92e1f29144f1cb6 (patch) | |
tree | 5f00aa9c1c7705497c0ebf15d28a62edea058c33 /libmproxy | |
parent | 2d8cfbafc32b4bcae288af1e0d9929c0b5427652 (diff) | |
download | mitmproxy-bd01126b2ba2e0aa39ef1619c92e1f29144f1cb6.tar.gz mitmproxy-bd01126b2ba2e0aa39ef1619c92e1f29144f1cb6.tar.bz2 mitmproxy-bd01126b2ba2e0aa39ef1619c92e1f29144f1cb6.zip |
Move try_del to utils
Diffstat (limited to 'libmproxy')
-rw-r--r-- | libmproxy/proxy.py | 23 | ||||
-rw-r--r-- | libmproxy/utils.py | 7 |
2 files changed, 15 insertions, 15 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index 44bc10e2..c08040e6 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -26,13 +26,6 @@ class Config: self.pemfile = pemfile -def try_del(dict, key): - try: - del dict[key] - except KeyError: - pass - - def parse_url(url): """ Returns a (scheme, host, port, path) tuple, or None on error. @@ -151,10 +144,10 @@ class Request(controller.Msg): modifications to make sure interception works properly. """ headers = self.headers.copy() - try_del(headers, 'accept-encoding') - try_del(headers, 'proxy-connection') - try_del(headers, 'keep-alive') - try_del(headers, 'connection') + utils.try_del(headers, 'accept-encoding') + utils.try_del(headers, 'proxy-connection') + utils.try_del(headers, 'keep-alive') + utils.try_del(headers, 'connection') headers["connection"] = ["close"] data = (self.method, self.path, str(headers), self.content) return self.FMT%data @@ -211,10 +204,10 @@ class Response(controller.Msg): modifications to make sure interception works properly. """ headers = self.headers.copy() - try_del(headers, 'accept-encoding') - try_del(headers, 'proxy-connection') - try_del(headers, 'connection') - try_del(headers, 'keep-alive') + utils.try_del(headers, 'accept-encoding') + utils.try_del(headers, 'proxy-connection') + utils.try_del(headers, 'connection') + utils.try_del(headers, 'keep-alive') headers["connection"] = ["close"] proto = "%s %s %s"%(self.proto, self.code, self.msg) data = (proto, str(headers), self.content) diff --git a/libmproxy/utils.py b/libmproxy/utils.py index e29910c5..22f98d12 100644 --- a/libmproxy/utils.py +++ b/libmproxy/utils.py @@ -138,6 +138,13 @@ def _caseless(s): return s.lower() +def try_del(dict, key): + try: + del dict[key] + except KeyError: + pass + + class MultiDict: """ Simple wrapper around a dictionary to make holding multiple objects per |