Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix response status and headers #245

Merged
merged 3 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 53 additions & 63 deletions Cargo.lock

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

8 changes: 6 additions & 2 deletions src/request/request_maker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl RequestMaker {
headers.insert(CONTENT_LENGTH, content_length.into());
}
debug!("final headers={:?}", headers);
info!("RequestMaker method=\"{}\" url=\"{}\" request_headers={:?} tags={:?}", method, url.as_str(), headers, tags);
info!("RequestMaker::send_request method=\"{}\" url=\"{}\" request_headers={:?} tags={:?}", method, url.as_str(), headers, tags);
let mut request_provider = json::json!({});
let request_obj = request_provider
.as_object_mut()
Expand Down Expand Up @@ -318,8 +318,12 @@ impl RequestMaker {
stats_tx,
tags,
};
debug!("RequestMaker::send_request Response<Incoming>={:?}", response);
// Convert from a Response<Incoming> to a Response<BoxBody> to pass to handle()
rh.handle(hyper::Response::new(response.into_body().boxed().map_err(std::io::Error::other).boxed()), auto_returns)
let (head, body) = response.into_parts();
let response = hyper::Response::from_parts(head, body.boxed().map_err(std::io::Error::other).boxed());
debug!("RequestMaker::send_request Response<BoxBody>={:?}", response);
rh.handle(response, auto_returns)
.map_err(TestError::from)
})
.or_else(move |r| {
Expand Down
9 changes: 9 additions & 0 deletions src/request/response_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,16 @@ impl ResponseHandler {
where
F: Future<Output = ()> + Send,
{
log::debug!("ResponseHandler::handle response=\"{:?}\"", response);
let status_code = response.status();
let status = status_code.as_u16();
let headers = response.headers().clone(); // For logging
log::debug!(
"ResponseHandler::handle status_code=\"{}\", status=\"{}\", headers={:?}",
status_code,
status,
headers
);
let response_provider = json::json!({ "status": status });
let mut template_values = self.template_values;
template_values.insert("response".into(), response_provider);
Expand Down Expand Up @@ -124,6 +132,7 @@ impl ResponseHandler {
let tags = self.tags;
body_future
.then(move |body_value| {
log::info!("ResponseHandler::handle status={:?} headers={:?} tags={:?} body_value=\"{:?}\"", status, headers, tags, body_value);
let bh = BodyHandler {
included_outgoing_indexes,
now,
Expand Down