From 0e7a7fdd69589c99835782d8f502beba824e487d Mon Sep 17 00:00:00 2001
From: Noah Levitt <nlevitt@archive.org>
Date: Wed, 19 Aug 2015 22:56:05 +0000
Subject: [PATCH] remove unusued method; fix exception at shutdown time

---
 warcprox/mitmproxy.py | 3 ---
 warcprox/warcproxy.py | 4 +++-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/warcprox/mitmproxy.py b/warcprox/mitmproxy.py
index d60ecd1..154d30e 100644
--- a/warcprox/mitmproxy.py
+++ b/warcprox/mitmproxy.py
@@ -136,9 +136,6 @@ class MitmProxyHandler(http_server.BaseHTTPRequestHandler):
             self.logger.error("exception from {}".format(self._proxy_request), exc_info=True)
             raise
 
-    def _special_request(self, method, type_):
-        raise Exception('Not supported')
-
     def _proxy_request(self):
         raise Exception('_proxy_request() not implemented in MitmProxyHandler, must be implemented in subclass!')
 
diff --git a/warcprox/warcproxy.py b/warcprox/warcproxy.py
index 3212086..6839ddc 100644
--- a/warcprox/warcproxy.py
+++ b/warcprox/warcproxy.py
@@ -213,6 +213,7 @@ class WarcProxyHandler(warcprox.mitmproxy.MitmProxyHandler):
         if 'Content-Length' in self.headers:
             req += self.rfile.read(int(self.headers['Content-Length']))
 
+        prox_rec_res = None
         try:
             self.logger.debug('sending to remote server req=%s', repr(req))
 
@@ -256,7 +257,8 @@ class WarcProxyHandler(warcprox.mitmproxy.MitmProxyHandler):
             self.logger.error("%s proxying %s", repr(e), self.url, exc_info=True)
         finally:
             # Let's close off the remote end
-            prox_rec_res.close()
+            if prox_rec_res:
+                prox_rec_res.close()
             self._proxy_sock.close()
 
             # XXX Close connection to proxy client. Doing this because we were