You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Shmuel Krakower <sh...@gmail.com> on 2019/05/22 18:00:07 UTC

[users@httpd] Control / Modify the HTTP Status Line

Hello,
This is my first message on this user list, hope that's the right place for
my question.

I am using Apache for proxying a backend server.
The backend server may return, in some occaisons, a 302 response code for
successful requests.
As I cannot alter the backend behavior nor the client's to consider such
302 responses as successful, I am looking for a way to manipulate the
response code on Apache.

While going through the options in and trying ways to alter data which is
sent back to clients I found two:
1. mod_substitute - to manipulate respose body.
2. mod_header - to manipulate respose headers.

The problem is that the HTTP Status Line (the very first line returned by
apache) cannot be altered by neither of these modules.
I was also trying to set the response code in various response headers but
none seem to make any affect on the Status Line contents.

Does anyone know of a way to manipulate the HTTP Status Line or how to
internal process of apache works to determine the Status Line (maybe this
way I can cause it to generate a different status line).

Thanks,
Shmuel Krakower.

[users@httpd] Re: Control / Modify the HTTP Status Line

Posted by "@lbutlr" <kr...@kreme.com>.
On 22 May 2019, at 12:00, Shmuel Krakower <sh...@gmail.com> wrote:
> I am using Apache for proxying a backend server.
> The backend server may return, in some occaisons, a 302 response code for successful requests.

This is incorrect behavior and you should fix that, not try to hack the reply codes.

-- 
"Humor is a rubber sword - it allows you to make a point without drawing
blood." - Mary Hirsch



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


Re: [users@httpd] Control / Modify the HTTP Status Line

Posted by Shmuel Krakower <sh...@gmail.com>.
Thanks Torsten,
I was reading and implementing a simple PerlResponseHandler script to set
the response status line/code.
It works fine as a standalone, but it seems like in conjuction with
mod_proxy, it has no affect.

It feels like this handler is not manipulating the response coming back
from the backend server.
Maybe there is a config to control the order of handlers? not sure...

Any ideas are welcome

Shmuel Krakower.


On Wed, 22 May 2019 at 23:42, Torsten Krah <kr...@gmail.com> wrote:

> Hi,
>
> you could use a mod_perl output filter handler to rewrite the response to
> your needs based on the input.
> Did that for some specific SaaS years ago and for some response with e.g.
> a special header the filter answered somerhing totally different and
> discarded the original response.
>
> Happy coding :-)
>
> Cheers
>
> Shmuel Krakower <sh...@gmail.com> schrieb am Mi., 22. Mai 2019, 22:29:
>
>> Hi matt and lbutlr
>> Thanks for the response.
>>
>> I guess I should add few pieces of information.
>> The client is one SaaS and the backend is another SaaS. The backend
>> returns 302 which is right but the client consider anything which is not
>> 2xx as error which cause it to retry.
>>
>> Therefore I must "hack" or stitch it with a proxy. I am using mod_proxy.
>> My other alternative is to use other software than httpd to stitch those
>> two services and show 200 instead of the 302.
>>
>> The solution mentioned in stackoverflow will not work for 302 response as
>> I cannot set error page for such non-error response codes.
>>
>> The solution with rewrite won't work neither as I need to alter the
>> response and not the request.
>>
>>
>> On Wed, May 22, 2019, 10:37 PM Muggeridge, Matt <ma...@hpe.com>
>> wrote:
>>
>>> With a little googling, this technique looks promising…
>>> https://stackoverflow.com/questions/15083481/how-can-i-replace-apache-http-code-404-to-200
>>>
>>>
>>>
>>>    - As I cannot alter the backend behaviour
>>>
>>>
>>>
>>> Yet, you talk about using mod_substitute and mod_header to alter the
>>> server’s behaviour.  If the 302 responses are not valid, then hunt down and
>>> fix/remove the ‘redirect’ configuration options in either a .htaccess or
>>> some other configuration file.
>>>
>>>
>>>
>>> Matt.
>>>
>>>
>>>
>>> *From:* Shmuel Krakower <sh...@gmail.com>
>>> *Sent:* Thursday, 23 May 2019 4:00 AM
>>> *To:* users@httpd.apache.org
>>> *Subject:* [users@httpd] Control / Modify the HTTP Status Line
>>>
>>>
>>>
>>> Hello,
>>>
>>> This is my first message on this user list, hope that's the right place
>>> for my question.
>>>
>>>
>>>
>>> I am using Apache for proxying a backend server.
>>>
>>> The backend server may return, in some occaisons, a 302 response code
>>> for successful requests.
>>>
>>> As I cannot alter the backend behavior nor the client's to consider such
>>> 302 responses as successful, I am looking for a way to manipulate the
>>> response code on Apache.
>>>
>>>
>>>
>>> While going through the options in and trying ways to alter data which
>>> is sent back to clients I found two:
>>>
>>> 1. mod_substitute - to manipulate respose body.
>>>
>>> 2. mod_header - to manipulate respose headers.
>>>
>>>
>>>
>>> The problem is that the HTTP Status Line (the very first line returned
>>> by apache) cannot be altered by neither of these modules.
>>>
>>> I was also trying to set the response code in various response headers
>>> but none seem to make any affect on the Status Line contents.
>>>
>>>
>>>
>>> Does anyone know of a way to manipulate the HTTP Status Line or how to
>>> internal process of apache works to determine the Status Line (maybe this
>>> way I can cause it to generate a different status line).
>>>
>>>
>>>
>>> Thanks,
>>>
>>> Shmuel Krakower.
>>>
>>

