|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #28051 gzip accept-encoding for HTTP request
Submitted: 2004-04-19 03:12 UTC Modified: 2005-02-05 11:50 UTC
Avg. Score:4.4 ± 0.7
Reproduced:6 of 6 (100.0%)
Same Version:2 (33.3%)
Same OS:1 (16.7%)
From: Olaf at XCC dot TMFWeb dot NL Assigned: pollita (profile)
Status: Suspended Package: Feature/Change Request
PHP Version: 5 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: Olaf at XCC dot TMFWeb dot NL
New email:
PHP Version: OS:


 [2004-04-19 03:12 UTC] Olaf at XCC dot TMFWeb dot NL
This code sends a HTTP request without gzip accept-encoding header, so the server can't send a gzip content encoded response.

Reproduce code:
	echo strlen(file_get_contents(""));

Expected result:
GET /s HTTP/1.0
Content-Encoding: gzip

HTTP/1.0 200 OK
Content-Type: text/plain

Actual result:
GET /s HTTP/1.0

HTTP/1.0 200 OK
Content-Type: text/plain


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-19 06:35 UTC]
This may be added in PHP 5.1.

In the mean time you may be able to acheive this behavior using a combination of the header context parameter for the http:// wrapper and the zlib_filter found in PECL.  This stop-gap solution will only work in PHP5 however.
 [2005-02-05 08:50 UTC] none at none dot org
I get the desired result like this:
(lest I didn't get the point...)


  //  my server sends gzipped data if client allows
  $url = "";

  function gzdecode($string){
    $string = substr($string, 10);
    return gzinflate($string);

  function get_gzipped_data($url){
    $http_response = '';
    $fp = fsockopen($url, 80);
    fputs($fp, "GET / HTTP/1.1\r\n");
    fputs($fp, "Accept-Encoding: gzip\r\n");
    fputs($fp, "Host: $url\r\n\r\n");
    while (!feof($fp))
      $http_response .= fgets($fp, 128);
    return $http_response;

  $header = $matches[1];
  $body   = $matches[2];
  $html   = gzdecode($body);
	$strlen_uncomp = strlen(file_get_contents("http://$url/"));
	$strlen_decomp = strlen($body);

  echo "
  strlen_uncomp: $strlen_uncomp Kb
  strlen_decomp: $strlen_decomp Kb

Marek Moehling
(del numbers to despam)
 [2005-02-05 11:50 UTC] Olaf at XCC dot TMFWeb dot NL
> (lest I didn't get the point...)

The point is gzip suppport in file_get_contents().
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC