aboutsummaryrefslogtreecommitdiffstats
path: root/components/net_traits/request.rs
diff options
context:
space:
mode:
authorCYBAI <cyb.ai.815@gmail.com>2020-06-07 12:31:48 +0900
committerCYBAI <cyb.ai.815@gmail.com>2020-06-13 21:22:09 +0900
commit63aab1b355d1ae0a40471d4259d5021c5bd02e1b (patch)
tree70dec84ee14df3506bf0c814a7b6c56e926e5b5f /components/net_traits/request.rs
parent9798373d5e27ab10645a230c08262d3675d3338e (diff)
downloadservo-63aab1b355d1ae0a40471d4259d5021c5bd02e1b.tar.gz
servo-63aab1b355d1ae0a40471d4259d5021c5bd02e1b.zip
Avoid sending a new chunk when the body is already done
As discussed in https://github.com/servo/servo/issues/26807#issuecomment-640151804, we'd like to add a new flag, `in_memory_done`, to `TransmitBodyConnectHandler` so that we can correctly finish and drop the sender correctly. When we send the bytes, we will mark the body as done and we can recognize it's already done in next tick so that we can send a Done request to finish the sender. Also, when there comes a redirect request, it will go to `re-extract` route, we can set the `done` flag to `false` which means we won't stop the IPC routers yet. Then, if the re-extract sent its bytes, we will be marked as done again so that we can finish with stopping the IPC routes when Chunk request comes.
Diffstat (limited to 'components/net_traits/request.rs')
-rw-r--r--components/net_traits/request.rs7
1 files changed, 2 insertions, 5 deletions
diff --git a/components/net_traits/request.rs b/components/net_traits/request.rs
index 27b9274a6dd..f80b82b0fca 100644
--- a/components/net_traits/request.rs
+++ b/components/net_traits/request.rs
@@ -117,7 +117,7 @@ pub enum ParserMetadata {
}
/// <https://fetch.spec.whatwg.org/#concept-body-source>
-#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)]
+#[derive(Clone, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]
pub enum BodySource {
Null,
Object,
@@ -178,10 +178,7 @@ impl RequestBody {
}
pub fn source_is_null(&self) -> bool {
- if let BodySource::Null = self.source {
- return true;
- }
- false
+ self.source == BodySource::Null
}
pub fn len(&self) -> Option<usize> {