mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
net: fix re-extracting stream upon re-direct
This commit is contained in:
parent
33e96e9567
commit
24a04373eb
2 changed files with 14 additions and 19 deletions
|
@ -911,8 +911,8 @@ pub fn http_redirect_fetch(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 12
|
// Step 12
|
||||||
if let Some(_) = request.body {
|
if let Some(body) = request.body.as_mut() {
|
||||||
// TODO: extract request's body's source
|
body.extract_source();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 13
|
// Step 13
|
||||||
|
|
|
@ -142,8 +142,6 @@ pub struct RequestBody {
|
||||||
/// Net's channel to communicate with script re this body.
|
/// Net's channel to communicate with script re this body.
|
||||||
#[ignore_malloc_size_of = "Channels are hard"]
|
#[ignore_malloc_size_of = "Channels are hard"]
|
||||||
chan: IpcSender<BodyChunkRequest>,
|
chan: IpcSender<BodyChunkRequest>,
|
||||||
/// Has the stream been read from already?
|
|
||||||
read_from: bool,
|
|
||||||
/// <https://fetch.spec.whatwg.org/#concept-body-source>
|
/// <https://fetch.spec.whatwg.org/#concept-body-source>
|
||||||
source: BodySource,
|
source: BodySource,
|
||||||
/// <https://fetch.spec.whatwg.org/#concept-body-total-bytes>
|
/// <https://fetch.spec.whatwg.org/#concept-body-total-bytes>
|
||||||
|
@ -160,25 +158,22 @@ impl RequestBody {
|
||||||
chan,
|
chan,
|
||||||
source,
|
source,
|
||||||
total_bytes,
|
total_bytes,
|
||||||
read_from: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take_stream(&mut self) -> IpcSender<BodyChunkRequest> {
|
/// Step 12 of https://fetch.spec.whatwg.org/#concept-http-redirect-fetch
|
||||||
if self.read_from {
|
pub fn extract_source(&mut self) {
|
||||||
match self.source {
|
match self.source {
|
||||||
BodySource::Null => panic!(
|
BodySource::Null => panic!("Null sources should never be re-directed."),
|
||||||
"Null sources should never be read more than once(no re-direct allowed)."
|
|
||||||
),
|
|
||||||
BodySource::Object => {
|
BodySource::Object => {
|
||||||
let (chan, port) = ipc::channel().unwrap();
|
let (chan, port) = ipc::channel().unwrap();
|
||||||
let _ = self.chan.send(BodyChunkRequest::Extract(port));
|
let _ = self.chan.send(BodyChunkRequest::Extract(port));
|
||||||
self.chan = chan.clone();
|
self.chan = chan.clone();
|
||||||
return chan;
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.read_from = true;
|
|
||||||
|
pub fn take_stream(&mut self) -> IpcSender<BodyChunkRequest> {
|
||||||
self.chan.clone()
|
self.chan.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue