Le 04/03/2021 à 21:15, Christophe JAILLET a écrit :
Le 04/03/2021 à 08:20, Lars Bruun-Hansen a écrit :
How do I customize the HTTP Reason Phrase ?

Definition: The Reason Phrase is sent in an HTTP response on the very
first line immediately following the status code, for example such
line may look like this:

    HTTP/1.1 401 Unauthorized

In this case "Unauthorized" is the Reason Phrase.

I've tried the Send-as-is Handler [1] which according to its
documentation should be able to do this. For example, I have an .asis
file which looks like this:

----file content begin
Status: 401 Blablabla
Content-type: text/html

<html>
<head>
<title>Foo Bar Title</title>
</head>
<body>
<h1>You can't do that</h1>
</body>
</html>
----file content end

This .asis file gets picked up and used in the response but it doesn't
really change the status code. I've looked into the source code for
the as-is module and can see no evidence that the documentation is
correct in stating that the header named "Status" will actually be
used for anything. As long as the .asis file can be successfully read
then the status code will be 200. That doesn't match the
documentation.

In any case maybe there's another way to customize Reason Phrase?

Thanks.

/Lars

[1] https://httpd.apache.org/docs/2.4/mod/mod_asis.html


Hi,
I've tested it with the test framework and it works as expected.
(See [1] for the test written in perl, and [2] for the .asis files where the 403 and 404 response codes come from)

I've slightly modified the test code ([1]) and I confirm that the status phrase is also left unmodified, as expected.


In fact, the response code comes "as-is" from the file itself. It is included in the processing flow of Apache by the 'apr_brigade_insert_file()' at line 95. So you can't find any kind of special "status" handling in the code, as there is no manipulation done on the file content itself.


Just in case, the handler name is "send-as-is" (no uppercase S as the first letter as written is your mail). See line 37 of the module source code.

CJ



[1]: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/modules/asis.t?revision=647766&view=markup&pathrev=

[2]: http://svn.apache.org/viewvc/httpd/test/framework/trunk/t/htdocs/modules/asis/?pathrev=1885573

Hi,

I forgot to add, that the directive that you seem to be looking for is ErrorDocument (see https://httpd.apache.org/docs/2.4/mod/core.html#errordocument)

CJ

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org

Reply via email to