MCPcopy Index your code
hub / github.com/aws/aws-cli / AWSResponse

Class AWSResponse

awscli/botocore/awsrequest.py:536–582  ·  view source on GitHub ↗

A data class representing an HTTP response. This class was originally inspired by requests.models.Response, but has been boiled down to meet the specific use cases in botocore. This has effectively been reduced to a named tuple. :ivar url: The full url. :ivar status_code: The s

Source from the content-addressed store, hash-verified

534
535
536class AWSResponse:
537 """A data class representing an HTTP response.
538
539 This class was originally inspired by requests.models.Response, but has
540 been boiled down to meet the specific use cases in botocore. This has
541 effectively been reduced to a named tuple.
542
543 :ivar url: The full url.
544 :ivar status_code: The status code of the HTTP response.
545 :ivar headers: The HTTP headers received.
546 :ivar body: The HTTP response body.
547 """
548
549 def __init__(self, url, status_code, headers, raw):
550 self.url = url
551 self.status_code = status_code
552 self.headers = HeadersDict(headers)
553 self.raw = raw
554
555 self._content = None
556
557 @property
558 def content(self):
559 """Content of the response as bytes."""
560
561 if self._content is None:
562 # Read the contents.
563 # NOTE: requests would attempt to call stream and fall back
564 # to a custom generator that would call read in a loop, but
565 # we don't rely on this behavior
566 self._content = b''.join(self.raw.stream()) or b''
567
568 return self._content
569
570 @property
571 def text(self):
572 """Content of the response as a proper text type.
573
574 Uses the encoding type provided in the reponse headers to decode the
575 response content into a proper text type. If the encoding is not
576 present in the headers, UTF-8 is used as a default.
577 """
578 encoding = botocore.utils.get_encoding_from_headers(self.headers)
579 if encoding:
580 return self.content.decode(encoding)
581 else:
582 return self.content.decode('utf-8')
583
584
585class _HeaderKey:

Callers 15

add_responseMethod · 0.90
add_responseMethod · 0.90
setUpMethod · 0.90
setUpMethod · 0.90
create_contextMethod · 0.90
_make_retry_contextMethod · 0.90
_make_retry_contextMethod · 0.90

Calls

no outgoing calls