Can I make Fiddler unzip outbound traffic?

2019-08-07 10:34发布

In order to replicate a problem some users are having with my application, I need to simulate a corporate proxy server which decompresses GZIP'd http traffic and doesn't recompress it before passing it to the destination server. The users are getting the error "the magic number in the GZIP header is incorrect" and it's my suspicion that the proxy server is not re-zipping the decompressed GZIPed traffic.

Is there a way I can simulate this using Fiddler? Specifically, I think I need to simulate proxys decompressing the body and perhaps not altering the headers to match.

2条回答
劫难
2楼-- · 2019-08-07 11:12

Give a try to:

Recenly, I found that the GZIP zip/unzip feature in fiddler does not work properly. There are applications which are based on HTTP protocol and also zip HTTP Requests and Responses with GZIP format. So I decided to write some script using Fiddler Script Editor for converting and extracting Requests that are in GZIP format. Here is the code, copy this to the CustomRules.js file (Rules---->Customize Rules)

http://yossi-yakubov.blogspot.fr/2010/05/fiddler-gzip-issue.html

查看更多
姐就是有狂的资本
3楼-- · 2019-08-07 11:16

Yes, Fiddler can manipulate the HTTP request and response in any way you like.

First, please confirm that your application GZIP's the request body. While compressing the response is very common, compressing the request is very uncommon for a number of reasons.

After that, you can do the following:

  1. In Fiddler, click Rules > Customize Rules.
  2. Scroll to OnBeforeRequest.
  3. Inside the method, add the following code: if (oSession.oRequest.headers.ExistsAndContains("Content-Encoding", "gzip")) { oSession.utilDecodeRequest(); // Decompress request and remove header oSession.oRequest["Content-Encoding"] = "gzip"; // Put header back oSession["ui-backcolor"] = "yellow"; // Mark the session }

  4. Save the script.

查看更多
登录 后发表回答