/usr/share/pyshared/wsgi_intercept/httplib2_intercept.py is in python-wsgi-intercept 0.4-0ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | """intercept HTTP connections that use httplib2
(see wsgi_intercept/__init__.py for examples)
"""
import httplib2
import wsgi_intercept
from httplib2 import HTTPConnectionWithTimeout, HTTPSConnectionWithTimeout
import sys
InterceptorMixin = wsgi_intercept.WSGI_HTTPConnection
# might make more sense as a decorator
def connect(self):
"""
Override the connect() function to intercept calls to certain
host/ports.
"""
if wsgi_intercept.debuglevel:
sys.stderr.write('connect: %s, %s\n' % (self.host, self.port,))
(app, script_name) = self.get_app(self.host, self.port)
if app:
if wsgi_intercept.debuglevel:
sys.stderr.write('INTERCEPTING call to %s:%s\n' % \
(self.host, self.port,))
self.sock = wsgi_intercept.wsgi_fake_socket(app,
self.host, self.port,
script_name)
else:
self._connect()
class HTTP_WSGIInterceptorWithTimeout(HTTPConnectionWithTimeout, InterceptorMixin):
_connect = httplib2.HTTPConnectionWithTimeout.connect
connect = connect
class HTTPS_WSGIInterceptorWithTimeout(HTTPSConnectionWithTimeout, InterceptorMixin):
_connect = httplib2.HTTPSConnectionWithTimeout.connect
connect = connect
def install():
httplib2.HTTPConnectionWithTimeout = HTTP_WSGIInterceptorWithTimeout
httplib2.HTTPSConnectionWithTimeout = HTTPS_WSGIInterceptorWithTimeout
def uninstall():
httplib2.HTTPConnectionWithTimeout = HTTPConnectionWithTimeout
httplib2.HTTPSConnectionWithTimeout = HTTPSConnectionWithTimeout
|