Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Rx extensions mapping to Alamofire response method #186

Merged
merged 1 commit into from
Jul 7, 2020

Conversation

JerryTheIntern
Copy link
Member

Use Case:
Imagine an HTTP API which returned status code 200, with an empty body.
Using responseJSON or responseData produces:

could not be serialized. Input data was nil or zero length

Just using RxAlamofire's AF.rx.request(urlRequest: urlRequest).validate() works, but if the API returns a 500, the validation doesn't actually work because the response is not yet set on the response property of the DataRequest.

It seems that API's with empty bodies aren't considered bad practice, nor discouraged by the HTTP specification.
https://softwareengineering.stackexchange.com/questions/211275/should-an-http-api-always-return-a-body

The Change
Alamofire already has an API which returns just the raw HTTPURLResponse, this PR is just creating an Rx mapping for it.

@rxswiftcommunity
Copy link

rxswiftcommunity bot commented Jul 5, 2020

Warnings
⚠️

It looks like code was changed without adding anything to the Changelog. If this is a trivial PR that doesn't need a changelog, add #trivial to the PR title or body.

Thanks a lot for contributing @JerryTheIntern! I've invited you to join the
RxSwiftCommunity GitHub organization – no pressure to accept! If you'd like
more information on what this means, check out our contributor guidelines
and feel free to reach out with any questions.

Generated by 🚫 dangerJS

@rynecheow rynecheow merged commit c04ea5b into RxSwiftCommunity:master Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants