0

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)
TomSelleck
  • 6,706
  • 22
  • 82
  • 151
  • I believe somebody already has had one: http://stackoverflow.com/q/4647105/535275 – Scott Hunter Apr 30 '14 at 16:11
  • I've tried the solutions listed there - no joy – TomSelleck Apr 30 '14 at 16:22
  • This code appears to only support `SOCKS`-type proxies, instead of the MUCH more common `CERN`-type. Fiddler does not expose a SOCKS proxy. I'm sure there's *some* way to use Python with the more common type, but I'm not a python developer. See http://stackoverflow.com/questions/2907812/does-httplib2-support-http-proxy-at-all-socks-proxy-works-but-not-http – EricLaw May 01 '14 at 19:49
  • Try changing the type to `socks.PROXY_TYPE_HTTP_NO_TUNNEL` which appears to not use SOCKS despite the misleading name. – EricLaw May 01 '14 at 19:50
  • You were dead right, thanks very much! – TomSelleck May 02 '14 at 08:45

1 Answers1

2

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

Community
  • 1
  • 1
EricLaw
  • 56,563
  • 7
  • 151
  • 196