Can we configure HTTP response code headers?

comb asked:

We’re stumped. We’re getting a new header in our Apache httpd + Passenger web server we didn’t expect. We have a sensitive web client reading this we cannot modify at this time.

Can we modify this piece of the header? As we understand it, the “OK” is part of the spec. We would like to modify the header so that it includes all the expected pieces of the spec.

We are expecting:

"HTTP/1.1 200 OK"

But instead are getting:

"HTTP/1.1 200 "

My answer:

You’re not meant to interpret anything beyond the numeric response code in your computer program; the textual representation is meant for human consumption.

See RFC 2616 section 6.1.1:

6.1.1 Status Code and Reason Phrase

The Status-Code element is a 3-digit integer result code of the attempt to understand and satisfy the request. These codes are fully defined in section 10. The Reason-Phrase is intended to give a short textual description of the Status-Code. The Status-Code is intended for use by automata and the Reason-Phrase is intended for the human user. The client is not required to examine or display the Reason-Phrase.

Looking for “OK” (or indeed, anything beyond the number) is a logic error in the program. The ABNF grammar makes clear that the Reason-Phrase may be empty:

      Reason-Phrase  = *<TEXT, excluding CR, LF>

So, your server is operating according to spec; the client is not.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.