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

Method reset_stream

awscli/botocore/awsrequest.py:512–533  ·  view source on GitHub ↗

Resets the streaming body to it's initial position. If the request contains a streaming body (a streamable file-like object) seek to the object's initial position to ensure the entire contents of the object is sent. This is a no-op for static bytes-like body types.

(self)

Source from the content-addressed store, hash-verified

510 return fmt % (self.stream_output, self.method, self.url, self.headers)
511
512 def reset_stream(self):
513 """Resets the streaming body to it's initial position.
514
515 If the request contains a streaming body (a streamable file-like object)
516 seek to the object's initial position to ensure the entire contents of
517 the object is sent. This is a no-op for static bytes-like body types.
518 """
519 # Trying to reset a stream when there is a no stream will
520 # just immediately return. It's not an error, it will produce
521 # the same result as if we had actually reset the stream (we'll send
522 # the entire body contents again if we need to).
523 # Same case if the body is a string/bytes/bytearray type.
524
525 non_seekable_types = (bytes, str, bytearray)
526 if self.body is None or isinstance(self.body, non_seekable_types):
527 return
528 try:
529 logger.debug("Rewinding stream: %s", self.body)
530 self.body.seek(0)
531 except Exception as e:
532 logger.debug("Unable to rewind stream: %s", e)
533 raise UnseekableStreamError(stream_object=self.body)
534
535
536class AWSResponse:

Calls 2

seekMethod · 0.45