MCPcopy Index your code
hub / github.com/googleapis/google-api-python-client / _process_response

Method _process_response

googleapiclient/http.py:1095–1129  ·  view source on GitHub ↗

Process the response from a single chunk upload. Args: resp: httplib2.Response, the response object. content: string, the content of the response. Returns: (status, body): (ResumableMediaStatus, object) The body will be None until the resu

(self, resp, content)

Source from the content-addressed store, hash-verified

1093 return self._process_response(resp, content)
1094
1095 def _process_response(self, resp, content):
1096 """Process the response from a single chunk upload.
1097
1098 Args:
1099 resp: httplib2.Response, the response object.
1100 content: string, the content of the response.
1101
1102 Returns:
1103 (status, body): (ResumableMediaStatus, object)
1104 The body will be None until the resumable media is fully uploaded.
1105
1106 Raises:
1107 googleapiclient.errors.HttpError if the response was not a 2xx or a 308.
1108 """
1109 if resp.status in [200, 201]:
1110 self._in_error_state = False
1111 return None, self.postproc(resp, content)
1112 elif resp.status == 308:
1113 self._in_error_state = False
1114 # A "308 Resume Incomplete" indicates we are not done.
1115 try:
1116 self.resumable_progress = int(resp["range"].split("-")[1]) + 1
1117 except KeyError:
1118 # If resp doesn't contain range header, resumable progress is 0
1119 self.resumable_progress = 0
1120 if "location" in resp:
1121 self.resumable_uri = resp["location"]
1122 else:
1123 self._in_error_state = True
1124 raise HttpError(resp, content, uri=self.uri)
1125
1126 return (
1127 MediaUploadProgress(self.resumable_progress, self.resumable.size()),
1128 None,
1129 )
1130
1131 def to_json(self):
1132 """Returns a JSON representation of the HttpRequest."""

Callers 1

next_chunkMethod · 0.95

Calls 3

HttpErrorClass · 0.90
MediaUploadProgressClass · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected