Skip to content

Commit

Permalink
remove lower-bound check as the read_body_with_limit fn handles it
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Nov 20, 2024
1 parent ce77c6a commit 8ff8efa
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
2 changes: 1 addition & 1 deletion proxy/src/bin/local_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct SqlOverHttpArgs {
sql_over_http_cancel_set_shards: usize,

#[clap(long, default_value_t = 10 * 1024 * 1024)] // 10 MiB
sql_over_http_max_request_size_bytes: u64,
sql_over_http_max_request_size_bytes: usize,

#[clap(long, default_value_t = 10 * 1024 * 1024)] // 10 MiB
sql_over_http_max_response_size_bytes: usize,
Expand Down
2 changes: 1 addition & 1 deletion proxy/src/bin/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ struct SqlOverHttpArgs {
sql_over_http_cancel_set_shards: usize,

#[clap(long, default_value_t = 10 * 1024 * 1024)] // 10 MiB
sql_over_http_max_request_size_bytes: u64,
sql_over_http_max_request_size_bytes: usize,

#[clap(long, default_value_t = 10 * 1024 * 1024)] // 10 MiB
sql_over_http_max_response_size_bytes: usize,
Expand Down
17 changes: 1 addition & 16 deletions proxy/src/serverless/sql_over_http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use http::header::AUTHORIZATION;
use http::Method;
use http_body_util::combinators::BoxBody;
use http_body_util::{BodyExt, Full};
use hyper::body::{Body, Incoming};
use hyper::body::Incoming;
use hyper::http::{HeaderName, HeaderValue};
use hyper::{header, HeaderMap, Request, Response, StatusCode};
use pq_proto::StartupMessageParamsBuilder;
Expand Down Expand Up @@ -598,21 +598,6 @@ async fn handle_db_inner(

let parsed_headers = HttpHeaders::try_parse(headers)?;

let request_content_length = request.body().size_hint().lower();
debug!(request_content_length, "request size in bytes");

// reject the request early if the content length lower bound exceeds our limit.
match usize::try_from(request_content_length) {
Ok(x) if x <= config.http_config.max_request_size_bytes => {}
_ => {
return Err(SqlOverHttpError::ReadPayload(
ReadPayloadError::BodyTooLarge {
limit: config.http_config.max_request_size_bytes,
},
));
}
}

let fetch_and_process_request = Box::pin(
async {
let body = read_body_with_limit(
Expand Down

0 comments on commit 8ff8efa

Please sign in to comment.