fn response_from_zip<'a>(
    zip: &mut ZipFile<'a>,
    csp: &str,
    if_none_match: Option<&HeaderValue>,
) -> HttpResponse {
    // Check if we can return NotModified without reading the file content.
    let etag = Etag::for_zip(&zip);
    let mime = mime_type_for(zip.name());
    if let Some(response) = maybe_not_modified(if_none_match, &etag, &mime) {
        return response;
    }

    let mut buf = vec![];
    let _ = zip.read_to_end(&mut buf);

    HttpResponse::Ok()
        .set_header("Content-Security-Policy", csp)
        .set_header("ETag", etag.to_string())
        .content_type(mime.as_ref())
        .body(buf)
}
// Naive conversion of a ZipFile into an HttpResponse.
// TODO: streaming version.
Naive conversion of a ZipFile into an HttpResponse.
TODO: streaming version.
Naive conversion of a ZipFile into an HttpResponse . TODO : streaming version .
fn response_from_zip<'a>(
    zip: &mut ZipFile<'a>,
    csp: &str,
    if_none_match: Option<&HeaderValue>,
) -> HttpResponse {
    // Check if we can return NotModified without reading the file content.
    let etag = Etag::for_zip(&zip);
    let mime = mime_type_for(zip.name());
    if let Some(response) = maybe_not_modified(if_none_match, &etag, &mime) {
        return response;
    }
    let mut buf = vec![];
    let _ = zip.read_to_end(&mut buf);
    HttpResponse::Ok()
        .set_header("Content-Security-Policy", csp)
        .set_header("ETag", etag.to_string())
        .content_type(mime.as_ref())
        .body(buf)
}
fn response_from_zip < ' a > ( zip : & mut ZipFile < ' a > , csp : & str , if_none_match : Option < & HeaderValue > , ) -> HttpResponse { // Check if we can return NotModified without reading the file content. let etag = Etag :: for_zip ( & zip ) ; let mime = mime_type_for ( zip . name ( ) ) ; if let Some ( response ) = maybe_not_modified ( if_none_match , & etag , & mime ) { return response ; } let mut buf = vec ! [ ] ; let _ = zip . read_to_end ( & mut buf ) ; HttpResponse :: Ok ( ) . set_header ( " " , csp ) . set_header ( " " , etag . to_string ( ) ) . content_type ( mime . as_ref ( ) ) . body ( buf ) }
Naive conversion of a ZipFile into an HttpResponse.
Naive conversion of a ZipFile into an HttpResponse .
zip
&mut ZipFile<'a>
csp
&str
if_none_match
Option<&HeaderValue>
zip
&mut ZipFile<'a>
csp
&str
if_none_match
Option<&HeaderValue>