?
avatar PhilETaylor
PhilETaylor
15 May 2017

Steps to reproduce the issue

check the headers of a 404 page in Joomla

Expected result

Valid HTTP 1.1 Status line as per https://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html which states

The first line of a Response message is the Status-Line, consisting of the protocol version followed by a numeric status code and its associated textual phrase

Therefore:

HTTP/1.1 404 Not Found

Actual result

HTTP/1.1 404
Cache-Control: no-cache
Connection: keep-alive
Content-Type: text/html; charset=UTF-8
Date: Mon, 15 May 2017 17:04:39 GMT
Pragma: no-cache
Server: nginx/1.12.0
Set-Cookie: 2b5a6d72eb04b3ca2060919d2e69f2c9=89t2b6579gogie33tnjpmvdirq; path=/; HttpOnly
Transfer-Encoding: chunked
X-Powered-By: PHP/7.1.5

Other Comments

same happens for 500 errors:

HTTP/1.1 500

instead of

HTTP/1.1 500 Internal Server Error

avatar PhilETaylor PhilETaylor - open - 15 May 2017
avatar joomla-cms-bot joomla-cms-bot - change - 15 May 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 15 May 2017
avatar PhilETaylor PhilETaylor - edited - 15 May 2017
avatar PhilETaylor PhilETaylor - change - 15 May 2017
The description was changed
avatar PhilETaylor PhilETaylor - edited - 15 May 2017
avatar rdeutz
rdeutz - comment - 15 May 2017

Which Joomla version 3.7.1-rc2?

avatar PhilETaylor
PhilETaylor - comment - 15 May 2017

Test was done on 61b9fcc (which is joomla-cms/staging as of now)

avatar rdeutz
rdeutz - comment - 15 May 2017

might be a side effect of #15738

avatar PhilETaylor
PhilETaylor - comment - 15 May 2017

Look here: https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/application/web.php#L722

// 'status' headers indicate an HTTP status, and need to be handled slightly differently
$this->header('HTTP/1.1 ' . (int) $header['value'], true);
avatar PhilETaylor
PhilETaylor - comment - 15 May 2017

Also see #15738 - see where they DELIBERATELY changed the Unit tests that were failing to suit their new BROKEN implementation of the HTTP 1.1 Status codes!!!

THIS IS NOT WHAT YOU DO WITH UNIT TESTS!!!!

avatar mbabker
mbabker - comment - 15 May 2017

Regardless of the changes in #15738 we've never handled Status headers very well as we don't enforce having a full header in our API. So we do need to look at better handling that somehow in general.

avatar PhilETaylor
PhilETaylor - comment - 15 May 2017

The unit tests used to be right, Joomla used to be right. Then #15738 changed that.

avatar wilsonge
wilsonge - comment - 15 May 2017

That was actually an unintended side effect of me trying to do fancy stuff with the redirect methods. I also changed the unit test when we reverted back to using the api. Given that everything else didn't have the text I didn't see it as an issue for that pull request. Although it is something we should solve generically

avatar PhilETaylor
PhilETaylor - comment - 15 May 2017

Well however it has been caused, Joomla 3.7.x will soon output invalid HTTP 1.1 status codes as the first output it ever sends to the browser.

Would be easy to fix by extending the use of the $responseMap and using those as the code instead of the int.

I would do the PR but Im on my way out for an indian curry...

avatar PhilETaylor
PhilETaylor - comment - 15 May 2017

if you dump out headers from http://joomla-cms/index.php?option=com_asd

$header['value']

in

// 'status' headers indicate an HTTP status, and need to be handled slightly differently
$this->header('HTTP/1.1 ' . (int) $header['value'], true);

You get

404 Component not found.

So the fact that casting it to (int) is getting 404 is lucky.. it is very tacky at best!

avatar PhilETaylor PhilETaylor - edited - 15 May 2017
avatar brianteeman
brianteeman - comment - 15 May 2017

just for fun i checked drupal and wordpress they also are "wrong" as is myjoomla.com although at least github was correct

drupal

screenshotr18-36-22

wordpress

screenshotr18-36-45

myjoomla.com

screenshotr18-41-50

github

screenshotr18-39-57

avatar PhilETaylor
PhilETaylor - comment - 15 May 2017

so just cause other projects do the wrong thing so should Joomla?

Just because Joomla USED TO DO THE RIGHT THING it is acceptable to change the unit tests to accept the WRONG THING now for whatever reasons?

avatar brianteeman
brianteeman - comment - 15 May 2017

its a bug - calm down - its not the end of the world

avatar PhilETaylor
PhilETaylor - comment - 15 May 2017

Its not a bug, Its a regression
Its made Joomla worse than it already was

avatar brianteeman
brianteeman - comment - 15 May 2017

hardly - but keeping banging your drum

the day any developer writes perfect code we can all go out and get new jobs - until then....

avatar PhilETaylor
PhilETaylor - comment - 15 May 2017

Well Im sorry for demanding that Joomla is held to some kind of standard... shoot me.

avatar mbabker
mbabker - comment - 15 May 2017

The only time Joomla did the right thing was with redirect responses because that one explicitly mapped a status code to a value in an array. Any other way to set the Status header doesn't go through any form of validation, so it hasn't always been right.

So yes it's a regression in that this change was allowed, but no we haven't completely FUBAR'd the handling of that header.

avatar PhilETaylor PhilETaylor - change - 15 May 2017
The description was changed
Title
HTTP/1.1 404 !== HTTP/1.1 404 Not Found
Invalid HTTP 1.1 Status lines generated by Joomla for 404/500 and maybe more
Status New Closed
Closed_Date 0000-00-00 00:00:00 2017-05-15 17:51:47
Closed_By PhilETaylor
avatar PhilETaylor PhilETaylor - close - 15 May 2017
avatar mbabker mbabker - change - 15 May 2017
Status Closed New
Closed_Date 2017-05-15 17:51:47
Closed_By PhilETaylor
avatar mbabker mbabker - reopen - 15 May 2017
avatar mbabker
mbabker - comment - 15 May 2017

It's a valid issue...

avatar rdeutz
rdeutz - comment - 15 May 2017

closing because we can discuss a PR #16040

avatar rdeutz rdeutz - change - 15 May 2017
Status New Closed
Closed_Date 0000-00-00 00:00:00 2017-05-15 18:46:46
Closed_By rdeutz
avatar rdeutz rdeutz - close - 15 May 2017

Add a Comment

Login with GitHub to post a comment