fix(http2): don't add client content-length if method doesn't require it
This commit is contained in:
		
				
					committed by
					
						 Sean McArthur
						Sean McArthur
					
				
			
			
				
	
			
			
			
						parent
						
							35825c4614
						
					
				
				
					commit
					fb90d30c02
				
			| @@ -1,6 +1,7 @@ | ||||
| use bytes::BytesMut; | ||||
| use http::header::{HeaderValue, OccupiedEntry, ValueIter}; | ||||
| use http::header::{CONTENT_LENGTH, TRANSFER_ENCODING}; | ||||
| use http::method::Method; | ||||
| use http::HeaderMap; | ||||
|  | ||||
| pub fn connection_keep_alive(value: &HeaderValue) -> bool { | ||||
| @@ -57,6 +58,13 @@ pub fn content_length_parse_all_values(values: ValueIter<'_, HeaderValue>) -> Op | ||||
|     } | ||||
| } | ||||
|  | ||||
| pub fn method_has_defined_payload_semantics(method: &Method) -> bool { | ||||
|     match *method { | ||||
|         Method::GET | Method::HEAD | Method::DELETE | Method::CONNECT => false, | ||||
|         _ => true, | ||||
|     } | ||||
| } | ||||
|  | ||||
| pub fn set_content_length_if_missing(headers: &mut HeaderMap, len: u64) { | ||||
|     headers | ||||
|         .entry(CONTENT_LENGTH) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user