aboutsummaryrefslogtreecommitdiffstats
path: root/components/net_traits/request.rs
diff options
context:
space:
mode:
authorGregory Terzian <gterzian@users.noreply.github.com>2020-06-11 01:02:03 +0800
committerGregory Terzian <gterzian@users.noreply.github.com>2020-06-12 11:58:17 +0800
commit24a04373eb91b0f093da4eb6bfd4be8fb23ae559 (patch)
tree0a394d95ee5246015ebd1a24fe90c983310bd7c1 /components/net_traits/request.rs
parent33e96e95677c5c1a5d49fece4016b7acf1d7594b (diff)
downloadservo-24a04373eb91b0f093da4eb6bfd4be8fb23ae559.tar.gz
servo-24a04373eb91b0f093da4eb6bfd4be8fb23ae559.zip
net: fix re-extracting stream upon re-direct
Diffstat (limited to 'components/net_traits/request.rs')
-rw-r--r--components/net_traits/request.rs29
1 files changed, 12 insertions, 17 deletions
diff --git a/components/net_traits/request.rs b/components/net_traits/request.rs
index 7af3855720d..27b9274a6dd 100644
--- a/components/net_traits/request.rs
+++ b/components/net_traits/request.rs
@@ -142,8 +142,6 @@ pub struct RequestBody {
/// Net's channel to communicate with script re this body.
#[ignore_malloc_size_of = "Channels are hard"]
chan: IpcSender<BodyChunkRequest>,
- /// Has the stream been read from already?
- read_from: bool,
/// <https://fetch.spec.whatwg.org/#concept-body-source>
source: BodySource,
/// <https://fetch.spec.whatwg.org/#concept-body-total-bytes>
@@ -160,25 +158,22 @@ impl RequestBody {
chan,
source,
total_bytes,
- read_from: false,
}
}
- pub fn take_stream(&mut self) -> IpcSender<BodyChunkRequest> {
- if self.read_from {
- match self.source {
- BodySource::Null => panic!(
- "Null sources should never be read more than once(no re-direct allowed)."
- ),
- BodySource::Object => {
- let (chan, port) = ipc::channel().unwrap();
- let _ = self.chan.send(BodyChunkRequest::Extract(port));
- self.chan = chan.clone();
- return chan;
- },
- }
+ /// Step 12 of https://fetch.spec.whatwg.org/#concept-http-redirect-fetch
+ pub fn extract_source(&mut self) {
+ match self.source {
+ BodySource::Null => panic!("Null sources should never be re-directed."),
+ BodySource::Object => {
+ let (chan, port) = ipc::channel().unwrap();
+ let _ = self.chan.send(BodyChunkRequest::Extract(port));
+ self.chan = chan.clone();
+ },
}
- self.read_from = true;
+ }
+
+ pub fn take_stream(&mut self) -> IpcSender<BodyChunkRequest> {
self.chan.clone()
}