You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Victor Danilchenko <da...@cs.umass.edu> on 2007/05/03 04:52:10 UTC

Help with sending custom headers in mod_perl2

	I seem to be missing something very obvious... I have:

$r->header_out("Refresh"=>"0; URL=$uri\n");
$r->send_http_header;
print "Test redirect => $uri\n";

	But when the redirect page gets submitted, the HTTP headers show up as 
page contents:

Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8

1e
Test redirect => /?loopback=1

0


	Obviously only the stuff after 'Test redirect' should show up. I am 
using Mason, and writing an error handler -- it tries to tell the 
browser resubmit a GET request in the event of a Mason failure. It looks 
like Mason inserts  a blank line to terminate the HTTP header block. is 
there any way to counter that, so that the header directives end up in 
the header?

	Incidentally, the actual Refresh header does work, so maybe my 
hypothesis about Mason is off the wall.

	Any ideas?

P.S. On a wild shot, does anyone know if the XMLHttpRequest JavaScript 
directive generally honors the HTTP Refresh header in Firefox and IE?

Re: Help with sending custom headers in mod_perl2

Posted by Victor Danilchenko <da...@cs.umass.edu>.
	By the way, this submission of the HTTP header also seems to result in 
an about 20 second additional delay on the client side -- i.e. if I 
request an object which returns the Refresh header, I wait for about 20 
seconds, then see the headers flash by as page contents, and then the 
refresh occurs. I do not get this extra delay when I simply submit the 
refresh as a <meta> header, so this seems to be an artifact of the HTTP 
transaction in some way.

Victor Danilchenko wrote:
>     I seem to be missing something very obvious... I have:
> 
> $r->header_out("Refresh"=>"0; URL=$uri\n");
> $r->send_http_header;
> print "Test redirect => $uri\n";
> 
>     But when the redirect page gets submitted, the HTTP headers show up 
> as page contents:
> 
> Keep-Alive: timeout=15, max=99
> Connection: Keep-Alive
> Transfer-Encoding: chunked
> Content-Type: text/html; charset=UTF-8
> 
> 1e
> Test redirect => /?loopback=1
> 
> 0
> 
> 
>     Obviously only the stuff after 'Test redirect' should show up. I am 
> using Mason, and writing an error handler -- it tries to tell the 
> browser resubmit a GET request in the event of a Mason failure. It looks 
> like Mason inserts  a blank line to terminate the HTTP header block. is 
> there any way to counter that, so that the header directives end up in 
> the header?
> 
>     Incidentally, the actual Refresh header does work, so maybe my 
> hypothesis about Mason is off the wall.
> 
>     Any ideas?
> 
> P.S. On a wild shot, does anyone know if the XMLHttpRequest JavaScript 
> directive generally honors the HTTP Refresh header in Firefox and IE?


RE: Help with sending custom headers in mod_perl2

Posted by Ki...@alltel.com.
Can someone tell me how to unsubscribe from this list..I haven't been able to unsubscribe.


-----Original Message-----
From:	Victor Danilchenko [mailto:danilche@cs.umass.edu]
Sent:	Fri 5/4/2007 9:41 AM
To:	modperl@perl.apache.org
Cc:	
Subject:	Re: Help with sending custom headers in mod_perl2

Perrin Harkins wrote:
> On 5/2/07, Victor Danilchenko <da...@cs.umass.edu> wrote:
>>         I seem to be missing something very obvious... I have:
>>
>> $r->header_out("Refresh"=>"0; URL=$uri\n");
> 
> I think you're looking for this:
> 
> $r->headers_out->add("Refresh"=>"0; URL=$uri\n");

	Yup, that was it. Thanks.

	Unfortunately, it worked, but it didn't help :(. Apparently neither 
Firefox nor IE honor the Refresh HTTP header when performing the 
XMLHttpRequest operation in JavaScript, so I will have to figure out a 
different way to re-process the request upon error.

> You were trying to use mod_perl 1 syntax.  See this for more:
> http://perl.apache.org/docs/2.0/user/porting/compat.html#C__r_E_gt_header_out_ 

-- 
|  Victor  Danilchenko  | Give a man a match, and he will be warm   |
| danilche@cs.umass.edu | for a moment; but set him on fire, and    |
|   CSCF   |   5-4231   | he will be warm for the rest of his life. |




