Bug in litespeed sapi, http_response_code() returns empty string

bneon

New Member
#1
Found this while debugging a page cache problem for a customer.

Other SAPI implementations, like mod_php, fastcgi, etc, will return "200" for http_response_code() if you haven't explicitly set it (there are several ways to set it, of course).

Litespeed's sapi returns an empty string if you haven't done something to set it.

A simple test:

<?php
$rc=http_response_code();
print "rc is [$rc]\n";​
?>​

Litespeed's sapi will print out "rc is []", other popular sapi implementations print "rc is [200]".

The manual page for http_response_code (here: http://php.net/manual/en/function.http-response-code.php ) says this:

Return Values
The current response code. By default the return value is int(200).


 

NiteWave

Administrator
#2
Thanks

tested with nginx + phpfpm and lsphp5, confirmed the difference.

>debugging a page cache problem
do you mean the lsws page cache ? after you patch the lsapi, the issue is gone ? can you give more info regarding this ?
 

bneon

New Member
#3
Thanks

tested with nginx + phpfpm and lsphp5, confirmed the difference.

>debugging a page cache problem
do you mean the lsws page cache ? after you patch the lsapi, the issue is gone ? can you give more info regarding this ?
No, it's a page cache we wrote for opencart (https://github.com/budgetneon/pagecache). I do not have regular access to litespeed, I had a customer trying to use it. He was only able to give me ftp access, so debugging it was something of a bear (logging to files, making changes, ftp new code, repeat).

We worked around it like this: https://github.com/budgetneon/pagecache/blob/master/upload/system/library/pagecache.php#L241
 
Top