Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

http::header, redirect, hyperlink send with location

by Anonymous Monk
on Mar 25, 2001 at 14:15 UTC ( #66999=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I was wondering if anyone knows how to send a HTTP::Header with a redirect or a hyperlink? Please include code if you got one; thanks.


$h = new HTTP::Headers
blah blah => "blah blah";
$url = blah blah;
print "Location: $url, $h";
something like above "which i KNOW IS WRONG"
Adam
  • Comment on http::header, redirect, hyperlink send with location

Replies are listed 'Best First'.
Re: http::header, redirect, hyperlink send with location
by Anonymous Monk on Mar 25, 2001 at 14:42 UTC
    HTTP::Headers is for http requests, but redirects are for http responses, so I'm not sure if you're trying to make a request or respond to one. If you are responding to one, you can just print each header on a seperate line before the blank line terminating the header:
    print "CustomHeader: CustomValue\n"; print "Location: $url\n\n";
Re: http::header, redirect, hyperlink send with location
by sutch (Curate) on Mar 25, 2001 at 20:55 UTC
    I've never used HTTP::Headers, instead I use HTTP::Response or CGI. Doing it with CGI is easy:

    use CGI; my $q = new CGI; print $q->redirect(-uri=>'http://blah.com/blah');
    Which returns:

    Status: 302 Moved location: http://blah.com/blah
Re: http::header, redirect, hyperlink send with location
by $CBAS (Scribe) on Mar 25, 2001 at 14:28 UTC
    I think this should do it:
    $url = "http://www.perlmonks.org/"; print "URI: $url\n\n";
Re: http::header, redirect, hyperlink send with location
by BMaximus (Chaplain) on Mar 25, 2001 at 16:59 UTC
    I looked at the man page for HTTP::headers and it isn't realy clear as to how to use it. I'm used to mod_perl and not doing cgi without it. My best guess:
    my $h = new HTTP::Headers Content_Type => 'text/html', Location => 'http://foo.com'; print $h->as_string,"\n\n";
    Since I'm assuming that your stuff is being handled by the server you only need to output a partial header. The two newlines will separate the content of the page as required. This is the best that I can do since I realy don't know what your trying to do except use HTTP::headers to do what it does best. Read the man page on how to use it. I hope I've given you a nudge in the right direction.

    BMaximus

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://66999]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2020-08-13 12:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (71 votes). Check out past polls.

    Notices?