📄 http::response.3
字号:
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05).\".\" Standard preamble:.\" ========================================================================.de Sh \" Subsection heading.br.if t .Sp.ne 5.PP\fB\\$1\fR.PP...de Sp \" Vertical space (when we can't use .PP).if t .sp .5v.if n .sp...de Vb \" Begin verbatim text.ft CW.nf.ne \\$1...de Ve \" End verbatim text.ft R.fi...\" Set up some character translations and predefined strings. \*(-- will.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left.\" double quote, and \*(R" will give a right double quote. \*(C+ will.\" give a nicer C++. Capital omega is used to do unbreakable dashes and.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,.\" nothing in troff, for use with C<>..tr \(*W-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'.ie n \{\. ds -- \(*W-. ds PI pi. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch. ds L" "". ds R" "". ds C` "". ds C' ""'br\}.el\{\. ds -- \|\(em\|. ds PI \(*p. ds L" ``. ds R" '''br\}.\".\" Escape single quotes in literal strings from groff's Unicode transform..ie \n(.g .ds Aq \(aq.el .ds Aq '.\".\" If the F register is turned on, we'll generate index entries on stderr for.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index.\" entries marked with X<> in POD. Of course, you'll have to process the.\" output yourself in some meaningful fashion..ie \nF \{\. de IX. tm Index:\\$1\t\\n%\t"\\$2"... nr % 0. rr F.\}.el \{\. de IX...\}.\".\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2)..\" Fear. Run. Save yourself. No user-serviceable parts.. \" fudge factors for nroff and troff.if n \{\. ds #H 0. ds #V .8m. ds #F .3m. ds #[ \f1. ds #] \fP.\}.if t \{\. ds #H ((1u-(\\\\n(.fu%2u))*.13m). ds #V .6m. ds #F 0. ds #[ \&. ds #] \&.\}. \" simple accents for nroff and troff.if n \{\. ds ' \&. ds ` \&. ds ^ \&. ds , \&. ds ~ ~. ds /.\}.if t \{\. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u". ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'.\}. \" troff and (daisy-wheel) nroff accents.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'.ds 8 \h'\*(#H'\(*b\h'-\*(#H'.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#].ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#].ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#].ds ae a\h'-(\w'a'u*4/10)'e.ds Ae A\h'-(\w'A'u*4/10)'E. \" corrections for vroff.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'. \" for low resolution devices (crt and lpr).if \n(.H>23 .if \n(.V>19 \\{\. ds : e. ds 8 ss. ds o a. ds d- d\h'-1'\(ga. ds D- D\h'-1'\(hy. ds th \o'bp'. ds Th \o'LP'. ds ae ae. ds Ae AE.\}.rm #[ #] #H #V #F C.\" ========================================================================.\".IX Title "HTTP::Response 3".TH HTTP::Response 3 "2005-12-06" "perl v5.10.0" "User Contributed Perl Documentation".\" For nroff, turn off justification. Always turn off hyphenation; it makes.\" way too many mistakes in technical documents..if n .ad l.nh.SH "NAME"HTTP::Response \- HTTP style response message.SH "SYNOPSIS".IX Header "SYNOPSIS"Response objects are returned by the \fIrequest()\fR method of the \f(CW\*(C`LWP::UserAgent\*(C'\fR:.PP.Vb 8\& # ...\& $response = $ua\->request($request)\& if ($response\->is_success) {\& print $response\->content;\& }\& else {\& print STDERR $response\->status_line, "\en";\& }.Ve.SH "DESCRIPTION".IX Header "DESCRIPTION"The \f(CW\*(C`HTTP::Response\*(C'\fR class encapsulates \s-1HTTP\s0 style responses. Aresponse consists of a response line, some headers, and a contentbody. Note that the \s-1LWP\s0 library uses \s-1HTTP\s0 style responses even fornon-HTTP protocol schemes. Instances of this class are usuallycreated and returned by the \fIrequest()\fR method of an \f(CW\*(C`LWP::UserAgent\*(C'\fRobject..PP\&\f(CW\*(C`HTTP::Response\*(C'\fR is a subclass of \f(CW\*(C`HTTP::Message\*(C'\fR and thereforeinherits its methods. The following additional methods are available:.ie n .IP "$r\fR = HTTP::Response\->new( \f(CW$code )" 4.el .IP "\f(CW$r\fR = HTTP::Response\->new( \f(CW$code\fR )" 4.IX Item "$r = HTTP::Response->new( $code )".PD 0.ie n .IP "$r\fR = HTTP::Response\->new( \f(CW$code\fR, \f(CW$msg )" 4.el .IP "\f(CW$r\fR = HTTP::Response\->new( \f(CW$code\fR, \f(CW$msg\fR )" 4.IX Item "$r = HTTP::Response->new( $code, $msg )".ie n .IP "$r\fR = HTTP::Response\->new( \f(CW$code\fR, \f(CW$msg\fR, \f(CW$header )" 4.el .IP "\f(CW$r\fR = HTTP::Response\->new( \f(CW$code\fR, \f(CW$msg\fR, \f(CW$header\fR )" 4.IX Item "$r = HTTP::Response->new( $code, $msg, $header )".ie n .IP "$r\fR = HTTP::Response\->new( \f(CW$code\fR, \f(CW$msg\fR, \f(CW$header\fR, \f(CW$content )" 4.el .IP "\f(CW$r\fR = HTTP::Response\->new( \f(CW$code\fR, \f(CW$msg\fR, \f(CW$header\fR, \f(CW$content\fR )" 4.IX Item "$r = HTTP::Response->new( $code, $msg, $header, $content )".PDConstructs a new \f(CW\*(C`HTTP::Response\*(C'\fR object describing a response withresponse code \f(CW$code\fR and optional message \f(CW$msg\fR. The optional \f(CW$header\fRargument should be a reference to an \f(CW\*(C`HTTP::Headers\*(C'\fR object or aplain array reference of key/value pairs. The optional \f(CW$content\fRargument should be a string of bytes. The meaning these arguments aredescribed below..ie n .IP "$r\fR = HTTP::Response\->parse( \f(CW$str )" 4.el .IP "\f(CW$r\fR = HTTP::Response\->parse( \f(CW$str\fR )" 4.IX Item "$r = HTTP::Response->parse( $str )"This constructs a new response object by parsing the given string..ie n .IP "$r\->code" 4.el .IP "\f(CW$r\fR\->code" 4.IX Item "$r->code".PD 0.ie n .IP "$r\fR\->code( \f(CW$code )" 4.el .IP "\f(CW$r\fR\->code( \f(CW$code\fR )" 4.IX Item "$r->code( $code )".PDThis is used to get/set the code attribute. The code is a 3 digitnumber that encode the overall outcome of a \s-1HTTP\s0 response. The\&\f(CW\*(C`HTTP::Status\*(C'\fR module provide constants that provide mnemonic namesfor the code attribute..ie n .IP "$r\->message" 4.el .IP "\f(CW$r\fR\->message" 4.IX Item "$r->message".PD 0.ie n .IP "$r\fR\->message( \f(CW$message )" 4.el .IP "\f(CW$r\fR\->message( \f(CW$message\fR )" 4.IX Item "$r->message( $message )".PDThis is used to get/set the message attribute. The message is a shorthuman readable single line string that explains the response code..ie n .IP "$r\fR\->header( \f(CW$field )" 4.el .IP "\f(CW$r\fR\->header( \f(CW$field\fR )" 4.IX Item "$r->header( $field )".PD 0.ie n .IP "$r\fR\->header( \f(CW$field\fR => \f(CW$value )" 4.el .IP "\f(CW$r\fR\->header( \f(CW$field\fR => \f(CW$value\fR )" 4.IX Item "$r->header( $field => $value )".PDThis is used to get/set header values and it is inherited from\&\f(CW\*(C`HTTP::Headers\*(C'\fR via \f(CW\*(C`HTTP::Message\*(C'\fR. See HTTP::Headers fordetails and other similar methods that can be used to access theheaders..ie n .IP "$r\->content" 4.el .IP "\f(CW$r\fR\->content" 4.IX Item "$r->content".PD 0.ie n .IP "$r\fR\->content( \f(CW$content )" 4.el .IP "\f(CW$r\fR\->content( \f(CW$content\fR )" 4.IX Item "$r->content( $content )".PDThis is used to get/set the raw content and it is inherited from the\&\f(CW\*(C`HTTP::Message\*(C'\fR base class. See HTTP::Message for details andother methods that can be used to access the content..ie n .IP "$r\fR\->decoded_content( \f(CW%options )" 4.el .IP "\f(CW$r\fR\->decoded_content( \f(CW%options\fR )" 4.IX Item "$r->decoded_content( %options )"This will return the content after any \f(CW\*(C`Content\-Encoding\*(C'\fR andcharsets has been decoded. See HTTP::Message for details..ie n .IP "$r\->request" 4.el .IP "\f(CW$r\fR\->request" 4.IX Item "$r->request".PD 0.ie n .IP "$r\fR\->request( \f(CW$request )" 4.el .IP "\f(CW$r\fR\->request( \f(CW$request\fR )" 4.IX Item "$r->request( $request )".PDThis is used to get/set the request attribute. The request attributeis a reference to the the request that caused this response. It doesnot have to be the same request passed to the \f(CW$ua\fR\->\fIrequest()\fR method,because there might have been redirects and authorization retries inbetween..ie n .IP "$r\->previous" 4.el .IP "\f(CW$r\fR\->previous" 4.IX Item "$r->previous".PD 0.ie n .IP "$r\fR\->previous( \f(CW$response )" 4.el .IP "\f(CW$r\fR\->previous( \f(CW$response\fR )" 4.IX Item "$r->previous( $response )".PDThis is used to get/set the previous attribute. The previousattribute is used to link together chains of responses. You getchains of responses if the first response is redirect or unauthorized.The value is \f(CW\*(C`undef\*(C'\fR if this is the first response in a chain..ie n .IP "$r\->status_line" 4.el .IP "\f(CW$r\fR\->status_line" 4.IX Item "$r->status_line"Returns the string \*(L"<code> <message>\*(R". If the message attributeis not set then the official name of <code> (see HTTP::Status)is substituted..ie n .IP "$r\->base" 4.el .IP "\f(CW$r\fR\->base" 4.IX Item "$r->base"Returns the base \s-1URI\s0 for this response. The return value will be areference to a \s-1URI\s0 object..SpThe base \s-1URI\s0 is obtained from one the following sources (in priorityorder):.RS 4.IP "1." 4Embedded in the document content, for instance <\s-1BASE\s0 HREF=\*(L"...\*(R">in \s-1HTML\s0 documents..IP "2." 4A \*(L"Content-Base:\*(R" or a \*(L"Content-Location:\*(R" header in the response..SpFor backwards compatibility with older \s-1HTTP\s0 implementations we willalso look for the \*(L"Base:\*(R" header..IP "3." 4The \s-1URI\s0 used to request this response. This might not be the original\&\s-1URI\s0 that was passed to \f(CW$ua\fR\->\fIrequest()\fR method, because we might havereceived some redirect responses first..RE.RS 4.SpIf neither of these sources provide an absolute \s-1URI\s0, undef isreturned..SpWhen the \s-1LWP\s0 protocol modules produce the HTTP::Response object, thenany base \s-1URI\s0 embedded in the document (step 1) will already haveinitialized the \*(L"Content-Base:\*(R" header. This means that this methodonly performs the last 2 steps (the content is not always availableeither)..RE.ie n .IP "$r\->as_string" 4.el .IP "\f(CW$r\fR\->as_string" 4.IX Item "$r->as_string".PD 0.ie n .IP "$r\fR\->as_string( \f(CW$eol )" 4.el .IP "\f(CW$r\fR\->as_string( \f(CW$eol\fR )" 4.IX Item "$r->as_string( $eol )".PDReturns a textual representation of the response..ie n .IP "$r\->is_info" 4.el .IP "\f(CW$r\fR\->is_info" 4.IX Item "$r->is_info".PD 0.ie n .IP "$r\->is_success" 4.el .IP "\f(CW$r\fR\->is_success" 4.IX Item "$r->is_success".ie n .IP "$r\->is_redirect" 4.el .IP "\f(CW$r\fR\->is_redirect" 4.IX Item "$r->is_redirect".ie n .IP "$r\->is_error" 4.el .IP "\f(CW$r\fR\->is_error" 4.IX Item "$r->is_error".PDThese methods indicate if the response was informational, successful, aredirection, or an error. See HTTP::Status for the meaning of these..ie n .IP "$r\->error_as_HTML" 4.el .IP "\f(CW$r\fR\->error_as_HTML" 4.IX Item "$r->error_as_HTML"Returns a string containing a complete \s-1HTML\s0 document indicating whaterror occurred. This method should only be called when \f(CW$r\fR\->is_erroris \s-1TRUE\s0..ie n .IP "$r\->current_age" 4.el .IP "\f(CW$r\fR\->current_age" 4.IX Item "$r->current_age"Calculates the \*(L"current age\*(R" of the response as specified by \s-1RFC\s0 2616section 13.2.3. The age of a response is the time since it was sentby the origin server. The returned value is a number representing theage in seconds..ie n .IP "$r\->freshness_lifetime" 4.el .IP "\f(CW$r\fR\->freshness_lifetime" 4.IX Item "$r->freshness_lifetime"Calculates the \*(L"freshness lifetime\*(R" of the response as specified by\&\s-1RFC\s0 2616 section 13.2.4. The \*(L"freshness lifetime\*(R" is the length oftime between the generation of a response and its expiration time.The returned value is a number representing the freshness lifetime inseconds..SpIf the response does not contain an \*(L"Expires\*(R" or a \*(L"Cache-Control\*(R"header, then this function will apply some simple heuristic based on\&'Last\-Modified' to determine a suitable lifetime..ie n .IP "$r\->is_fresh" 4.el .IP "\f(CW$r\fR\->is_fresh" 4.IX Item "$r->is_fresh"Returns \s-1TRUE\s0 if the response is fresh, based on the values of\&\fIfreshness_lifetime()\fR and \fIcurrent_age()\fR. If the response is no longerfresh, then it has to be refetched or revalidated by the originserver..ie n .IP "$r\->fresh_until" 4.el .IP "\f(CW$r\fR\->fresh_until" 4.IX Item "$r->fresh_until"Returns the time when this entity is no longer fresh..SH "SEE ALSO".IX Header "SEE ALSO"HTTP::Headers, HTTP::Message, HTTP::Status, HTTP::Request.SH "COPYRIGHT".IX Header "COPYRIGHT"Copyright 1995\-2004 Gisle Aas..PPThis library is free software; you can redistribute it and/ormodify it under the same terms as Perl itself.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -