Re: Perl CGI Response codes other than 200 OK

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ian Burrell wrote:
Don Russell <fedora <at> drussell.dnsalias.com> writes:
I've spent most of yesterday trying to solve this by searching google...
I'm trying to use HTTP::Response to create a response when my perl cgi
program is run.


Why are you using HTTP::Response?  That is the class for representing responses
from the server in LWP, the HTTP client module.  It is not for generating
responses on the server-side.

If you are using CGI, then use the header() method.  It takes a -status option.

If you are using mod_perl, it is $r->status().  Apache2::Const for mod_perl2
contains constants for the different statuses like OK.

 - Ian
Well, it seemed reasonable to me that if HTTP::Response represented a response received from a server, then it could be used to build a response to send from a server... and if not, why do so many methods allow the changing of the response? i.e. headers may be added/removed... that doesn't sound typical for processing a response from another server...

I like how I can add headers and content as I go through my script, then finally, when everything is done, actually send the response.

I've rewritten my code to use CGI, and I can now generate the headers I want, but unless I'm misunderstanding something, there's no "container/object" that I can accumulate headers in, and then print them out later...

Or, does the CGI::header method accept a hash of all the headers I want to send?

I'm relatively new to Perl, so maybe something like "print $query->header(%all_my_headers);" will work... I just don't see that in the doc I've found so far.

I'm using HTTP::Status to get all the status codes like RC_BAD_REQUEST, RC_SERVICE_UNAVAILABLE etc.

Thanks,
Don


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux