Skip to content

Commit

Permalink
fix(server): proxy body utf8 error
Browse files Browse the repository at this point in the history
  • Loading branch information
gc-victor committed Nov 10, 2023
1 parent 3c208ad commit 3ae47a1
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "query"
version = "0.3.0"
version = "0.3.1-prerelease"
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use tracing_subscriber::FmtSubscriber;

#[derive(Parser)]
#[command(name = "Query")]
#[command(version = "0.3.0")]
#[command(version = "0.3.1-prerelease")]
#[command(about = "The CLI to manage your Query Server instance", long_about = None)]
struct Cli {
#[command(subcommand)]
Expand Down
2 changes: 1 addition & 1 deletion crates/server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "query-server"
version = "0.3.0"
version = "0.3.1-prerelease"
authors.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
20 changes: 1 addition & 19 deletions crates/server/src/controllers/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,6 @@ pub async fn proxy(req: &mut Request<Body>) -> Result<Response<Body>, HttpError>
})
}
};
let status = response.status();
let headers = response.headers().clone();
let body = match hyper::body::to_bytes(response.into_body()).await {
Ok(body) => body,
Err(e) => {
return Err(HttpError {
code: hyper::StatusCode::BAD_GATEWAY,
message: e.to_string(),
body: None,
})
}
};
let body = String::from_utf8(body.to_vec()).unwrap();

let mut resp = Response::new(Body::from(body));

*resp.status_mut() = status;
*resp.headers_mut() = headers;

Ok(resp)
Ok(response)
}

0 comments on commit 3ae47a1

Please sign in to comment.