Skip to content

Commit 39b6d01

Browse files
committedAug 19, 2021
fix(ffi): on_informational callback had no headers
1 parent adaa8b3 commit 39b6d01

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed
 

‎capi/examples/upload.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ static int print_each_header(void *userdata,
148148
return HYPER_ITER_CONTINUE;
149149
}
150150

151-
static void print_informational(void *userdata, const hyper_response *resp) {
151+
static void print_informational(void *userdata, hyper_response *resp) {
152152
uint16_t http_status = hyper_response_status(resp);
153153

154154
printf("\nInformational (1xx): %d\n", http_status);

‎capi/include/hyper.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ typedef int (*hyper_body_foreach_callback)(void*, const struct hyper_buf*);
207207

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

210-
typedef void (*hyper_request_on_informational_callback)(void*, const struct hyper_response*);
210+
typedef void (*hyper_request_on_informational_callback)(void*, struct hyper_response*);
211211

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

@@ -469,7 +469,7 @@ enum hyper_code hyper_request_set_body(struct hyper_request *req, struct hyper_b
469469
`hyper_response *` which can be inspected as any other response. The
470470
body of the response will always be empty.
471471
472-
NOTE: The `const hyper_response *` is just borrowed data, and will not
472+
NOTE: The `hyper_response *` is just borrowed data, and will not
473473
be valid after the callback finishes. You must copy any data you wish
474474
to persist.
475475
*/

‎src/ffi/http_types.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub(crate) struct OnInformational {
3434
data: UserDataPointer,
3535
}
3636

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

3939
// ===== impl hyper_request =====
4040

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

438438
impl OnInformational {
439439
pub(crate) fn call(&mut self, resp: Response<Body>) {
440-
let mut resp = hyper_response(resp);
440+
let mut resp = hyper_response::wrap(resp);
441441
(self.func)(self.data.0, &mut resp);
442442
}
443443
}

‎src/proto/h1/role.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::fmt::{self, Write};
2-
use std::mem::{self, MaybeUninit};
2+
use std::mem::MaybeUninit;
33

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

362362
let orig_headers;
363-
let extensions = mem::take(&mut msg.head.extensions);
363+
let extensions = std::mem::take(&mut msg.head.extensions);
364364
let orig_headers = match extensions.get::<HeaderCaseMap>() {
365365
None if msg.title_case_headers => {
366366
orig_headers = HeaderCaseMap::default();

0 commit comments

Comments
 (0)
Please sign in to comment.