.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" Standard preamble: .\" ======================================================================== .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 (.SS), 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 "DAV::Response 3pm" .TH DAV::Response 3pm "2009-09-13" "perl v5.14.2" "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::DAV::Response \- represents a WebDAV HTTP Response (ala HTTP::Response) .SH "SYNOPSIS" .IX Header "SYNOPSIS" require HTTP::DAV::Response; .SH "DESCRIPTION" .IX Header "DESCRIPTION" The HTTP::DAV::Response class encapsulates \s-1HTTP\s0 style responses. A response consists of a response line, some headers, and (potentially empty) content. .PP HTTP::DAV::Response is a subclass of \f(CW\*(C`HTTP::Response\*(C'\fR and therefore inherits its methods. (HTTP::Response in turn inherits it's methods from \f(CW\*(C`HTTP::Message\*(C'\fR). .PP Therefore, this class actually inherits a rich library of functions. You are more likely wanting to read the \f(CW\*(C`HTTP::Response\*(C'\fR class as opposed to this class. .PP Instances of this class are usually created by a \f(CW\*(C`HTTP::DAV::Resource\*(C'\fR object after it has performed some request (such as get, lock, delete, etc). You use the object to analyse the success or otherwise of the request. .PP HTTP::DAV::Response was created to handle two extra functions that normal \s-1HTTP\s0 Responses don't require: .PP .Vb 1 \& \- WebDAV reponses have 6 extra error codes: 102, 207, 422, 423, 424 and 507. Older versions of the LWP\*(Aqs C class did not have these extra codes. These were added. \& \& \- WebDAV responses can actually contain more than one response (and often DO contain more than one) in the form of a "Multistatus". These multistatus responses come in the form of an XML document. HTTP::DAV::Response can accurately parse these XML responses and emulate the normal of the C. .Ve .PP HTTP::DAV::Response transparently implements these extra features without the user having to be aware, so you really should be reading the \f(CW\*(C`HTTP::Response\*(C'\fR documentation for most of the things you want to do (have I already said that?). .PP There are only a handful of custom functions that HTTP::DAV::Response returns and those are to handle multistatus requests, \f(CW\*(C`messages()\*(C'\fR and \f(CW\*(C`codes()\*(C'\fR. .PP The six extra status codes that \s-1DAV\s0 servers can be returned in an \s-1HTTP\s0 Response are: 102 => \*(L"Processing. Server has accepted the request, but has not yet completed it\*(R", 207 => \*(L"Multistatus\*(R", 422 => \*(L"Unprocessable Entity. Bad client \s-1XML\s0 sent?\*(R", 423 => \*(L"Locked. The source or destination resource is locked\*(R", 424 => \*(L"Failed Dependency\*(R", 507 => \*(L"Insufficient Storage. The server is unable to store the request\*(R", .PP See \f(CW\*(C`HTTP::Status\*(C'\fR for the rest. .SH "HANDLING A MULTISTATUS" .IX Header "HANDLING A MULTISTATUS" So, many \s-1DAV\s0 requests may return a multistatus (\*(L"207 multistatus\*(R") instead of, say, \*(L"200 \s-1OK\s0\*(R" or \*(L"403 Forbidden\*(R". .PP The HTTP::DAV::Response object stores each \*(L"response\*(R" sent back in the multistatus. You access them by array number. .PP The following code snippet shows what you will normally want to do: .PP \&... \&\f(CW$response\fR = \f(CW$resource\fR\->\fIlock()\fR; .PP if ( \f(CW$response\fR\->\fIis_multistatus()\fR ) { .PP .Vb 6 \& foreach $num ( 0 .. $response\->response_count() ) { \& ($err_code,$mesg,$url,$desc) = \& $response\->response_bynum($num); \& print "$mesg ($err_code) for $url\en"; \& } \&} .Ve .PP Would produce something like this: Failed Dependency (424) for /test/directory Locked (423) for /test/directory/file3 .PP This says that we couldn't lock /test/directory because file3 which exists inside is already locked by somebody else. .SH "METHODS" .IX Header "METHODS" .IP "\fBis_multistatus\fR" 4 .IX Item "is_multistatus" This function takes no arguments and returns a 1 or a 0. .Sp For example: if ($response\->\fIis_multistatus()\fR ) { } .Sp If the \s-1HTTP\s0 reply had \*(L"207 Multistatus\*(R" in the header then that indicates that there are multiple status messages in the \s-1XML\s0 content that was returned. .Sp In this event, you may be interested in knowing what the individual messages were. To do this you would then use \f(CW\*(C`messages\*(C'\fR. .IP "\fBresponse_count\fR" 4 .IX Item "response_count" Takes no arguments and returns \*(L"the number of error responses \-1\*(R" that we got. Why \-1? Because usually you will want to use this like an array operator: .Sp foreach \f(CW$num\fR ( 0 .. \f(CW$response\fR\->\fIresponse_count()\fR ) { print \f(CW$response\fR\->\fImessage_bynum()\fR; } .IP "\fBresponse_bynum\fR" 4 .IX Item "response_bynum" Takes one argument, the \*(L"response number\*(R" that you're interested in. And returns an array of details: .Sp .Vb 1 \& ($code,$message,$url,$description) = response_bynum(2); .Ve .Sp where \f(CW$code\fR \- is the \s-1HTTP\s0 error code (e.g. 403, 423, etc). \f(CW$message\fR \- is the associated message for that error code. \f(CW$url\fR \- is the url that this error applies to (recall that there can be multiple responses within one response and they all relate to one \s-1URL\s0) \f(CW$description\fR \- is server's attempt at an english description of what happened. .IP "\fBcode_bynum\fR" 4 .IX Item "code_bynum" Takes one argument, the \*(L"response number\*(R" that you're interested in, and returns it's code. E.g: .Sp .Vb 1 \& $code = $response\->code_bynum(1); .Ve .Sp See \f(CW\*(C`response_bynum()\*(C'\fR .IP "\fBmessage_bynum\fR" 4 .IX Item "message_bynum" Takes one argument, the \*(L"response number\*(R" that you're interested in, and returns it's message. E.g: .Sp .Vb 1 \& $code = $response\->message_bynum(1); .Ve .Sp See \f(CW\*(C`response_bynum()\*(C'\fR .IP "\fBurl_bynum\fR" 4 .IX Item "url_bynum" Takes one argument, the \*(L"response number\*(R" that you're interested in, and returns it's url. E.g: .Sp .Vb 1 \& $code = $response\->message_bynum(1); .Ve .Sp See \f(CW\*(C`response_bynum()\*(C'\fR .IP "\fBdescription_bynum\fR" 4 .IX Item "description_bynum" Takes one argument, the \*(L"response number\*(R" that you're interested in, and returns it's description. E.g: .Sp .Vb 1 \& $code = $response\->message_description(1); .Ve .Sp See \f(CW\*(C`response_bynum()\*(C'\fR .IP "\fBmessages\fR" 4 .IX Item "messages" Takes no arguments and returns all of the messages returned in a multistatus response. If called in a scalar context then all of the messages will be returned joined together by newlines. If called in an array context the messages will be returned as an array. .Sp \&\f(CW$messages\fR = \f(CW$response\fR\->\fImessages()\fR; e.g. \f(CW$messages\fR eq \*(L"Forbidden\enLocked\*(R"; .Sp \&\f(CW@messages\fR = \f(CW$response\fR\->\fImessages()\fR; e.g. \f(CW@messages\fR eq [\*(L"Forbidden\*(R", \*(L"Locked\*(R"]; .Sp This routine is a variant on the standard \f(CW\*(C`HTTP::Response\*(C'\fR \f(CW\*(C`message()\*(C'\fR.