refactor(header): improve debug view of Headers
This commit is contained in:
		| @@ -202,6 +202,14 @@ impl<'a, H: Header + ?Sized + 'a> fmt::Display for FmtHeader<'a, H> { | |||||||
|  |  | ||||||
| struct ValueString<'a>(&'a Item); | struct ValueString<'a>(&'a Item); | ||||||
|  |  | ||||||
|  | impl<'a> fmt::Debug for ValueString<'a> { | ||||||
|  |     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||||||
|  |         try!(f.write_str("\"")); | ||||||
|  |         try!(self.0.write_h1(&mut MultilineFormatter(Multi::Join(true, f)))); | ||||||
|  |         f.write_str("\"") | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| impl<'a> fmt::Display for ValueString<'a> { | impl<'a> fmt::Display for ValueString<'a> { | ||||||
|     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||||||
|         self.0.write_h1(&mut MultilineFormatter(Multi::Join(true, f))) |         self.0.write_h1(&mut MultilineFormatter(Multi::Join(true, f))) | ||||||
| @@ -504,12 +512,9 @@ impl fmt::Display for Headers { | |||||||
|  |  | ||||||
| impl fmt::Debug for Headers { | impl fmt::Debug for Headers { | ||||||
|     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||||||
|         try!(f.write_str("Headers { ")); |         f.debug_map() | ||||||
|         for header in self.iter() { |             .entries(self.iter().map(|view| (view.0.as_ref(), ValueString(view.1)))) | ||||||
|             try!(write!(f, "{:?}, ", header)); |             .finish() | ||||||
|         } |  | ||||||
|         try!(f.write_str("}")); |  | ||||||
|         Ok(()) |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -92,7 +92,7 @@ impl Http1Transaction for ServerTransaction { | |||||||
|  |  | ||||||
|         let init_cap = 30 + head.headers.len() * AVERAGE_HEADER_SIZE; |         let init_cap = 30 + head.headers.len() * AVERAGE_HEADER_SIZE; | ||||||
|         dst.reserve(init_cap); |         dst.reserve(init_cap); | ||||||
|         debug!("writing {:#?}", head.headers); |         debug!("writing headers = {:?}", head.headers); | ||||||
|         if head.version == ::HttpVersion::Http11 && head.subject == ::StatusCode::Ok { |         if head.version == ::HttpVersion::Http11 && head.subject == ::StatusCode::Ok { | ||||||
|             extend(dst, b"HTTP/1.1 200 OK\r\n"); |             extend(dst, b"HTTP/1.1 200 OK\r\n"); | ||||||
|             let _ = write!(FastWrite(dst), "{}\r\n", head.headers); |             let _ = write!(FastWrite(dst), "{}\r\n", head.headers); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user