当我正常运行python代码时:
batch_request = BatchHttpRequest(batch_uri = "http://localhost:12345/api/batch")
batch_request.add(get_customers)
batch_request.execute()
小提琴手不接这个请求。在
当我将batch_uri
更改为localhost.fiddler
时,我得到:
对ipv4.fiddler
相同
当我将batch_uri
改为我的电脑名pc-21
时,我得到:
<HttpError 400 when requesting http://pc-21:12345/api/batch returned "Bad Request">
我试着给小提琴手添加以下规则:
static function OnBeforeRequest(oSession:Fiddler.Session){
if (oSession.HostnameIs("MYAPP")){
oSession.host = "127.0.0.1:8081";
}
}
这也会产生“找不到服务器”错误。在
但这些仍然没有出现在小提琴手。在
有人有什么想法吗??在
编辑
在埃里克劳的建议下,我得到了以下代码,并被小提琴手捕获:
proxy = ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP_NO_TUNNEL, proxy_host='127.0.0.1', proxy_port=8888)
http = Http(proxy_info=proxy)
get_customers = HttpRequest(http, print_complete, "http://localhost:65200/api/Customers", method="GET", headers={"Content-Type": "application/http; msgtype=request"})
batch_request = BatchHttpRequest(batch_uri = "http://localhost:65200/api/batch")
batch_request.add(get_customers, callback=print_complete)
try:
batch_request.execute()
except HttpError, e:
print "{0}".format(e)
您的Python代码没有配置为使用Fiddler作为代理,这就是为什么不能识别
localhost.fiddler
主机名。只有通过Fiddler发送请求时,虚拟主机名才存在。在您使用的是Python中的哪个HTTP对象?您需要查看它的文档,了解如何将其代理设置为
127.0.0.1:8888
。E、 g.Proxy with urllib2相关问题 更多 >
编程相关推荐