开发者

gzip HttpWebRequest

开发者 https://www.devze.com 2022-12-16 20:28 出处:网络
I am submitting HTTP POST requests via HttpWebRequest which contain a large amount of content. I would like to gzip the message content. Is this possible?

I am submitting HTTP POST requests via HttpWebRequest which contain a large amount of content. I would like to gzip the message content. Is this possible?

Does IIS 7 have to be configured to handle the compressed content? It has already been configured to serve compressed responses.

I've tried adding a Content-Encoding = gzip header and writing to the request stream w开发者_如何学Pythonrapped in a GZipStream but the server returns a 504 (GatewayTimeout) which seems odd.


I don't believe IIS7 supports GZIP requests, out of the box. Here's why. On my IIS7 machine, gzip.dll does not export decompression methods.

c:\Windows\System32\inetsrv>c:\vc9\bin\dumpbin.exe  -exports gzip.dll
Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file gzip.dll

File Type: DLL

  Section contains the following exports for gzip.dll

    00000000 characteristics
    47919400 time date stamp Sat Jan 19 01:09:04 2008
        0.00 version
           1 ordinal base
           6 number of functions
           6 number of names

    ordinal hint RVA      name

          1    0 0000242D Compress
          2    1 00002E13 CreateCompression
          3    2 000065AE DeInitCompression
          4    3 000012EE DestroyCompression
          5    4 0000658D InitCompression
          6    5 000065B6 ResetCompression

  Summary

        1000 .data
        1000 .reloc
        1000 .rsrc
        6000 .text

I think this represents a change in gzip.dll. I believe in prior versions of gzip.dll, there were 12 exported methods, including 6 that did Decompression.


The vast majority of web servers do not support compressed request bodies. mod_deflate can be configured to support it on Apache but seldom actually is (as a zip-bomb is an easy potential DoS attack). I'm not aware of an IIS solution.

If you are talking back to your own server there is of course nothing stopping you doing the compression at the application level. If you have to pass a standard form type for the backend to read, you should pick multipart/form-data, as URL-encoding would bloat the binary data of the compressed content parameter.


I got the same error.

Solved by adding executionTimeout to web.config:

<httpRuntime maxRequestLength="1048576" executionTimeout="300" />

ExecutionTimeout- is on seconds...

0

精彩评论

暂无评论...
验证码 换一张
取 消