fix(http1): only send 100 Continue if request body is polled
				
					
				
			Before, if a client request included an `Expect: 100-continue` header, the `100 Continue` response was sent immediately. However, this is problematic if the service is going to reply with some 4xx status code and reject the body. This change delays the automatic sending of the `100 Continue` status until the service has call `poll_data` on the request body once.
This commit is contained in:
		| @@ -74,3 +74,22 @@ pub(crate) struct Encode<'a, T> { | ||||
|     req_method: &'a mut Option<Method>, | ||||
|     title_case_headers: bool, | ||||
| } | ||||
|  | ||||
| /// Extra flags that a request "wants", like expect-continue or upgrades. | ||||
| #[derive(Clone, Copy, Debug)] | ||||
| struct Wants(u8); | ||||
|  | ||||
| impl Wants { | ||||
|     const EMPTY: Wants = Wants(0b00); | ||||
|     const EXPECT: Wants = Wants(0b01); | ||||
|     const UPGRADE: Wants = Wants(0b10); | ||||
|  | ||||
|     #[must_use] | ||||
|     fn add(self, other: Wants) -> Wants { | ||||
|         Wants(self.0 | other.0) | ||||
|     } | ||||
|  | ||||
|     fn contains(&self, other: Wants) -> bool { | ||||
|         (self.0 & other.0) == other.0 | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user