You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
litle patch for import_logs.py to request from source address:
import functools
Formats.
class BoundHTTPHandler(urllib2.HTTPHandler):
def __init__(self, source_address=None, debuglevel=0):
urllib2.HTTPHandler.__init__(self, debuglevel)
self.http_class = functools.partial(httplib.HTTPConnection,
source_address=source_address)
def http_open(self, req):
return self.do_open(self.http_class, req)
(...other code....)
def _call(path, args, headers=None, url=None, data=None):
"""
Make a request to the Piwik site. It is up to the caller to format
arguments, to embed authentication, etc.
"""
if url is None:
url = config.options.piwik_url
headers = headers or {}
if data is None:
# If Content-Type isn't defined, PHP do not parse the request's body.
headers['Content-type'] = 'application/x-www-form-urlencoded'
data = urllib.urlencode(args)
elif not isinstance(data, basestring) and headers['Content-type'] == 'application/json':
data = json.dumps(data)
handler = BoundHTTPHandler(source_address=('127.0.0.1', 0))
opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)
headers['User-Agent'] = 'Piwik/LogImport'
request = urllib2.Request(url + path, data, headers)
response = urllib2.urlopen(request)
result = response.read()
response.close()
return result
The text was updated successfully, but these errors were encountered:
when applying nginx and restrict access by ip address it is sometimes necessary to specify the source address of the sender.
I hope I'm clearly outlined, sorry my english .. :)
litle patch for import_logs.py to request from source address:
import functools
Formats.
class BoundHTTPHandler(urllib2.HTTPHandler):
The text was updated successfully, but these errors were encountered: