2013-11-13 13:20:58 +00:00
|
|
|
# -*- encoding: utf-8 -*-
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
|
class FakeIP(object):
|
|
|
|
|
|
|
|
def __init__(self, app, ip):
|
|
|
|
self.app = app
|
|
|
|
self.ip = ip
|
|
|
|
|
|
|
|
def __call__(self, environ, start_response):
|
|
|
|
environ['REMOTE_ADDR'] = self.ip
|
2013-12-01 12:38:41 +00:00
|
|
|
environ['HTTP_ORIGIN'] = "http://localhost:8080"
|
2013-11-13 13:20:58 +00:00
|
|
|
return self.app(environ, start_response)
|
|
|
|
|
|
|
|
|
|
|
|
class Dummy:
|
|
|
|
|
|
|
|
status = 200
|
|
|
|
|
|
|
|
def __enter__(self):
|
|
|
|
return self
|
|
|
|
|
|
|
|
def read(self):
|
|
|
|
return ''
|
|
|
|
|
|
|
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
|
|
pass
|
|
|
|
|
|
|
|
curl = lambda method, host, path: Dummy()
|
|
|
|
loads = lambda data: json.loads(data.decode('utf-8'))
|