Re: [users@httpd] Control / Modify the HTTP Status Line

Posted by Torsten Krah <kr...@gmail.com>.
Hi,

you could use a mod_perl output filter handler to rewrite the response to
your needs based on the input.
Did that for some specific SaaS years ago and for some response with e.g. a
special header the filter answered somerhing totally different and
discarded the original response.

Happy coding :-)

Cheers

Shmuel Krakower <sh...@gmail.com> schrieb am Mi., 22. Mai 2019, 22:29:

> Hi matt and lbutlr
> Thanks for the response.
>
> I guess I should add few pieces of information.
> The client is one SaaS and the backend is another SaaS. The backend
> returns 302 which is right but the client consider anything which is not
> 2xx as error which cause it to retry.
>
> Therefore I must "hack" or stitch it with a proxy. I am using mod_proxy.
> My other alternative is to use other software than httpd to stitch those
> two services and show 200 instead of the 302.
>
> The solution mentioned in stackoverflow will not work for 302 response as
> I cannot set error page for such non-error response codes.
>
> The solution with rewrite won't work neither as I need to alter the
> response and not the request.
>
>
> On Wed, May 22, 2019, 10:37 PM Muggeridge, Matt <ma...@hpe.com>
> wrote:
>
>> With a little googling, this technique looks promising…
>> https://stackoverflow.com/questions/15083481/how-can-i-replace-apache-http-code-404-to-200
>>
>>
>>
>>    - As I cannot alter the backend behaviour
>>
>>
>>
>> Yet, you talk about using mod_substitute and mod_header to alter the
>> server’s behaviour.  If the 302 responses are not valid, then hunt down and
>> fix/remove the ‘redirect’ configuration options in either a .htaccess or
>> some other configuration file.
>>
>>
>>
>> Matt.
>>
>>
>>
>> *From:* Shmuel Krakower <sh...@gmail.com>
>> *Sent:* Thursday, 23 May 2019 4:00 AM
>> *To:* users@httpd.apache.org
>> *Subject:* [users@httpd] Control / Modify the HTTP Status Line
>>
>>
>>
>> Hello,
>>
>> This is my first message on this user list, hope that's the right place
>> for my question.
>>
>>
>>
>> I am using Apache for proxying a backend server.
>>
>> The backend server may return, in some occaisons, a 302 response code for
>> successful requests.
>>
>> As I cannot alter the backend behavior nor the client's to consider such
>> 302 responses as successful, I am looking for a way to manipulate the
>> response code on Apache.
>>
>>
>>
>> While going through the options in and trying ways to alter data which is
>> sent back to clients I found two:
>>
>> 1. mod_substitute - to manipulate respose body.
>>
>> 2. mod_header - to manipulate respose headers.
>>
>>
>>
>> The problem is that the HTTP Status Line (the very first line returned by
>> apache) cannot be altered by neither of these modules.
>>
>> I was also trying to set the response code in various response headers
>> but none seem to make any affect on the Status Line contents.
>>
>>
>>
>> Does anyone know of a way to manipulate the HTTP Status Line or how to
>> internal process of apache works to determine the Status Line (maybe this
>> way I can cause it to generate a different status line).
>>
>>
>>
>> Thanks,
>>
>> Shmuel Krakower.
>>
>

