Reputation: 6968
When I run my python code as normal:
batch_request = BatchHttpRequest(batch_uri = "http://localhost:12345/api/batch")
batch_request.add(get_customers)
batch_request.execute()
Fiddler doesn't pick up the request.
When I change batch_uri
to localhost.fiddler
, I get:
ServerNotFoundError: Unable to find the server at localhost.fiddler
Same for ipv4.fiddler
When I change batch_uri
to my pc name, pc-21
, I get:
<HttpError 400 when requesting http://pc-21:12345/api/batch returned "Bad Request">
I've tried adding the following rule to fiddler:
static function OnBeforeRequest(oSession:Fiddler.Session){
if (oSession.HostnameIs("MYAPP")){
oSession.host = "127.0.0.1:8081";
}
}
Which also gives a server not found error.
And still none of these appear in fiddler.
Anybody have any ideas??
Edit
With EricLaw's suggestion, I got the following code working and captured by fiddler:
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)
Upvotes: 0
Views: 945
Reputation: 57085
Your Python code isn't configured to use Fiddler as a proxy, which is why the localhost.fiddler
hostname isn't recognized. That virtual hostname only exists when a request is sent through Fiddler.
What HTTP object are you using from Python? You need to check its documentation for information on how to set its proxy to 127.0.0.1:8888
. E.g. Proxy with urllib2
Upvotes: 2