-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update response and error response parsing (#66)
Currently when response body is a payload member, the SDK either keeps reponse intact if it has a streaming trait, or parse the body to JS object. Actually when response payload is not streaming, it is NOT always parsable(not a valid JSON or XML string). Specificly, when payload is String, we shouldn't parse it with XML or JSON parser; We should also treat Blob shape differently as we should encode the binaries into string; Only when shape is Union or Structure can we assume payload is parsable by JSON or XML parser. For some protocols, error type flag exists in error response body, then we need to collect response stream to JS object and parse the error type; For other protocols, error type flag doesn't exist in error response body, then we don't need to collect the response stream in error dispatcher. Instead, we can treat the error like normal response. So that error shape supports the same traits as normal responses like streaming, payload etc. This is done by add a new flag in Protocol generator-- isErrorCodeInBody. When it return true, it means error type flag exists in error response body, then body is parsed in errors dispatcher, and each error deser only need to deal with parsed response body in JS object format. When it returns false, it means error type can be inferred without touching response body, then error deser can access the error response intact.
- Loading branch information
1 parent
83bf329
commit 07f9273
Showing
3 changed files
with
158 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.