---
name: "Net::Amazon::S3::Response"
section: "3pm"
platform: "linux"
package: "libnet-amazon-s3-perl"
version: "0.991-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Net::Amazon::S3::Response"
---

# Net::Amazon::S3::Response(3pm)

Behaviour common to most S3 responses.

## NAME

Net::Amazon::S3::Response - Behaviour common to most S3 responses.

## VERSION

version 0.991

## SYNOPSIS

```
        package Command::Response;
        extends 'Net::Amazon::S3::Response';
        ...
        my $response = Command::Response->new (
                http_response => $http_response,
        );
```

## DESCRIPTION

Response handler base class providing functionality common to most S3 responses.

## EXTENDING

Net::Amazon::S3::Response provides methods to cache response data.

- \_data

  Read-only accessor initialized by `"_build_data"`

- \_build\_data

  Data builder, by default calls `"_parse_data"` if response is success and provides valid XML document.

- \_parse\_data

  Abstract (undefined in parent) method to be implemented by children.

## METHODS

### Constructor

Constructor accepts only one (required) parameter - `"http_response"`. It should act like HTTP::Response.

### Response classification methods

- is\_success

  True if response is a success response, false otherwise.

  Successful response may contain invalid XML.

- is\_redirect

  True if response is a redirect.

- is\_error

  True if response is an error response, false otherwise.

  Response is considered to be an error either when response code is an HTTP error (4xx or 5xx) or response content is an error XML document.

  See also "S3 Error Response" \<https://docs.aws.amazon.com/AmazonS3/latest/API/ErrorResponses.html\> for more details.

- is\_internal\_response

  True if response is generated by user agent itself (eg: Cannot connect)

- is\_xml\_content

  True if response data is a valid XML document

### Error handling

Apart error classifition Net::Amazon::S3::Response provides also common error data accessors.

Error data are available only in case of error response.

- error\_code

  Either content of `"Error/Code"` XML element or HTTP response code.

- error\_message

  Either content of `"Error/Message"` XML element or HTTP response message.

- error\_request\_id

  Content of `"Error/RequestId"` XML element if available, `"x-amz-request-id"` header if available, empty list otherwise.

- error\_resource

  Content of c\<Error/Resource\> if available, request uri otherwise.

### Common Response Headers

See "S3 Common Response Headers" \<https://docs.aws.amazon.com/AmazonS3/latest/API/RESTCommonResponseHeaders.html\> for more details.

- content\_length

  - content\_type

  - connection

  - etag

  ETag with trimmed leading/trailing quotes.

- server

  - delete\_marker

  - request\_id

  - id\_2

  - version\_id

  ### XML Document parsing

- xml\_document

  Lazy built instance of XML::LibXML.

  Available only if response is XML response and contains valid XML document.

- xpath\_context

  Lazy built instance of XML::LibXML::XPathContext.

  Available only if response is XML response and contains valid XML document

### HTTP Response methods

Further methods delegated to `"http_response"`. Refer HTTP::Response for description.

- code

  - message

  - status\_line

  - content

  - decoded\_content

  - header

  - headers

  - header\_field\_names

  ## AUTHOR

Branislav Zahradník \<barney@cpan.org\>

## COPYRIGHT AND LICENSE

This module is part of Net::Amazon::S3.

## AUTHOR

Branislav Zahradník \<barney@cpan.org\>

## COPYRIGHT AND LICENSE

This software is copyright (c) 2022 by Amazon Digital Services, Leon Brocard, Brad Fitzpatrick, Pedro Figueiredo, Rusty Conover, Branislav Zahradník.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