Re: [users@httpd] Re: Control / Modify the HTTP Status Line

Posted by Shmuel Krakower <sh...@gmail.com>.
Just for the closure of this thread - as I couldn't find any way of
altering the status line in apache while using mod_proxy, I had to use
another software to proxy such requests and altering the status line with
it.

Shmuel Krakower.


On Thu, 23 May 2019 at 12:14, Shmuel Krakower <sh...@gmail.com> wrote:

> Thanks for the feedback, i am looking for actual solutions i can apply and
> have control of. As i pointed out, i cannot control what i cannot control.
>
> On Thu, May 23, 2019, 11:28 AM @lbutlr <kr...@kreme.com> wrote:
>
>>
>> On 22 May 2019, at 14:29, Shmuel Krakower <sh...@gmail.com> wrote:
>> > I guess I should add few pieces of information.
>> > The client is one SaaS and the backend is another SaaS. The backend
>> returns 302 which is right but the client consider anything which is not
>> 2xx as error which cause it to retry.
>>
>> So, that simply moves the incorrect behavior from eh backend to the
>> server you do control.
>>
>> 302 is not a "retry" request, and treating it as such would be considered
>> abusive.
>>
>> > Therefore I must "hack" or stitch it with a proxy. I am using mod_proxy.
>> > My other alternative is to use other software than httpd to stitch
>> those two services and show 200 instead of the 302.
>>
>> Or fix the software that doesn't understand what a 302 code is.
>>
>> > The solution mentioned in stackoverflow will not work for 302 response
>> as I cannot set error page for such non-error response codes.
>>
>> Of course not, it's not an error code, it's a success code.
>>
>> --
>> I used to work in a fire hydrant factory. You couldn't park anywhere near
>> the place.
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>

Re: [users@httpd] Re: Control / Modify the HTTP Status Line

Posted by Shmuel Krakower <sh...@gmail.com>.
Thanks for the feedback, i am looking for actual solutions i can apply and
have control of. As i pointed out, i cannot control what i cannot control.

On Thu, May 23, 2019, 11:28 AM @lbutlr <kr...@kreme.com> wrote:

>
> On 22 May 2019, at 14:29, Shmuel Krakower <sh...@gmail.com> wrote:
> > I guess I should add few pieces of information.
> > The client is one SaaS and the backend is another SaaS. The backend
> returns 302 which is right but the client consider anything which is not
> 2xx as error which cause it to retry.
>
> So, that simply moves the incorrect behavior from eh backend to the server
> you do control.
>
> 302 is not a "retry" request, and treating it as such would be considered
> abusive.
>
> > Therefore I must "hack" or stitch it with a proxy. I am using mod_proxy.
> > My other alternative is to use other software than httpd to stitch those
> two services and show 200 instead of the 302.
>
> Or fix the software that doesn't understand what a 302 code is.
>
> > The solution mentioned in stackoverflow will not work for 302 response
> as I cannot set error page for such non-error response codes.
>
> Of course not, it's not an error code, it's a success code.
>
> --
> I used to work in a fire hydrant factory. You couldn't park anywhere near
> the place.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

[users@httpd] Re: Control / Modify the HTTP Status Line

Posted by "@lbutlr" <kr...@kreme.com>.
On 22 May 2019, at 14:29, Shmuel Krakower <sh...@gmail.com> wrote:
> I guess I should add few pieces of information.
> The client is one SaaS and the backend is another SaaS. The backend returns 302 which is right but the client consider anything which is not 2xx as error which cause it to retry.

So, that simply moves the incorrect behavior from eh backend to the server you do control.

302 is not a "retry" request, and treating it as such would be considered abusive.

> Therefore I must "hack" or stitch it with a proxy. I am using mod_proxy.
> My other alternative is to use other software than httpd to stitch those two services and show 200 instead of the 302.

Or fix the software that doesn't understand what a 302 code is.

> The solution mentioned in stackoverflow will not work for 302 response as I cannot set error page for such non-error response codes.

Of course not, it's not an error code, it's a success code.

