Content-Length header problem

#1
Hi,

I'm working on a php proyect. I need to redirect the user to other page and keep working in background, for that i use:

@ob_end_clean();
@ob_start();
@ignore_user_abort(true);
header("Status: 302");
header('Location: '.$href, true, 302);
header("Content-Length: 0", true);
header("Connection: close", true);
echo str_repeat("\r\n", 128); // for IE
@ob_end_flush();
@ob_flush();
@flush();

that is working on Apache severs, but for some reason litespeed is not sending content length header, and the browser omit the location header.

there is some way to do this?

Regards Ivan
 

NiteWave

Administrator
#2
I tested with following script:
PHP:
<?php
header("Status: 302");
header('Location: /phpinfo.php', true, 302);
header("Content-Length: 0", true);
header("Connection: close", true);
echo str_repeat("\r\n", 128); // for IE
?>
It is working fine: redirect to /phpinfo.php successfully.
 
#3
Hi,
Put sleep(15); at the end of the script to see if redirect works.

As now, you are finishing the script with the end tag ?> and that work perfectly.

Remember i need to work in background after headers are sent
 

NiteWave

Administrator
#4
I tried sleep(15), sleep(35), sleep(135), all were successful.

can you try the test script at your end, so that I can reproduce.

how long will the background work take, for example, exceed 5 minutes?
 
#5
Hi,

this code is part of an upload script, uploads times depend on file size, but for most cases are > 5' . that is the reason to make uploads in background.

this are the hedaers sent as response from litespeed and from apche:


//from litespeed

Cache-Control:no-cache, must-revalidate, max-age=0
Connection:close
Content-Encoding:gzip
Content-Type:text/html; charset=UTF-8
Date:Tue, 24 May 2011 14:56:56 GMT
Expires:Wed, 11 Jan 1984 05:00:00 GMT
Last-Modified:Tue, 24 May 2011 14:56:48 GMT
Location:/wp-admin/tools.php?page=pressback_principal&function=dashboard&fargs[]=&fargs[]=1
Pragma:no-cache
Server:LiteSpeed
Transfer-Encoding:chunked
Vary:Accept-Encoding
X-Powered-By:pHP/5.2.16


//from apache

Cache-Control:no-cache, must-revalidate, max-age=0
Connection:close
Content-Length:0
Content-Type:text/html; charset=UTF-8
Date:Tue, 24 May 2011 15:03:07 GMT
Expires:Wed, 11 Jan 1984 05:00:00 GMT
Last-Modified:Tue, 24 May 2011 15:03:08 GMT
Location:/wp-admin/tools.php?page=pressback_principal&function=dashboard&fargs[]=&fargs[]=1
Pragma:no-cache
Server:Apache/2.2.15 (Unix)
X-Powered-By:pHP/5.2.13


See that content length not appear on litespeed, i think the browser don't make the redirect, because is waiting for some content.

After headers are get by the browser, this wait until 'background' task finish and then does the redirect

Regards Ivan
 

mistwang

LiteSpeed Staff
#6
That's because the request is not finished processing,
For some buggy script, even though the "Content-Length" header is set in response, the script may not exactly follow it, so chunked encoding is used.
It will be addressed in next build of 4.1.1 for your specific case.
 
Top