@@ -64,6 +64,9 @@ struct Args {
6464 generate_jwt_token : String ,
6565}
6666
67+ // const names for last-modified and etag in lowercase
68+ const LAST_MODIFIED : & str = "last-modified" ;
69+ const ETAG : & str = "etag" ;
6770
6871type FileSemaphores = Arc < RwLock < HashMap < String , Arc < Semaphore > > > > ;
6972
@@ -539,6 +542,7 @@ async fn ax_get_file(
539542 }
540543 } ;
541544
545+ // IMPORTANT! Headers in cache must be stored in lowercase
542546 let received_file = driver_get_file ( filepath. clone ( ) ) ;
543547 if !received_file. valid {
544548 println ! (
@@ -576,7 +580,7 @@ async fn ax_get_file(
576580 headers. insert ( header:: ETAG , etag. clone ( ) ) ;
577581 }
578582 // add last-modified header
579- if let Some ( last_modified) = upstream_headers. get ( "Last-Modified" ) {
583+ if let Some ( last_modified) = upstream_headers. get ( LAST_MODIFIED ) {
580584 headers. insert ( header:: LAST_MODIFIED , last_modified. clone ( ) ) ;
581585 }
582586
@@ -587,7 +591,7 @@ async fn ax_get_file(
587591 if method != axum:: http:: Method :: GET && method != axum:: http:: Method :: HEAD {
588592 return ( StatusCode :: PRECONDITION_FAILED , "Method Not Allowed" ) . into_response ( ) ;
589593 }
590- if let Some ( etag) = upstream_headers. get ( "ETag" ) {
594+ if let Some ( etag) = upstream_headers. get ( ETAG ) {
591595 if if_none_match == etag {
592596 println ! (
593597 "{:?} 304 0 {} {} {} {}" ,
@@ -598,7 +602,7 @@ async fn ax_get_file(
598602 }
599603 // Does request have If-Modified-Since header?
600604 } else if let Some ( if_modified_since) = rxheaders. get ( "If-Modified-Since" ) {
601- if let Some ( last_modified) = upstream_headers. get ( "Last-Modified" ) {
605+ if let Some ( last_modified) = upstream_headers. get ( LAST_MODIFIED ) {
602606 // TODO: Validate properly last_modified
603607 if if_modified_since == last_modified {
604608 println ! (
0 commit comments