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

Bring some sanity to request parsing and error handling #2335

Merged
merged 2 commits into from May 29, 2019

Conversation

@isiahmeadows
Copy link
Member

@isiahmeadows isiahmeadows commented Dec 10, 2018

Description

  • The browser can do JSON parsing itself. Let's defer to that where possible. (A few IE hacks are required here, though.)
  • Don't propagate any error that occurs before deserialize/extract.
  • Allow sending raw array buffers/blobs/etc. to deserialize.
  • Align behavior more closely with the XHR spec.
  • Send the more useful parsed response to deserialize, not the less useful string response.

Motivation and Context

Fixes #2333
Edit: Fixes #2313

Here's why I included more breaking changes:

  1. I wanted to not hard-code all the possible values for responseType.
  2. I noticed that XHR has had this convenient responseType: "json" feature for a while and that it's fully integrated with response, and thought that could simplify our end a little.
  3. I didn't want to slap on yet another band-aid, especially when the docs were already starting to show signs of it being covered in them.

How Has This Been Tested?

Ran all the tests and updated them as appropriate. I updated a mock, but the tests for them didn't really need updated.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation change

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated docs/change-log.md
@isiahmeadows isiahmeadows added this to the 2.0.0 milestone Dec 10, 2018
@isiahmeadows isiahmeadows requested a review from Dec 10, 2018
@project-bot project-bot bot added this to Needs triage in Triage/bugs Dec 10, 2018
@isiahmeadows isiahmeadows force-pushed the request-response-type-fix branch from 37bd8ac to c2b1eb7 Dec 10, 2018
@isiahmeadows isiahmeadows moved this from Needs triage to Low priority in Triage/bugs Dec 11, 2018
@isiahmeadows
Copy link
Member Author

@isiahmeadows isiahmeadows commented Dec 30, 2018

@MithrilJS/collaborators Could I get a review here?

Loading

@isiahmeadows isiahmeadows requested review from barneycarroll and StephanHoyer and removed request for Feb 1, 2019
@isiahmeadows isiahmeadows force-pushed the request-response-type-fix branch from c2b1eb7 to 1ce2376 Feb 7, 2019
@isiahmeadows isiahmeadows force-pushed the request-response-type-fix branch 3 times, most recently from 4999b46 to 42002f4 Mar 2, 2019
docs/request.md Outdated Show resolved Hide resolved
Loading
@isiahmeadows
Copy link
Member Author

@isiahmeadows isiahmeadows commented Apr 3, 2019

@StephanHoyer Anything else stick out to you?

Loading

request/request.js Show resolved Hide resolved
Loading
@isiahmeadows isiahmeadows removed the request for review from barneycarroll May 12, 2019
isiahmeadows and others added 2 commits May 29, 2019
- The browser can do JSON parsing itself. Let's defer to that where
  possible. (A few IE hacks are required here, though.)
- Don't propagate any error that occurs before `deserialize`/`extract`.
- Allow sending raw array buffers/blobs/etc. to `deserialize`.
- Align behavior more closely with the XHR spec.
- Send the more useful parsed response to `deserialize`, not the less
  useful string response.
Co-Authored-By: isiahmeadows <contact@isiahmeadows.com>
@isiahmeadows isiahmeadows force-pushed the request-response-type-fix branch from cf9f4ab to b814567 May 29, 2019
@isiahmeadows
Copy link
Member Author

@isiahmeadows isiahmeadows commented May 29, 2019

Merging as per private discussion with @StephanHoyer.

Loading

@isiahmeadows isiahmeadows merged commit 794e8e9 into MithrilJS:next May 29, 2019
1 check passed
Loading
Triage/bugs automation moved this from Low priority to Closed May 29, 2019
@isiahmeadows isiahmeadows deleted the request-response-type-fix branch May 29, 2019
@isiahmeadows isiahmeadows restored the request-response-type-fix branch May 29, 2019
@isiahmeadows isiahmeadows deleted the request-response-type-fix branch May 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked issues

Successfully merging this pull request may close these issues.

3 participants