54
54
55
55
ssl ._create_default_https_context = ssl ._create_unverified_context
56
56
57
+ normpath = lambda p : os .path .normpath (os .path .join (os .path .dirname (os .path .realpath (__file__ )), p ))
58
+
57
59
# Global options dictonary, that will get modified after parsing
58
60
# program arguments. Below state represents default values.
59
61
options = {
66
68
'proxy_self_url' : 'http://proxy2.test/' ,
67
69
'timeout' : 5 ,
68
70
'no_ssl' : False ,
69
- 'cakey' : os . path . normpath (os . path . join ( os . getcwd (), 'ca-cert/ca.key' ) ),
70
- 'cacert' : os . path . normpath (os . path . join ( os . getcwd (), 'ca-cert/ca.crt' ) ),
71
- 'certkey' : os . path . normpath (os . path . join ( os . getcwd (), 'ca-cert/cert.key' ) ),
72
- 'certdir' : os . path . normpath (os . path . join ( os . getcwd (), 'certs/' ) ),
71
+ 'cakey' : normpath ('ca-cert/ca.key' ),
72
+ 'cacert' : normpath ('ca-cert/ca.crt' ),
73
+ 'certkey' : normpath ('ca-cert/cert.key' ),
74
+ 'certdir' : normpath ('certs/' ),
73
75
'cacn' : 'proxy2 CA' ,
74
76
'plugins' : set (),
75
77
'plugin_class_name' : 'ProxyPlugin' ,
@@ -313,7 +315,7 @@ class Response(object):
313
315
assert scheme in ('http' , 'https' )
314
316
#if netloc:
315
317
# req.headers['Host'] = netloc
316
- req_headers = self .filter_headers (req .headers )
318
+ req_headers = ProxyRequestHandler .filter_headers (req .headers )
317
319
318
320
if not origin in self .tls .conns :
319
321
logger .dbg ('Connecting with {}' .format (outbound_origin ))
@@ -359,7 +361,7 @@ class Response(object):
359
361
360
362
logger .info ('[RESPONSE] HTTP {} {}, length: {}' .format (res .status , res .reason , len (res_body )), color = ProxyLogger .colors_map ['yellow' ])
361
363
362
- res_headers = self .filter_headers (res .headers )
364
+ res_headers = ProxyRequestHandler .filter_headers (res .headers )
363
365
o = "%s %d %s\r \n " % (self .protocol_version , res .status , res .reason )
364
366
self .wfile .write (o .encode ())
365
367
for k , v in res_headers .items ():
@@ -385,7 +387,8 @@ class Response(object):
385
387
do_TRACE = do_GET
386
388
do_PATCH = do_GET
387
389
388
- def filter_headers (self , headers ):
390
+ @staticmethod
391
+ def filter_headers (headers ):
389
392
# http://tools.ietf.org/html/rfc2616#section-13.5.1
390
393
hop_by_hop = ('connection' , 'keep-alive' , 'proxy-authenticate' , 'proxy-authorization' , 'te' , 'trailers' , 'transfer-encoding' , 'upgrade' )
391
394
for k in hop_by_hop :
0 commit comments