Convert a Content-ID header value to an id. Presumes the Content-ID header conforms to the format that _id_to_header() returns. Args: header: string, Content-ID header value. Returns: The extracted id value. Raises: BatchError
(self, header)
| 1296 | return "<%s + %s>" % (self._base_id, urllib.parse.quote(id_)) |
| 1297 | |
| 1298 | def _header_to_id(self, header): |
| 1299 | """Convert a Content-ID header value to an id. |
| 1300 | |
| 1301 | Presumes the Content-ID header conforms to the format that _id_to_header() |
| 1302 | returns. |
| 1303 | |
| 1304 | Args: |
| 1305 | header: string, Content-ID header value. |
| 1306 | |
| 1307 | Returns: |
| 1308 | The extracted id value. |
| 1309 | |
| 1310 | Raises: |
| 1311 | BatchError if the header is not in the expected format. |
| 1312 | """ |
| 1313 | if header[0] != "<" or header[-1] != ">": |
| 1314 | raise BatchError("Invalid value for Content-ID: %s" % header) |
| 1315 | if "+" not in header: |
| 1316 | raise BatchError("Invalid value for Content-ID: %s" % header) |
| 1317 | base, id_ = header[1:-1].split(" + ", 1) |
| 1318 | |
| 1319 | return urllib.parse.unquote(id_) |
| 1320 | |
| 1321 | def _serialize_request(self, request): |
| 1322 | """Convert an HttpRequest object into a string. |