diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 1 | ||||
-rw-r--r-- | src/modules/auth/cookie.rs | 2 | ||||
-rw-r--r-- | src/modules/auth/openid.rs | 4 | ||||
-rw-r--r-- | src/modules/files.rs | 28 | ||||
-rw-r--r-- | src/modules/log.rs | 4 | ||||
-rw-r--r-- | src/modules/ratelimit.rs | 2 |
6 files changed, 19 insertions, 22 deletions
diff --git a/src/main.rs b/src/main.rs index 147a329..356b270 100644 --- a/src/main.rs +++ b/src/main.rs @@ -375,7 +375,6 @@ async fn send_h3_response( } if let Err(e) = send.finish().await { debug!("h3 response finish error: {e}"); - return; } } diff --git a/src/modules/auth/cookie.rs b/src/modules/auth/cookie.rs index 4c4d96d..c0935f7 100644 --- a/src/modules/auth/cookie.rs +++ b/src/modules/auth/cookie.rs @@ -199,7 +199,7 @@ fn apply_login_success_headers( ); r.headers_mut().append( SET_COOKIE, - HeaderValue::from_str(&format!("gnix_auth={}{}", auth, cookie_opts)).unwrap(), + HeaderValue::from_str(&format!("gnix_auth={auth}{cookie_opts}")).unwrap(), ); } diff --git a/src/modules/auth/openid.rs b/src/modules/auth/openid.rs index bad9c0c..9ea268c 100644 --- a/src/modules/auth/openid.rs +++ b/src/modules/auth/openid.rs @@ -200,7 +200,7 @@ impl Node for OpenIDAuth { ); resp.headers_mut().insert( LOCATION, - HeaderValue::from_str(&return_path).map_err(|_| ServiceError::InvalidHeader)?, + HeaderValue::from_str(return_path).map_err(|_| ServiceError::InvalidHeader)?, ); Ok(resp) } else if request.method() == Method::GET && request.uri().path() == "/favicon.ico" { @@ -318,7 +318,7 @@ async fn token_request( .map_err(|_| ServiceError::CustomStatic("token request handshake failed"))?; tokio::task::spawn(async move { if let Err(err) = conn.await { - println!("Connection failed: {:?}", err); + println!("Connection failed: {err:?}"); } }); diff --git a/src/modules/files.rs b/src/modules/files.rs index ab98f66..a37098d 100644 --- a/src/modules/files.rs +++ b/src/modules/files.rs @@ -119,7 +119,7 @@ impl Node for Files { *r.status_mut() = StatusCode::FOUND; r.headers_mut().insert( LOCATION, - HeaderValue::from_str(&format!("{}/", rpath)) + HeaderValue::from_str(&format!("{rpath}/")) .map_err(|_| ServiceError::Other)?, ); return Ok(r.map(|b| b.map_err(|e| match e {}).boxed())); @@ -192,22 +192,20 @@ impl Node for Files { if skip_body { *r.status_mut() = StatusCode::NOT_MODIFIED; - } else { - if range_satisfied { - if range.end - range.start != metadata.len() { - *r.status_mut() = StatusCode::PARTIAL_CONTENT; - r.headers_mut().typed_insert( - ContentRange::bytes(range.clone(), metadata.len()) - .expect("valid ContentRange"), - ); - } else { - *r.status_mut() = StatusCode::OK; - } + } else if range_satisfied { + if range.end - range.start != metadata.len() { + *r.status_mut() = StatusCode::PARTIAL_CONTENT; + r.headers_mut().typed_insert( + ContentRange::bytes(range.clone(), metadata.len()) + .expect("valid ContentRange"), + ); } else { - *r.status_mut() = StatusCode::RANGE_NOT_SATISFIABLE; - r.headers_mut() - .typed_insert(ContentRange::unsatisfied_bytes(metadata.len())); + *r.status_mut() = StatusCode::OK; } + } else { + *r.status_mut() = StatusCode::RANGE_NOT_SATISFIABLE; + r.headers_mut() + .typed_insert(ContentRange::unsatisfied_bytes(metadata.len())); } r.headers_mut().typed_insert(AcceptRanges::bytes()); diff --git a/src/modules/log.rs b/src/modules/log.rs index 3705657..9efa3ad 100644 --- a/src/modules/log.rs +++ b/src/modules/log.rs @@ -135,7 +135,7 @@ impl Node for Log { } .unwrap(); } - write!(out, "\n").unwrap(); + writeln!(out).unwrap(); out } Format::Json => { @@ -210,7 +210,7 @@ impl Node for Log { let mut out = Cursor::new(Vec::new()); serde_json::to_writer(&mut out, &entry).unwrap(); - write!(out, "\n").unwrap(); + writeln!(out).unwrap(); String::from_utf8_lossy_owned(out.into_inner()) } }; diff --git a/src/modules/ratelimit.rs b/src/modules/ratelimit.rs index 9e5d583..ce5ac68 100644 --- a/src/modules/ratelimit.rs +++ b/src/modules/ratelimit.rs @@ -142,7 +142,7 @@ impl Node for Ratelimit { LimitMode::Exec(path) => { // Exact comparison so it can only trigger once per frame if counter == *thres { - let mut command = Command::new(&path); + let mut command = Command::new(path); command.stdin(Stdio::null()); set_cgi_variables(&mut command, &request, context); spawn(async move { |