File req contains the request header:GET /cd/E11882_01/server.112/e41084/toc.htm HTTP/1.1^MHost: docs.oracle.com^MAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8^MAccept-Language: en-US,en;q=0.5^MAccept-Encoding: gzip, deflate^MConnection: keep-alive^M^MI run:cat req | nc docs.oracle.com 80 > respresp contains:HTTP/1.1 200 OK^MServer: Apache^METag: 726bf43b293f9fc8eac0f8f6b7be3a84:1457459134^MLast-Modified: Fri, 04 Mar 2016 14:26:34 GMT^MAccept-Ranges: bytes^MContent-Type: text/html^MVary: Accept-Encoding^MContent-Encoding: gzip^MDate: Sat, 18 Jun 2016 07:04:06 GMT^MContent-Length: 13163^MConnection: keep-alive^M^M^_<8b>^H^@^@^@^@^@^@^@}ys8<92>)<88>}3Mvy<83>%u(1^[^[Zmv<92>[Gu?f<82>^D^H  x^[]^AH$^R<99><89>D^?<97>^O^O<8c>Hds\^Gi<82>^?^^C^B9<^^_^_/\<9d>Kw<98>^\<9b>uz!-<9b>C9|<88><8f>.T<9b>!x=Kx^N^WV<87><8f>{L//?I&;drLGC'!<91>=^\^_G^Lwy<9f>)^\^O<97>^V~|^NK^NMO<81>4<80>^\<93>T<9a>.,SRr^^^?)N:z<97>n]r<9e><8e>wr<9d>J<9e>3J_z^@!C<93>>R.<8f>^O^?@^Ctw<97>On<9f>m7<92>1^K<9d>^R^_^_<96>49+5#^[<97>^]^?j?^U_w<9b>a^Q%ue^Sd<94>wk8T<89><93><80><R<9e>7&w,U<93>^KF<8c>o9:h{^Z4lMk<90><88><8f>^W^_>\*^ABx>@^_^OO<8f>!qB=Gr<8f>O^Lm><l7<84>j    _9A<88>^<82>.{<^T^?L^^^_^R^_~K'^_/$i[<9e>   ...continues...Now, apparently the response body is in gzip format. To decompress it, I have copied the response body to resp-body. So, resp-body contains:^_<8b>^H^@^@^@^@^@^@^@}ys8<92>)<88>}3Mvy<83>%u(1^[^[Zmv<92>[Gu?f<82>^D^H  x^[]^AH$^R<99><89>D^?<97>^O^O<8c>Hds\^Gi<82>^?^^C^B9<^^_^_/\<9d>Kw<98>^\<9b>uz!-<9b>C9|<88><8f>. T<9b>!x=Kx^N^WV<87><8f>{L//?I&;drLGC'!<91>=^\^_G^Lwy<9f>)^\^O<97>^V~|^NK^NMO<81>4<80>^\<93>T<9a>.,SRr^^^?)N:z<97>n]r<9e><8e>wr<9d>J<9e>3J_z^@!C<93>>R.<8f>^O^?@^Ctw<97>On<9f>m7<92>1^K<9d>^R^_^_<96>49+5#^[<97>^]^?j?^U_w<9b>a^Q%ue^Sd<94>wk8T<89><93><80><R<9e>7&w,U<93>^KF<8c>o9:h{^Z4lMk<90> <88><8f>^W^_>\*^ABx>@^_^OO<8f>!qB=Gr<8f>O^Lm><l7<84>j    _9A<88>^<82>.{<^T^?L^^^_^R^_~K'^_/$i[<9e>   ...continues...Then I have tried gzip -d resp-body but it does not work.What should I do in order to decompress the response?
How to decompress gzipped HTTP response?
gzip;http
Delete the headers and what you'll have left is gzip-compressed data that can be decompressed with gzip -d or zcat.e.g. sed -e '1,/^[[:space:]]*$/d' resp | gzip -d > resp.decompressedThe sed script deletes the headers - i.e. everything from the first line to the first empty line (/^[[:space:]]*$/).The [[:space:]] character-class will make the sed script match empty lines and lines containing only space characters (including carriage-returns, ^M)BTW, a slightly smarter version of this would extract the Content-Encoding: and Content-Type: headers, and use the mime-type from that to decide whether to use cat, lynx -dump, gzip -d, bzip2 -d, xz -d or whatever else to decode the data.  But that would probably require writing it in perl.