mirror of
https://github.com/servo/servo.git
synced 2025-08-08 06:55:31 +01:00
net: use an empty body for the null body case
This commit is contained in:
parent
7d51997214
commit
3535dd7412
1 changed files with 49 additions and 54 deletions
|
@ -421,8 +421,16 @@ fn obtain_response(
|
|||
|
||||
let devtools_bytes = StdArc::new(Mutex::new(vec![]));
|
||||
|
||||
let request_body = match body {
|
||||
Some(chunk_requester) => {
|
||||
// https://url.spec.whatwg.org/#percent-encoded-bytes
|
||||
let encoded_url = url
|
||||
.clone()
|
||||
.into_url()
|
||||
.as_ref()
|
||||
.replace("|", "%7C")
|
||||
.replace("{", "%7B")
|
||||
.replace("}", "%7D");
|
||||
|
||||
let request = if let Some(chunk_requester) = body {
|
||||
// TODO: If body is a stream, append `Transfer-Encoding`/`chunked`,
|
||||
// see step 4.2 of https://fetch.spec.whatwg.org/#concept-http-network-fetch
|
||||
|
||||
|
@ -463,15 +471,15 @@ fn obtain_response(
|
|||
}),
|
||||
);
|
||||
|
||||
receiver
|
||||
},
|
||||
_ => {
|
||||
let (_sender, mut receiver) = channel(1);
|
||||
|
||||
receiver.close();
|
||||
|
||||
receiver
|
||||
},
|
||||
HyperRequest::builder()
|
||||
.method(method)
|
||||
.uri(encoded_url)
|
||||
.body(Body::wrap_stream(receiver))
|
||||
} else {
|
||||
HyperRequest::builder()
|
||||
.method(method)
|
||||
.uri(encoded_url)
|
||||
.body(Body::empty())
|
||||
};
|
||||
|
||||
context
|
||||
|
@ -489,19 +497,6 @@ fn obtain_response(
|
|||
.unwrap()
|
||||
.set_attribute(ResourceAttribute::ConnectStart(connect_start));
|
||||
|
||||
// https://url.spec.whatwg.org/#percent-encoded-bytes
|
||||
let request = HyperRequest::builder()
|
||||
.method(method)
|
||||
.uri(
|
||||
url.clone()
|
||||
.into_url()
|
||||
.as_ref()
|
||||
.replace("|", "%7C")
|
||||
.replace("{", "%7B")
|
||||
.replace("}", "%7D"),
|
||||
)
|
||||
.body(Body::wrap_stream(request_body));
|
||||
|
||||
// TODO: We currently don't know when the handhhake before the connection is done
|
||||
// so our best bet would be to set `secure_connection_start` here when we are currently
|
||||
// fetching on a HTTPS url.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue