feat(http1): Add higher-level HTTP upgrade support to Client and Server (#1563)
- Adds `Body::on_upgrade()` that returns an `OnUpgrade` future.
- Adds `hyper::upgrade` module containing types for dealing with
  upgrades.
- Adds `server::conn::Connection::with_upgrades()` method to enable
  these upgrades when using lower-level API (because of a missing
  `Send` bound on the transport generic).
- Client connections are automatically enabled.
- Optimizes request parsing, to make up for extra work to look for
  upgrade requests.
  - Returns a smaller `DecodedLength` type instead of the fatter
    `Decoder`, which should also allow a couple fewer branches.
  - Removes the `Decode::Ignore` wrapper enum, and instead ignoring
    1xx responses is handled directly in the response parsing code.
Ref #1563 
Closes #1395
			
			
This commit is contained in:
		| @@ -93,6 +93,12 @@ where | ||||
|         self.read_buf.as_ref() | ||||
|     } | ||||
|  | ||||
|     #[cfg(test)] | ||||
|     #[cfg(feature = "nightly")] | ||||
|     pub(super) fn read_buf_mut(&mut self) -> &mut BytesMut { | ||||
|         &mut self.read_buf | ||||
|     } | ||||
|  | ||||
|     pub fn headers_buf(&mut self) -> &mut Vec<u8> { | ||||
|         let buf = self.write_buf.headers_mut(); | ||||
|         &mut buf.bytes | ||||
| @@ -595,7 +601,7 @@ mod tests { | ||||
|             cached_headers: &mut None, | ||||
|             req_method: &mut None, | ||||
|         }; | ||||
|         assert!(buffered.parse::<::proto::ClientTransaction>(ctx).unwrap().is_not_ready()); | ||||
|         assert!(buffered.parse::<::proto::h1::ClientTransaction>(ctx).unwrap().is_not_ready()); | ||||
|         assert!(buffered.io.blocked()); | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user