amplify-swift
amplify-swift copied to clipboard
HTTP REST Successful Responses do not include the status code and headers
Is your feature request related to a problem? Please describe.
In February, the community opened a feature request to include the HTTP response body on > 300 status codes, found here: https://github.com/aws-amplify/amplify-ios/issues/655.
The opposite issue exists with successful requests ( statusCode in [200, 300) ).
When the API returns a failure result, I can get the response body, the status code, and the header values.
When the API returns a successful result, I can only get the response body. My application, and I'm sure many others, would benefit from the increased granularity of fully qualified HTTP status codes and header information.
Describe the solution you'd like
I would like to see the Amplify.API.<opType> methods return a callback that uses a datatype that contains the response body (current Data), the status code, and the headers. It seems like the AWSHTTPURLResponse class would be a good candidate, as this class has the public methods already available for the information I wish to consume.
Describe alternatives you've considered
I do not have any alternative recommendations at this time.
Is the feature request related to any of the existing Amplify categories?
API
Additional context
No response
This is a perfect example of why URLSession out of the box is the right choice for many developers.
I too, need to distinguish between getting different 200 status codes. It is a very bad practice to assume your json body before checking the status code.
I refuse to combine my JSON response types into a single type, and really really don't want to have nested try decode with the data in the .success(let data) path.
Closing as a duplicate in favor of:
- https://github.com/aws-amplify/amplify-swift/issues/3285
because #3285 has more engagement.