diff --git a/src/gz/bufread.rs b/src/gz/bufread.rs index 8db25605..f2a04718 100644 --- a/src/gz/bufread.rs +++ b/src/gz/bufread.rs @@ -205,6 +205,7 @@ pub struct GzDecoder { state: GzState, reader: CrcReader>, multi: bool, + headers: Vec, } #[derive(Debug)] @@ -240,6 +241,7 @@ impl GzDecoder { state, reader: CrcReader::new(deflate::bufread::DeflateDecoder::new(r)), multi: false, + headers: Vec::new(), } } @@ -284,6 +286,7 @@ impl Read for GzDecoder { state, reader, multi, + headers, } = self; loop { @@ -366,9 +369,10 @@ impl Read for GzDecoder { return Err(err); } }; + headers.push(header); if is_eof { - GzState::End(Some(header)) + GzState::End(None) } else { reader.reset(); reader.get_mut().reset_data(); @@ -449,9 +453,13 @@ impl MultiGzDecoder { } impl MultiGzDecoder { - /// Returns the current header associated with this stream, if it's valid - pub fn header(&self) -> Option<&GzHeader> { - self.0.header() + /// Returns the headers processed so far + pub fn headers(&self) -> Vec<&GzHeader> { + let mut hdrs: Vec<&GzHeader> = self.0.headers.iter().collect(); + if let Some(hdr) = &self.0.header() { + hdrs.push(hdr) + } + hdrs } /// Acquires a reference to the underlying reader. diff --git a/src/gz/read.rs b/src/gz/read.rs index 2b0796b2..3ede2e6b 100644 --- a/src/gz/read.rs +++ b/src/gz/read.rs @@ -237,9 +237,9 @@ impl MultiGzDecoder { } impl MultiGzDecoder { - /// Returns the current header associated with this stream, if it's valid. - pub fn header(&self) -> Option<&GzHeader> { - self.inner.header() + /// Returns the headers processed so far + pub fn headers(&self) -> Vec<&GzHeader> { + self.inner.headers() } /// Acquires a reference to the underlying reader.