Skip to content

Commit b8a0672

Browse files
fix: Fixes query param detection in case insensitive form (#245)
* Closes #244 --------- Co-authored-by: andres <afquinteromoreano@gmail.com>
1 parent 9fc8d93 commit b8a0672

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

CHANGELOG.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
## [unreleased]
12

2-
## [2.0.0] - 2025-09-01
3+
### 🐛 Bug Fixes
4+
5+
- Fixes query param detection in case insensitive form
36

4-
### ⚠️ Breaking Changes
5-
- As of this version in order to save telemetry events such as HTTP requests and the new tracing events requires additional tables on the PostgreSQL instance. This change should not change previous tables, but requieres a new table. Current deployments that make use of this feature will need to add the new PostgreSQL table.
7+
### ⚙️ Miscellaneous Tasks
8+
9+
- Update docker images to use latest versions
10+
- Updates cross.sh
11+
## [2.0.0] - 2025-09-01
612

713
### 🚀 Features
814

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "faucet-server"
3-
version = "2.0.0"
3+
version = "2.0.1"
44
edition = "2021"
55
authors = ["Andrés F. Quintero <afquinteromoreano@gmail.com>"]
66
description = "Welcome to Faucet, your go-to solution for deploying Plumber APIs and Shiny Applications with blazing speed and efficiency. Faucet is a high-performance server built with Rust, offering Round Robin and Round Robin + IP Hash load balancing for seamless scaling and distribution of your R applications. Whether you're a data scientist, developer, or DevOps enthusiast, Faucet streamlines the deployment process, making it easier than ever to manage replicas and balance loads effectively."

src/client/websockets.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,23 +418,33 @@ pub enum UpgradeStatus<ReqBody> {
418418

419419
const SESSION_ID_QUERY: &str = "sessionId";
420420

421+
/// zero allocation case insensitive ascii compare
422+
fn case_insensitive_eq(this: &str, that: &str) -> bool {
423+
if this.len() != that.len() {
424+
return false;
425+
}
426+
this.bytes()
427+
.zip(that.bytes())
428+
.all(|(a, b)| a.to_ascii_lowercase() == b.to_ascii_lowercase())
429+
}
430+
421431
async fn upgrade_connection_from_request<ReqBody>(
422432
mut req: Request<ReqBody>,
423433
client: impl ExtractSocketAddr,
424434
shutdown: &'static ShutdownSignal,
425435
) -> FaucetResult<()> {
426436
// Extract sessionId query parameter
427437
let query = req.uri().query().ok_or(FaucetError::BadRequest(
428-
BadRequestReason::MissingQueryParam("sessionId"),
438+
BadRequestReason::MissingQueryParam("Unable to parse query params"),
429439
))?;
430440

431441
let mut session_id: Option<uuid::Uuid> = None;
432442
let mut attempt: Option<usize> = None;
433443

434444
url::form_urlencoded::parse(query.as_bytes()).for_each(|(key, value)| {
435-
if key == SESSION_ID_QUERY {
445+
if case_insensitive_eq(&key, SESSION_ID_QUERY) {
436446
session_id = uuid::Uuid::from_str(&value).ok();
437-
} else if key == "attempt" {
447+
} else if case_insensitive_eq(&key, "attempt") {
438448
attempt = value.parse::<usize>().ok();
439449
}
440450
});
@@ -523,6 +533,12 @@ mod tests {
523533
use super::*;
524534
use uuid::Uuid;
525535

536+
#[test]
537+
fn test_insensitive_compare() {
538+
let session_id = "sessionid";
539+
assert!(case_insensitive_eq(session_id, SESSION_ID_QUERY));
540+
}
541+
526542
#[test]
527543
fn test_calculate_sec_websocket_accept() {
528544
let key = "dGhlIHNhbXBsZSBub25jZQ==";

0 commit comments

Comments
 (0)