******************************************************************************************
The information contained in this message, including attachments, may contain 
privileged or confidential information that is intended to be delivered only to the 
person identified above. If you are not the intended recipient, or the person 
responsible for delivering this message to the intended recipient, Alltel requests 
that you immediately notify the sender and asks that you do not read the message or its 
attachments, and that you delete them without copying or sending them to anyone else. 



Re: Help with sending custom headers in mod_perl2

Posted by Jonathan Vanasco <jv...@2xlp.com>.
On May 4, 2007, at 7:49 PM, Victor Danilchenko wrote:

> 	Someone (you know who you are, thanks!) helped me off-list by  
> pointing out that I should use HTTP status 301 with Location header  
> instead. In retrospect, it should have been obvious that the  
> behavior I desired is meaningless in the context of Refresh header.  
> D'oh.

That was me.  I thought i sent that to the list.

The essence of the email ( for future google searchers )
	a 301 http redirect is more appropriate
		xmlhttprequest etc will recognize the 301
		the flash player ( loadmovie / loadvariables ) will not


// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
| SyndiClick.com
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|      FindMeOn.com - The cure for Multiple Web Personality Disorder
|      Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -
|      RoadSound.com - Tools For Bands, Stuff For Fans
|      Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -



Re: Help with sending custom headers in mod_perl2

Posted by Victor Danilchenko <da...@cs.umass.edu>.
	Someone (you know who you are, thanks!) helped me off-list by pointing 
out that I should use HTTP status 301 with Location header instead. In 
retrospect, it should have been obvious that the behavior I desired is 
meaningless in the context of Refresh header. D'oh.

Victor Danilchenko wrote:
> Perrin Harkins wrote:
>> On 5/2/07, Victor Danilchenko <da...@cs.umass.edu> wrote:
>>>         I seem to be missing something very obvious... I have:
>>>
>>> $r->header_out("Refresh"=>"0; URL=$uri\n");
>>
>> I think you're looking for this:
>>
>> $r->headers_out->add("Refresh"=>"0; URL=$uri\n");
> 
>     Yup, that was it. Thanks.
> 
>     Unfortunately, it worked, but it didn't help :(. Apparently neither 
> Firefox nor IE honor the Refresh HTTP header when performing the 
> XMLHttpRequest operation in JavaScript, so I will have to figure out a 
> different way to re-process the request upon error.
> 
>> You were trying to use mod_perl 1 syntax.  See this for more:
>> http://perl.apache.org/docs/2.0/user/porting/compat.html#C__r_E_gt_header_out_ 
> 
> 


Re: Help with sending custom headers in mod_perl2

Posted by Victor Danilchenko <da...@cs.umass.edu>.
Perrin Harkins wrote:
> On 5/2/07, Victor Danilchenko <da...@cs.umass.edu> wrote:
>>         I seem to be missing something very obvious... I have:
>>
>> $r->header_out("Refresh"=>"0; URL=$uri\n");
> 
> I think you're looking for this:
> 
> $r->headers_out->add("Refresh"=>"0; URL=$uri\n");

	Yup, that was it. Thanks.

	Unfortunately, it worked, but it didn't help :(. Apparently neither 
Firefox nor IE honor the Refresh HTTP header when performing the 
XMLHttpRequest operation in JavaScript, so I will have to figure out a 
different way to re-process the request upon error.

> You were trying to use mod_perl 1 syntax.  See this for more:
> http://perl.apache.org/docs/2.0/user/porting/compat.html#C__r_E_gt_header_out_ 

-- 
|  Victor  Danilchenko  | Give a man a match, and he will be warm   |
| danilche@cs.umass.edu | for a moment; but set him on fire, and    |
|   CSCF   |   5-4231   | he will be warm for the rest of his life. |

Re: Help with sending custom headers in mod_perl2

Posted by Perrin Harkins <pe...@elem.com>.
On 5/2/07, Victor Danilchenko <da...@cs.umass.edu> wrote:
>         I seem to be missing something very obvious... I have:
>
> $r->header_out("Refresh"=>"0; URL=$uri\n");

I think you're looking for this:

$r->headers_out->add("Refresh"=>"0; URL=$uri\n");

You were trying to use mod_perl 1 syntax.  See this for more:
http://perl.apache.org/docs/2.0/user/porting/compat.html#C__r_E_gt_header_out_

- Perrin