-- 
I used to work in a fire hydrant factory. You couldn't park anywhere near the place.



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


Re: [users@httpd] Control / Modify the HTTP Status Line

Posted by Shmuel Krakower <sh...@gmail.com>.
Hi matt and lbutlr
Thanks for the response.

I guess I should add few pieces of information.
The client is one SaaS and the backend is another SaaS. The backend returns
302 which is right but the client consider anything which is not 2xx as
error which cause it to retry.

Therefore I must "hack" or stitch it with a proxy. I am using mod_proxy.
My other alternative is to use other software than httpd to stitch those
two services and show 200 instead of the 302.

The solution mentioned in stackoverflow will not work for 302 response as I
cannot set error page for such non-error response codes.

The solution with rewrite won't work neither as I need to alter the
response and not the request.


On Wed, May 22, 2019, 10:37 PM Muggeridge, Matt <ma...@hpe.com>
wrote:

> With a little googling, this technique looks promising…
> https://stackoverflow.com/questions/15083481/how-can-i-replace-apache-http-code-404-to-200
>
>
>
>    - As I cannot alter the backend behaviour
>
>
>
> Yet, you talk about using mod_substitute and mod_header to alter the
> server’s behaviour.  If the 302 responses are not valid, then hunt down and
> fix/remove the ‘redirect’ configuration options in either a .htaccess or
> some other configuration file.
>
>
>
> Matt.
>
>
>
> *From:* Shmuel Krakower <sh...@gmail.com>
> *Sent:* Thursday, 23 May 2019 4:00 AM
> *To:* users@httpd.apache.org
> *Subject:* [users@httpd] Control / Modify the HTTP Status Line
>
>
>
> Hello,
>
> This is my first message on this user list, hope that's the right place
> for my question.
>
>
>
> I am using Apache for proxying a backend server.
>
> The backend server may return, in some occaisons, a 302 response code for
> successful requests.
>
> As I cannot alter the backend behavior nor the client's to consider such
> 302 responses as successful, I am looking for a way to manipulate the
> response code on Apache.
>
>
>
> While going through the options in and trying ways to alter data which is
> sent back to clients I found two:
>
> 1. mod_substitute - to manipulate respose body.
>
> 2. mod_header - to manipulate respose headers.
>
>
>
> The problem is that the HTTP Status Line (the very first line returned by
> apache) cannot be altered by neither of these modules.
>
> I was also trying to set the response code in various response headers but
> none seem to make any affect on the Status Line contents.
>
>
>
> Does anyone know of a way to manipulate the HTTP Status Line or how to
> internal process of apache works to determine the Status Line (maybe this
> way I can cause it to generate a different status line).
>
>
>
> Thanks,
>
> Shmuel Krakower.
>

RE: [users@httpd] Control / Modify the HTTP Status Line

Posted by "Muggeridge, Matt" <ma...@hpe.com>.
With a little googling, this technique looks promising… https://stackoverflow.com/questions/15083481/how-can-i-replace-apache-http-code-404-to-200


  *   As I cannot alter the backend behaviour

Yet, you talk about using mod_substitute and mod_header to alter the server’s behaviour.  If the 302 responses are not valid, then hunt down and fix/remove the ‘redirect’ configuration options in either a .htaccess or some other configuration file.

Matt.

From: Shmuel Krakower <sh...@gmail.com>
Sent: Thursday, 23 May 2019 4:00 AM
To: users@httpd.apache.org
Subject: [users@httpd] Control / Modify the HTTP Status Line

Hello,
This is my first message on this user list, hope that's the right place for my question.

I am using Apache for proxying a backend server.
The backend server may return, in some occaisons, a 302 response code for successful requests.
As I cannot alter the backend behavior nor the client's to consider such 302 responses as successful, I am looking for a way to manipulate the response code on Apache.

While going through the options in and trying ways to alter data which is sent back to clients I found two:
1. mod_substitute - to manipulate respose body.
2. mod_header - to manipulate respose headers.

The problem is that the HTTP Status Line (the very first line returned by apache) cannot be altered by neither of these modules.
I was also trying to set the response code in various response headers but none seem to make any affect on the Status Line contents.

Does anyone know of a way to manipulate the HTTP Status Line or how to internal process of apache works to determine the Status Line (maybe this way I can cause it to generate a different status line).

Thanks,
Shmuel Krakower.