-
Notifications
You must be signed in to change notification settings - Fork 3k
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
refactor(ajax): Move to simple Observable implementation. Fix errors. #5661
refactor(ajax): Move to simple Observable implementation. Fix errors. #5661
Conversation
5215f64
to
37a8d3c
Compare
322c879
to
2f95d73
Compare
As I'm going through the backlog of issues, I keep finding stuff related to ajax, so I've added a couple more commits to fix another (nasty) issue. |
This also seems to need an API guardian update. |
The API guardian is killing me. It seems like there's an issue where you have to rebase, THEN update api_guardian before it actually works. This is the third PR where I've had issues. The thing it's complaining about is unrelated to the PR. |
2f95d73
to
7db988d
Compare
- Also ensures x-requested-with header is set properly - Adds comments - Code clean up - Normalize headers to be lowercase, since they are case insensitive. - Updates tests - Remove superfluous checks in unsubscribe resolves ReactiveX#2801
- Refactors `ajax` to use a simple `Observable` implementation. - Moves code to a new ajax-specific folder. - Adds a lot more documentation to classes and support classes. - Differentiates between the configuration passed to `ajax` (`AjaxConfig`) and the request values used to make the HTTP request (`AjaxRequest`), as the latter has more required values. - Ensures that no configuration values are mutated while making the request. - Ensures there is at least one valid test for `ajax.patch`. The old one was sketchy. - Adds better comments throughout the code. - Adds better typing to `ajax` functions. BREAKING CHANGE: For TypeScript users, `AjaxRequest` is no longer the type that should be explicitly used to create an `ajax`. It is now `AjaxConfig`, although the two types are compatible, only `AjaxConfig` has `progressSubscriber` and `createXHR`.
…pe where possible - Ajax will now allow default behavior as defined in the specs: - https://xhr.spec.whatwg.org/#the-send()-method - https://fetch.spec.whatwg.org/#concept-bodyinit-extract - if the `body` is set to: `Blob`, `ArrayBuffer`, any array buffer view (like a byte sequence, e.g. `Uint8Array`, etc), `FormData`, `URLSearchParams`, `string`, or `ReadableStream`, default handling is use. If the `body` is otherwise `typeof` `"object"`, then it will be converted to JSON via `JSON.stringify`, and the `Content-Type` header will be set to `application/json;charset=utf-8`. All other types will emit an error. - Updates tests. - Puts the behavior in-line with Axios, et al. resolves ReactiveX#2837 BREAKING CHANGE: `ajax` body serialization will now use default XHR behavior in all cases. If the body is a `Blob`, `ArrayBuffer`, any array buffer view (like a byte sequence, e.g. `Uint8Array`, etc), `FormData`, `URLSearchParams`, `string`, or `ReadableStream`, default handling is use. If the `body` is otherwise `typeof` `"object"`, then it will be converted to JSON via `JSON.stringify`, and the `Content-Type` header will be set to `application/json;charset=utf-8`. All other types will emit an error. BREAKING CHANGE: The `Content-Type` header passed to `ajax` configuration no longer has any effect on the serialization behavior of the AJAX request.
7db988d
to
68aa003
Compare
ajax
to use a simpleObservable
implementation.ajax
(AjaxConfig
) and the request values used to make the HTTP request (AjaxRequest
), as the latter has more required values.ajax.patch
. The old one was sketchy.ajax
functions.body
is set to:Blob
,ArrayBuffer
, any array buffer view (like a byte sequence, e.g.Uint8Array
, etc),FormData
,URLSearchParams
,string
, orReadableStream
, default handling is use. If thebody
is otherwisetypeof
"object"
, then it will be converted to JSON viaJSON.stringify
, and theContent-Type
header will be set toapplication/json;charset=utf-8
. All other types will emit an error. (resolves AJAX Content-Type Handling. #2837)BREAKING CHANGE: For TypeScript users,
AjaxRequest
is no longer the type that should be explicitly used to create anajax
. It is nowAjaxConfig
, although the two types are compatible, onlyAjaxConfig
hasprogressSubscriber
andcreateXHR
.BREAKING CHANGE:
ajax
body serialization will now use default XHR behavior in all cases. If the body is aBlob
,ArrayBuffer
, any array buffer view (like a byte sequence, e.g.Uint8Array
, etc),FormData
,URLSearchParams
,string
, orReadableStream
, default handling is use. If thebody
is otherwisetypeof
"object"
, then it will be converted to JSON viaJSON.stringify
, and theContent-Type
header will be set toapplication/json;charset=utf-8
. All other types will emit an error.BREAKING CHANGE: The
Content-Type
header passed toajax
configuration no longer has any effect on the serialization behavior of the AJAX request.