php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59604 http_redirect breaks output with zlib.output_compression=on
Submitted: 2011-02-03 05:51 UTC Modified: 2011-03-24 04:53 UTC
From: delreich at takeit dot se Assigned: mike (profile)
Status: Closed Package: pecl_http (PECL)
PHP Version: 5.3.5 OS: Fedora 14
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: delreich at takeit dot se
New email:
PHP Version: OS:

 

 [2011-02-03 05:51 UTC] delreich at takeit dot se
Description:
------------
Config change: zlib.output_compression = on

Using http_redirect(...) produces uncompressed output
with header 'Content-Encoding: gzip', which will make
user-agents try to decode unencoded text.
Changing http.force_exit make no difference.

Need to disable automatic following of redirects to
actually see this, e.g. with
> curl -sSi --header 'Accept-Encoding: gzip' $url

Using header('Loaction: ...') followed by die(...) works
as one would expect, with output being compressed.

Same happens on CentOS 5.5, php 5.1.6, pecl_http 1.6.5.

Reproduce code:
---------------
<?php

if (!isset($_SERVER['PATH_INFO']) ||
    strpos('/', $_SERVER['PATH_INFO']) !== false) {
    // i.e. no path_info to speak of
    $url = http_build_url(rtrim($_SERVER['SCRIPT_NAME'], '/') . '/redir');
    header('Location: ' . $url);
    die("Redirecting to <a href=\"$url\">$url</a>.\n");
}
elseif ($_SERVER['PATH_INFO'] === '/redir') {
    http_redirect('foobar');
}

header('Content-Type: text/plain');
echo("No redirection this time.\n");


Expected result:
----------------
GET /index.php HTTP/1.1
Host: localhost
Accept: */*
Accept-Encoding: gzip,deflate

HTTP/1.1 302 Found
Date: Thu, 03 Feb 2011 10:03:23 GMT
Server: Apache/2.2.17 (Fedora)
X-Powered-By: PHP/5.3.5
Location: http://localhost/index.php/redir
Content-Encoding: gzip
Vary: Accept-Encoding
Content-Length: 90
Content-Type: text/html; charset=UTF-8

[gzipped content that decodes to:
Redirecting to <a href="http://localhost/index.php/redir">http://localhost/index.php/redir</a>.
]

Actual result:
--------------
GET /index.php/redir HTTP/1.1
Host: localhost
Accept: */*
Accept-Encoding: gzip,deflate

HTTP/1.1 302 Found
Date: Thu, 03 Feb 2011 10:13:50 GMT
Server: Apache/2.2.17 (Fedora)
X-Powered-By: PHP/5.3.5
Location: http://localhost/index.php/foobar
Content-Encoding: gzip
Vary: Accept-Encoding
Content-Length: 98
Content-Type: text/html; charset=UTF-8

Redirecting to <a href="http://localhost/index.php/foobar">http://localhost/index.php/foobar</a>.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-03 05:57 UTC] delreich at takeit dot se
Alternative expected result would be actual result without the content-encoding header.
 [2011-03-24 04:53 UTC] mike@php.net
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Nov 13 04:01:31 2024 UTC