Add FetchMetadata and update corresponding methods

This commit is contained in:
Keith Yeung 2016-09-14 00:30:59 -07:00
parent 4dcf693a75
commit 07c9cfecec
5 changed files with 75 additions and 29 deletions

View file

@ -170,7 +170,7 @@ pub enum FetchResponseMsg {
ProcessRequestBody,
ProcessRequestEOF,
// todo: send more info about the response (or perhaps the entire Response)
ProcessResponse(Result<Metadata, NetworkError>),
ProcessResponse(Result<FetchMetadata, NetworkError>),
ProcessResponseChunk(Vec<u8>),
ProcessResponseEOF(Result<(), NetworkError>),
}
@ -200,10 +200,25 @@ pub trait FetchTaskTarget {
fn process_response_eof(&mut self, response: &Response);
}
#[derive(Serialize, Deserialize)]
pub enum FilteredMetadata {
Opaque,
Transparent(Metadata)
}
#[derive(Serialize, Deserialize)]
pub enum FetchMetadata {
Unfiltered(Metadata),
Filtered {
filtered: FilteredMetadata,
unsafe_: Metadata
}
}
pub trait FetchResponseListener {
fn process_request_body(&mut self);
fn process_request_eof(&mut self);
fn process_response(&mut self, metadata: Result<Metadata, NetworkError>);
fn process_response(&mut self, metadata: Result<FetchMetadata, NetworkError>);
fn process_response_chunk(&mut self, chunk: Vec<u8>);
fn process_response_eof(&mut self, response: Result<(), NetworkError>);
}