From 755f0e07a19da7212d5e93a62ac4f11d5443ff80 Mon Sep 17 00:00:00 2001 From: Abhinav Singh Date: Tue, 24 Dec 2013 03:21:45 +0530 Subject: [PATCH] variablize reply pkt, ignore, Makefile --- .gitignore | 3 ++- Makefile | 17 +++++++++++++++++ proxy.py | 12 +++++++----- 3 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 0a1c1ace..7a42f483 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ .project .pydevproject .settings - +.coverage *.pyc +cover dist proxy.py.egg-info diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..201a7593 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +.PHONY: all clean package test + +all: clean test + +clean: + find . -name '*.pyc' -exec rm -f {} + + find . -name '*.pyo' -exec rm -f {} + + find . -name '*~' -exec rm -f {} + + +test: + nosetests -v --with-coverage --cover-package=proxy --cover-erase --cover-html --nocapture + +package: + python setup.py sdist + +release: + python setup.py sdist register upload diff --git a/proxy.py b/proxy.py index a40d3e81..52af804b 100644 --- a/proxy.py +++ b/proxy.py @@ -299,6 +299,12 @@ class Proxy(multiprocessing.Process): self.request = HttpParser() self.response = HttpParser(HTTP_RESPONSE_PARSER) + + self.connection_established_pkt = CRLF.join([ + 'HTTP/1.1 200 Connection established', + 'Proxy-agent: proxy.py v%s' % __version__, + CRLF + ]) def _now(self): return datetime.datetime.utcnow() @@ -344,11 +350,7 @@ class Proxy(multiprocessing.Process): # queue appropriate response for client # notifying about established connection if self.request.method == "CONNECT": - self.client.queue(CRLF.join([ - 'HTTP/1.1 200 Connection established', - 'Proxy-agent: proxy.py v%s' % __version__, - CRLF - ])) + self.client.queue(self.connection_established_pkt) # for usual http requests, re-build request packet # and queue for the server with appropriate headers else: