aboutsummaryrefslogtreecommitdiffstats
path: root/libmproxy
diff options
context:
space:
mode:
authorAldo Cortesi <aldo@nullcube.com>2013-01-05 19:44:12 -0800
committerAldo Cortesi <aldo@nullcube.com>2013-01-05 19:44:12 -0800
commitd0ee4d60d09c607a208ae1b190e619a4f106538e (patch)
treed61b69df2c120f1100e9639072f3b1d8d2231558 /libmproxy
parent060e3198bca48f327984b2d1d73a5d4592866736 (diff)
downloadmitmproxy-d0ee4d60d09c607a208ae1b190e619a4f106538e.tar.gz
mitmproxy-d0ee4d60d09c607a208ae1b190e619a4f106538e.tar.bz2
mitmproxy-d0ee4d60d09c607a208ae1b190e619a4f106538e.zip
Unit tests and minor code refactoring for ServerConnection.
Diffstat (limited to 'libmproxy')
-rw-r--r--libmproxy/proxy.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py
index 370eca9a..2485a0c9 100644
--- a/libmproxy/proxy.py
+++ b/libmproxy/proxy.py
@@ -48,9 +48,9 @@ class ProxyConfig:
self.reverse_proxy = reverse_proxy
self.transparent_proxy = transparent_proxy
self.authenticator = authenticator
-
self.certstore = certutils.CertStore(certdir)
+
class RequestReplayThread(threading.Thread):
def __init__(self, config, flow, masterq):
self.config, self.flow, self.masterq = config, flow, masterq
@@ -86,7 +86,7 @@ class ServerConnection(tcp.TCPClient):
clientcert = None
if self.config.clientcerts:
path = os.path.join(self.config.clientcerts, self.host) + ".pem"
- if os.path.exists(clientcert):
+ if os.path.exists(path):
clientcert = path
try:
self.convert_to_ssl(clientcert=clientcert, sni=self.host)
@@ -95,10 +95,10 @@ class ServerConnection(tcp.TCPClient):
def send(self, request):
self.requestcount += 1
+ d = request._assemble()
+ if not d:
+ raise ProxyError(502, "Cannot transmit an incomplete request.")
try:
- d = request._assemble()
- if not d:
- raise ProxyError(502, "Incomplete request could not not be readied for transmission.")
self.wfile.write(d)
self.wfile.flush()
except socket.error, err:
@@ -373,7 +373,7 @@ class ProxyHandler(tcp.BaseHandler):
def send_response(self, response):
d = response._assemble()
if not d:
- raise ProxyError(502, "Incomplete response could not not be readied for transmission.")
+ raise ProxyError(502, "Cannot transmit an incomplete response.")
self.wfile.write(d)
self.wfile.flush()