Skip to content

fix(ffi): on_informational callback had no headers #2630

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

Merged
merged 1 commit into from
Aug 19, 2021
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
2 changes: 1 addition & 1 deletion capi/examples/upload.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static int print_each_header(void *userdata,
return HYPER_ITER_CONTINUE;
}

static void print_informational(void *userdata, const hyper_response *resp) {
static void print_informational(void *userdata, hyper_response *resp) {
uint16_t http_status = hyper_response_status(resp);

printf("\nInformational (1xx): %d\n", http_status);
Expand Down
4 changes: 2 additions & 2 deletions capi/include/hyper.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ typedef int (*hyper_body_foreach_callback)(void*, const struct hyper_buf*);

typedef int (*hyper_body_data_callback)(void*, struct hyper_context*, struct hyper_buf**);

typedef void (*hyper_request_on_informational_callback)(void*, const struct hyper_response*);
typedef void (*hyper_request_on_informational_callback)(void*, struct hyper_response*);

typedef int (*hyper_headers_foreach_callback)(void*, const uint8_t*, size_t, const uint8_t*, size_t);

Expand Down Expand Up @@ -469,7 +469,7 @@ enum hyper_code hyper_request_set_body(struct hyper_request *req, struct hyper_b
`hyper_response *` which can be inspected as any other response. The
body of the response will always be empty.

NOTE: The `const hyper_response *` is just borrowed data, and will not
NOTE: The `hyper_response *` is just borrowed data, and will not
be valid after the callback finishes. You must copy any data you wish
to persist.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/ffi/http_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) struct OnInformational {
data: UserDataPointer,
}

type hyper_request_on_informational_callback = extern "C" fn(*mut c_void, *const hyper_response);
type hyper_request_on_informational_callback = extern "C" fn(*mut c_void, *mut hyper_response);

// ===== impl hyper_request =====

Expand Down Expand Up @@ -153,7 +153,7 @@ ffi_fn! {
/// `hyper_response *` which can be inspected as any other response. The
/// body of the response will always be empty.
///
/// NOTE: The `const hyper_response *` is just borrowed data, and will not
/// NOTE: The `hyper_response *` is just borrowed data, and will not
/// be valid after the callback finishes. You must copy any data you wish
/// to persist.
fn hyper_request_on_informational(req: *mut hyper_request, callback: hyper_request_on_informational_callback, data: *mut c_void) -> hyper_code {
Expand Down Expand Up @@ -437,7 +437,7 @@ unsafe fn raw_name_value(

impl OnInformational {
pub(crate) fn call(&mut self, resp: Response<Body>) {
let mut resp = hyper_response(resp);
let mut resp = hyper_response::wrap(resp);
(self.func)(self.data.0, &mut resp);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/proto/h1/role.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::fmt::{self, Write};
use std::mem::{self, MaybeUninit};
use std::mem::MaybeUninit;

#[cfg(any(test, feature = "server", feature = "ffi"))]
use bytes::Bytes;
Expand Down Expand Up @@ -360,7 +360,7 @@ impl Http1Transaction for Server {
}

let orig_headers;
let extensions = mem::take(&mut msg.head.extensions);
let extensions = std::mem::take(&mut msg.head.extensions);
let orig_headers = match extensions.get::<HeaderCaseMap>() {
None if msg.title_case_headers => {
orig_headers = HeaderCaseMap::default();
Expand Down