Ryan Eatmon > Net-HTTPServer-1.1.1 > Net::HTTPServer::Response

Download:
Net-HTTPServer-1.1.1.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  7
Open  1
View/Report Bugs
Module Version: 1.0.3   Source  

NAME ^

Net::HTTPServer::Response

SYNOPSIS ^

Net::HTTPServer::Response handles formatting the response to the client.

DESCRIPTION ^

Net::HTTPServer::Response provides a nice OOP interface for easy control of headers, cookies, sessions, and/or the content that will be sent to the requesting client.

EXAMPLES ^

my $response = new Net::HTTPServer::Response();

my $response = new Net::HTTPServer::Response(code=>200, headers=>{ );

my $response = $request->Response();

METHODS ^

new(%cfg)

Given a config hash, return a server object that you can start, process, and stop. The config hash takes the options:

    body => string      - The contents of the response.
                          ( Default: "" )

    code => int         - The return code of this reponse.
                          ( Default: 200 )
                      
    cookies => hashref  - Hash reference to a set of cookies to send.
                          Most people should just use the Cookie method
                          to set these.
                          ( Default: {} )

    headers => hashref  - Hash reference to the headers to send.  Most
                          people should just use the Header method.
                          ( Default: {} )

Body([string])

Returns the current value of the response body. Sets the content of the response if a value is specified.

Clear()

Reset the body to "".

Code(int)

Returns the current value of the response code. Set the status code of the response if a value is specified.

Cookie(name[,value[,%options]])

Returns the cookie value for the specified name, or undef if it is not set. If the value is also specified, then the cookie is set to the value. The optional hash options that you can provide to the cookie are:

    domain => string   - If specified, the client will return the
                         cookie for any hostname that is part of
                         the domain.

    expires => string  - When should the cookie expire.  Must be
                         formatted according to the rules:
                             Wednesday, 30-June-2004 18:14:24 GMT
                         Optionally you can specify "now" which
                         will resolve to the current time.
                      
    path => string     - The path on the server that the client should
                         return the cookie for.

    secure => 0|1      - The client will only return the cookie over
                         an HTTPS connection.

Header(name[,value])

Returns the header value for the specified name, or undef if it is not set. If the value is specified, then the header is set to the value.

Print(arg1[,arg2,...,argN])

Appends the arguments to the end of the body.

Redirect(url)

Redirect the client to the specified URL.

Session(object)

Register the Net::HTTPServer::Session object with the response. When the server builds the actual reponse to the client it will set the appropriate cookie and save the session. If the response is created from the request object, and there was a session created from the request object then this, will be prepopulated with that session.

CaptureSTDOUT()

If you use the CGI perl module then it wants to print everything to STDOUT. CaptureSTDOUT() will put the Reponse object into a mode where it will capture all the output from the module. See ProcessSTDOUT() for more information.

ProcessSTDOUT([%args])

This will harvest all of the data printed to STDOUT and put it into the Response object via a Print() call. This will also stop monitoring STDOUT and release it. You can specify some options:

  strip_header => 0|1     - If you use the CGI module and you
                            print the headers then ProcessSTDOUT()
                            can try to strip those out.  The best
                            plan is not to print them.

See CaptureSTDOUT() for more information.

AUTHOR ^

Ryan Eatmon

COPYRIGHT ^

Copyright (c) 2003-2005 Ryan Eatmon <reatmon@mail.com>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: