-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Currently, reqwest uses serde in three places that are not behind feature flags:
- Request query parameters
query<T> - Request form data
form<T> - WASM header parsing
It would be nice to make serde usage entirely optional.
The two request methods could be moved to optional (enabled by default) features query, form.
And the WASM parsing could be replaced with native JS methods.
There's been asks in the past to change the behavior of the query/form methods:
This would at least provide an option to disable those built-in APIs.
For the WASM usage, the current approach converts headers to JSON, then parses them with serde_json, in order to extract them as strings.
I imagine there's a simpler way to do that without reaching for serde.
Lines 264 to 269 in da0702b
| let serialized_headers: String = JSON::stringify(&item) | |
| .expect_throw("serialized headers") | |
| .into(); | |
| let [name, value]: [String; 2] = serde_json::from_str(&serialized_headers) | |
| .expect_throw("deserializable serialized headers"); | |
| resp = resp.header(&name, &value); |
Note that serde would still be pulled in as a transitive dependency through url due to a bug.
But that should be resolved once servo/rust-url#1071 is released.