request: test adding duplicate headers to the request (#519)
This commit is contained in:
		
				
					committed by
					
						 Sean McArthur
						Sean McArthur
					
				
			
			
				
	
			
			
			
						parent
						
							bf5a268079
						
					
				
				
					commit
					1bdc3fa3c8
				
			| @@ -642,6 +642,27 @@ mod tests { | ||||
|         assert_eq!(r.headers, headers); | ||||
|     } | ||||
|  | ||||
|     #[test] | ||||
|     fn add_headers_multi() { | ||||
|         let client = Client::new().unwrap(); | ||||
|         let some_url = "https://google.com/"; | ||||
|         let mut r = client.post(some_url).unwrap(); | ||||
|  | ||||
|         let header = Host { | ||||
|             hostname: "google.com".to_string(), | ||||
|             port: None, | ||||
|         }; | ||||
|  | ||||
|         let mut headers = Headers::new(); | ||||
|         headers.set(header); | ||||
|  | ||||
|         // Add a copy of the headers to the request builder | ||||
|         let r = r.headers(headers.clone()).build(); | ||||
|  | ||||
|         // then make sure they were added correctly | ||||
|         assert_eq!(r.headers, headers); | ||||
|     } | ||||
|  | ||||
|     #[test] | ||||
|     fn add_body() { | ||||
|         let client = Client::new().unwrap(); | ||||
|   | ||||
| @@ -580,7 +580,7 @@ fn fmt_request_fields<'a, 'b>(f: &'a mut fmt::DebugStruct<'a, 'b>, req: &Request | ||||
| #[cfg(test)] | ||||
| mod tests { | ||||
|     use {body, Client, Method}; | ||||
|     use header::{HOST, HeaderMap, HeaderValue, CONTENT_TYPE}; | ||||
|     use header::{ACCEPT, HOST, HeaderMap, HeaderValue, CONTENT_TYPE}; | ||||
|     use std::collections::{BTreeMap, HashMap}; | ||||
|     use serde_json; | ||||
|     use serde_urlencoded; | ||||
| @@ -678,6 +678,30 @@ mod tests { | ||||
|         assert_eq!(r.headers(), &headers); | ||||
|     } | ||||
|  | ||||
|     #[test] | ||||
|     fn add_headers_multi() { | ||||
|         let client = Client::new(); | ||||
|         let some_url = "https://google.com/"; | ||||
|         let r = client.post(some_url); | ||||
|  | ||||
|         let header_json = HeaderValue::from_static("application/json"); | ||||
|         let header_xml = HeaderValue::from_static("application/xml"); | ||||
|  | ||||
|         let mut headers = HeaderMap::new(); | ||||
|         headers.append(ACCEPT, header_json); | ||||
|         headers.append(ACCEPT, header_xml); | ||||
|  | ||||
|         // Add a copy of the headers to the request builder | ||||
|         let r = r.headers(headers.clone()).build().unwrap(); | ||||
|  | ||||
|         // then make sure they were added correctly | ||||
|         assert_eq!(r.headers(), &headers); | ||||
|         let mut all_values = r.headers().get_all(ACCEPT).iter(); | ||||
|         assert_eq!(all_values.next().unwrap(), &"application/json"); | ||||
|         assert_eq!(all_values.next().unwrap(), &"application/xml"); | ||||
|         assert_eq!(all_values.next(), None); | ||||
|     } | ||||
|  | ||||
|     #[test] | ||||
|     fn add_body() { | ||||
|         let client = Client::new(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user