RawDeserializer Class
- Inheritance
-
RawDeserializer
Constructor
RawDeserializer()
Methods
| deserialize_from_http_generics |
Deserialize from HTTP response. Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type" |
| deserialize_from_text |
Decode data according to content-type. Accept a stream of data as well, but will be load at once in memory for now. If no content-type, will return the string version (not bytes, not stream) |
| on_response |
Extract data from the body of a REST response object. This will load the entire payload in memory. Will follow Content-Type to parse. We assume everything is UTF8 (BOM acceptable). |
deserialize_from_http_generics
Deserialize from HTTP response.
Use bytes and headers to NOT use any requests/aiohttp or whatever specific implementation. Headers will tested for "content-type"
deserialize_from_http_generics(body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any
Parameters
- cls
- body_bytes
- headers
deserialize_from_text
Decode data according to content-type.
Accept a stream of data as well, but will be load at once in memory for now.
If no content-type, will return the string version (not bytes, not stream)
deserialize_from_text(data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any
Parameters
Input, could be bytes or stream (will be decoded with UTF8) or text
- content_type
on_response
Extract data from the body of a REST response object.
This will load the entire payload in memory.
Will follow Content-Type to parse. We assume everything is UTF8 (BOM acceptable).
on_response(request: Request, response: Response, **kwargs: Any) -> None
Parameters
- raw_data
Data to be processed.
- content_type
How to parse if raw_data is a string/bytes.
Exceptions
If JSON is requested and parsing is impossible.
If bytes is not UTF8
If bytes is not valid XML
Attributes
CONTEXT_NAME
CONTEXT_NAME = 'deserialized_data'
JSON_REGEXP
JSON_REGEXP = re.compile('^(application|text)/([a-z+.]+\\+)?json$')
Feedback
Submit and view feedback for