|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-02-03 05:57 UTC] delreich at takeit dot se
[2011-03-24 04:53 UTC] mike@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 16:00:01 2025 UTC |
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>.