|
2 | 2 | use std::borrow::{Cow, ToOwned};
|
3 | 3 | use std::cmp::min;
|
4 | 4 | use std::io::{self, Read, Write, BufRead};
|
| 5 | +use std::fmt; |
5 | 6 |
|
6 | 7 | use httparse;
|
7 | 8 |
|
@@ -60,6 +61,18 @@ impl<R: Read> HttpReader<R> {
|
60 | 61 | }
|
61 | 62 | }
|
62 | 63 |
|
| 64 | +impl<R> fmt::Debug for HttpReader<R> { |
| 65 | + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { |
| 66 | + match *self { |
| 67 | + SizedReader(_,rem) => write!(fmt, "SizedReader(remaining={:?})", rem), |
| 68 | + ChunkedReader(_, None) => write!(fmt, "ChunkedReader(chunk_remaining=unknown)"), |
| 69 | + ChunkedReader(_, Some(rem)) => write!(fmt, "ChunkedReader(chunk_remaining={:?})", rem), |
| 70 | + EofReader(_) => write!(fmt, "EofReader"), |
| 71 | + EmptyReader(_) => write!(fmt, "EmptyReader"), |
| 72 | + } |
| 73 | + } |
| 74 | +} |
| 75 | + |
63 | 76 | impl<R: Read> Read for HttpReader<R> {
|
64 | 77 | fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
|
65 | 78 | match *self {
|
@@ -305,6 +318,17 @@ impl<W: Write> Write for HttpWriter<W> {
|
305 | 318 | }
|
306 | 319 | }
|
307 | 320 |
|
| 321 | +impl<W: Write> fmt::Debug for HttpWriter<W> { |
| 322 | + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { |
| 323 | + match *self { |
| 324 | + ThroughWriter(_) => write!(fmt, "ThroughWriter"), |
| 325 | + ChunkedWriter(_) => write!(fmt, "ChunkedWriter"), |
| 326 | + SizedWriter(_, rem) => write!(fmt, "SizedWriter(remaining={:?})", rem), |
| 327 | + EmptyWriter(_) => write!(fmt, "EmptyWriter"), |
| 328 | + } |
| 329 | + } |
| 330 | +} |
| 331 | + |
308 | 332 | const MAX_HEADERS: usize = 100;
|
309 | 333 |
|
310 | 334 | /// Parses a request into an Incoming message head.
|
|
0 commit comments