parameters: (self, start, additional_headers=None)
return_statement: return self.__SendMediaRequest(request, end)
docstring: Send the specified chunk.
docstring_summary: Send the specified chunk.
docstring_tokens: Send the specified chunk .
function: def __SendChunk(self, start, additional_headers=None):
          """Send the specified chunk."""
          self.EnsureInitialized()
          no_log_body = self.total_size is None
          if self.total_size is None:
              # For the streaming resumable case, we need to detect when
              # we're at the end of the stream.
              body_stream = buffered_stream.BufferedStream(
                  self.stream, start, self.chunksize)
              end = body_stream.stream_end_position
              if body_stream.stream_exhausted:
                  self.__total_size = end
              # TODO: Here, change body_stream from a stream to a string object,
              # which means reading a chunk into memory.  This works around
              # https://code.google.com/p/httplib2/issues/detail?id=176 which can
              # cause httplib2 to skip bytes on 401's for file objects.
              # Rework this solution to be more general.
              body_stream = body_stream.read(self.chunksize)
          else:
              end = min(start + self.chunksize, self.total_size)
              body_stream = stream_slice.StreamSlice(self.stream, end - start)
          # TODO(craigcitro): Think about clearer errors on "no data in
          # stream".
          request = http_wrapper.Request(url=self.url, http_method='PUT',
                                         body=body_stream)
          request.headers['Content-Type'] = self.mime_type
          if no_log_body:
              # Disable logging of streaming body.
              # TODO: Remove no_log_body and rework as part of a larger logs
              # refactor.
              request.loggable_body = '<media body>'
          if self.total_size is None:
              # Streaming resumable upload case, unknown total size.
              range_string = 'bytes %s-%s/*' % (start, end - 1)
          elif end == start:
              # End of an upload with 0 bytes left to send; just finalize.
              range_string = 'bytes */%s' % self.total_size
          else:
              # Normal resumable upload case with known sizes.
              range_string = 'bytes %s-%s/%s' % (start, end - 1, self.total_size)
  
          request.headers['Content-Range'] = range_string
          if additional_headers:
              request.headers.update(additional_headers)
  
          return self.__SendMediaRequest(request, end)
function_tokens: def __SendChunk ( self , start , additional_headers = None ) : self . EnsureInitialized ( ) no_log_body = self . total_size is None if self . total_size is None : # For the streaming resumable case, we need to detect when # we're at the end of the stream. body_stream = buffered_stream . BufferedStream ( self . stream , start , self . chunksize ) end = body_stream . stream_end_position if body_stream . stream_exhausted : self . __total_size = end # TODO: Here, change body_stream from a stream to a string object, # which means reading a chunk into memory.  This works around # https://code.google.com/p/httplib2/issues/detail?id=176 which can # cause httplib2 to skip bytes on 401's for file objects. # Rework this solution to be more general. body_stream = body_stream . read ( self . chunksize ) else : end = min ( start + self . chunksize , self . total_size ) body_stream = stream_slice . StreamSlice ( self . stream , end - start ) # TODO(craigcitro): Think about clearer errors on "no data in # stream". request = http_wrapper . Request ( url = self . url , http_method = 'PUT' , body = body_stream ) request . headers [ 'Content-Type' ] = self . mime_type if no_log_body : # Disable logging of streaming body. # TODO: Remove no_log_body and rework as part of a larger logs # refactor. request . loggable_body = '<media body>' if self . total_size is None : # Streaming resumable upload case, unknown total size. range_string = 'bytes %s-%s/*' % ( start , end - 1 ) elif end == start : # End of an upload with 0 bytes left to send; just finalize. range_string = 'bytes */%s' % self . total_size else : # Normal resumable upload case with known sizes. range_string = 'bytes %s-%s/%s' % ( start , end - 1 , self . total_size ) request . headers [ 'Content-Range' ] = range_string if additional_headers : request . headers . update ( additional_headers ) return self . __SendMediaRequest ( request , end )