Thank you for your answer!

You are more or less correct - And as I saw it to be too much work (or
just more or less impossible) I changed my approach to the problem.

I am now sending several separated request with JavaScript (jQuery to
be exact) without a 302, since I know in advance where I'll have to go
anyway.

So this issue can be considered closed!

Sincerely yours
Louis

2011/6/24 Arthur Moczulski <arthur.moczul...@gmail.com>:
> Hey,
> this is what I understand: you want to manipulate headers of the request
> sent by the client directly after receiving a 302 response?
> If that's the case, than read further ;)
> Any client goes through the following process while communicating with a
> web-server:
> 1. get IP address from the domain (achieved thanks to DNSs)
> 2. create an IP socket connection with the obtained IP address
> 3. write an HTTP request through the socket
> 4. receive an HTTP response from the web-server. the "answer" will include
> status compatible with the HTTP protocol.
> In your example this process is repeated twice:
> 1. get ip of domain using dns
> 2. open a connection
> 3. write an http request to the socket
> 4. receive http with 302 status
> (the client as an http protocol compliant software continues with the
> alternative url provided by the 302 response)
> 5. get ip of domain specified as alternative url in received 302 using dns
> 6. open a new connection
> 7. write an http request to the newly opened socket
> 8. receive http response from web-server
> Your problem is exactly between point 4 and 5. Unfortunately for you that's
> client software's work to determine what will be done next. HTTP compliant
> software (which every browser is) will follow the redirection. So, unless a
> client provides you with some way of manipulating this behaviour, which is
> quite unlikely, this can't be done.
> Javascript won't be too much help in here as js scripts loaded into the
> browser live only in the lifetime of displaying the specific response. As
> 302 responses can't include any content like javascript code which can live
> in the lifetime of processing the response, so you can't control what's
> going on in here.
> The only way that comes my mind is to check if 302 response can hold any
> "force behaviour" sort of information which is taken under consideration by
> the client. Unfortunately, I don't think HTTP protocol specification defines
> anything like that (however something definitely worth checking).
> What you can try though is extending whole the communication between client
> and web-server. So:
> 1. send the original request
> 2. receive the 302 response
> 3. send the request for alternative url
> 4. web-server checks the referrer of the request received and sends an
> answer needed, so you receive a response which guides your client
> To achieve that you need an access to the server-side application.
> Let me know if that's any help.
> On 24 June 2011 08:37, Louis Huppenbauer <louis.huppenba...@gmail.com>
> wrote:
>>
>> Thanks for your response, but I don't think that will do.
>>
>> First - SERVER_PORT is the port the apache/iis/whatever server is
>> working with (usually 80 or 443)
>> Second - That would still be manipulating the headers for the response
>> (As php mostly just generates the response, and not the request).
>>
>> I'm thinking more and more that this is not really a php-question (as
>> it is server-side), but more of a js-question (client-side).
>>
>> thanks anyway!
>> louis
>> 2011/6/24  <ad...@buskirkgraphics.com>:
>> > Try
>> >
>> >
>> > If($_SERVER['SERVER_PORT'] == "302")
>> > {
>> > header('Referer: example.net');
>> > }
>> >
>> >
>> > Richard L. Buskirk
>> >
>> > -----Original Message-----
>> > From: Louis Huppenbauer [mailto:louis.huppenba...@gmail.com]
>> > Sent: Friday, June 24, 2011 3:05 AM
>> > To: php-general@lists.php.net
>> > Subject: [PHP] Manipulate Request Headers after Redirect
>> >
>> > Hi there!
>> >
>> > I just have a small question concerning the http-protocol and php (and
>> > in specific the header-function, i think).
>> > Is it possible to manipulate the headers for the request which is sent
>> > after a 302-header?
>> >
>> >
>> > eg:
>> >
>> > Response:
>> > header('Referer: example.com');
>> > header('Location: example.net');
>> >
>> > Request (for the 302):
>> > header('Referer: example.net');
>> > header('Cache: max-age=0);
>> >
>> >
>> > I think I need that for a login to a tomcat app from an external
>> > php-form. As of now the Login works fine, I just have to reload the
>> > page to actually be logged in (and that is quite a bother).
>> >
>> >
>> > Sincerely yours
>> > Louis
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to