Apache/PHP returning default http status

Asked

Viewed 108 times

0

I am creating a REST api in PHP, and in certain situations return an HTTP status with the specific error message for what occurred, for example, 403 Invalid Access Key rather than simply 403 Forbidden.

I’m using php’s header() function to generate such status, and local is working perfectly, but the default status messages appear on the production server. For example: where to return 403 Invalid Access Key, it returns the descriptive nothing 403 Forbidden.

What could be causing this? I did a lot of research and found nothing on the subject.

Location: Apache 2.4.9 PHP 5.5.12

Production: Apache 2.2.29 PHP 5.4.37

  • I can give you a suggestion, the error messages and the numbers are standardized, not only for a server or for a browser, but all tools that use HTTP somehow, changing the error message is the same as deregulating causing the logic to get lost, the best would be to pass the custom message in BODY, for example a JSON.

1 answer

0

Apparently, somehow the proxy (squid) is "standardizing" the HTTP headers. I checked this using REST clients like Hurl and Apigee, that make the requests from their own servers and not from the client, that is, does not go through the proxy. Thus, in these clients, the status returned as it should.

There’s nothing I can do about it at the moment, so this is not a "solution" answer, but there’s a tip for whoever needs it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.