Namespace
Google \ ApiCore \ Transport \ RestMethods
__construct
JsonStreamDecoder is a HTTP-JSON response stream decoder for JSON-ecoded protobuf messages. The response stream must be a JSON array, where the first byte is the opening of the array (i.e. '['), and the last byte is the closing of the array (i.e. ']'). Each array item must be a JSON object and comma separated.
Parameters | |
---|---|
Name | Description |
stream |
Psr\Http\Message\StreamInterface
The stream to decode. |
decodeType |
string
The type name of response messages to decode. |
options |
array
An array of optional arguments. |
↳ ignoreUnknown |
bool
Toggles whether or not to throw an exception when an unknown field is encountered in a response message. The default is true. |
↳ readChunkSizeBytes |
int
The upper size limit in bytes that can be read at a time from the response stream. The default is 1 KB. |
decode
Begins decoding the configured response stream. It is a generator which yields messages of the given decode type from the stream until the stream completes. Throws an Exception if the stream is closed before the closing byte is read or if it encounters an error while decoding a message.
Returns | |
---|---|
Type | Description |
Generator |
close
Closes the underlying stream. If the stream is actively being decoded, an exception will not be thrown due to the interruption.
Returns | |
---|---|
Type | Description |
void |
Constants
ESCAPE_CHAR
Value: '\\'