From 2d2461ad95dd530b28dc29cd9bc4a1d7e94a6a03 Mon Sep 17 00:00:00 2001 From: Dan Nasman Date: Mon, 3 Oct 2022 21:25:05 +0300 Subject: [PATCH] Refactor(ffi): remove the "raw" headers option in C API --- capi/examples/upload.c | 6 ------ capi/include/hyper.h | 26 -------------------------- src/ffi/client.rs | 14 -------------- src/ffi/http_types.rs | 21 --------------------- 4 files changed, 67 deletions(-) diff --git a/capi/examples/upload.c b/capi/examples/upload.c index 9b791eedf8..4bf44e6513 100644 --- a/capi/examples/upload.c +++ b/capi/examples/upload.c @@ -153,11 +153,6 @@ static void print_informational(void *userdata, hyper_response *resp) { uint16_t http_status = hyper_response_status(resp); printf("\nInformational (1xx): %d\n", http_status); - - const hyper_buf *headers = hyper_response_headers_raw(resp); - if (headers) { - write(1, hyper_buf_bytes(headers), hyper_buf_len(headers)); - } } typedef enum { @@ -228,7 +223,6 @@ int main(int argc, char *argv[]) { // Prepare client options hyper_clientconn_options *opts = hyper_clientconn_options_new(); hyper_clientconn_options_exec(opts, exec); - hyper_clientconn_options_headers_raw(opts, 1); hyper_task *handshake = hyper_clientconn_handshake(io, opts); hyper_task_set_userdata(handshake, (void *)EXAMPLE_HANDSHAKE); diff --git a/capi/include/hyper.h b/capi/include/hyper.h index 16487f0813..d41ccaaccd 100644 --- a/capi/include/hyper.h +++ b/capi/include/hyper.h @@ -391,17 +391,6 @@ void hyper_clientconn_options_exec(struct hyper_clientconn_options *opts, */ enum hyper_code hyper_clientconn_options_http2(struct hyper_clientconn_options *opts, int enabled); -/* - Set the whether to include a copy of the raw headers in responses - received on this connection. - - Pass `0` to disable, `1` to enable. - - If enabled, see `hyper_response_headers_raw()` for usage. - */ -enum hyper_code hyper_clientconn_options_headers_raw(struct hyper_clientconn_options *opts, - int enabled); - /* Set whether HTTP/1 connections will accept obsolete line folding for header values. Newline codepoints (\r and \n) will be transformed to spaces when parsing. @@ -567,21 +556,6 @@ const uint8_t *hyper_response_reason_phrase(const struct hyper_response *resp); */ size_t hyper_response_reason_phrase_len(const struct hyper_response *resp); -/* - Get a reference to the full raw headers of this response. - - You must have enabled `hyper_clientconn_options_headers_raw()`, or this - will return NULL. - - The returned `hyper_buf *` is just a reference, owned by the response. - You need to make a copy if you wish to use it after freeing the - response. - - The buffer is not null-terminated, see the `hyper_buf` functions for - getting the bytes and length. - */ -const struct hyper_buf *hyper_response_headers_raw(const struct hyper_response *resp); - /* Get the HTTP version used by this response. diff --git a/src/ffi/client.rs b/src/ffi/client.rs index 637b490e0d..d12c55dc57 100644 --- a/src/ffi/client.rs +++ b/src/ffi/client.rs @@ -203,20 +203,6 @@ ffi_fn! { } } -ffi_fn! { - /// Set the whether to include a copy of the raw headers in responses - /// received on this connection. - /// - /// Pass `0` to disable, `1` to enable. - /// - /// If enabled, see `hyper_response_headers_raw()` for usage. - fn hyper_clientconn_options_headers_raw(opts: *mut hyper_clientconn_options, enabled: c_int) -> hyper_code { - let opts = non_null! { &mut *opts ?= hyper_code::HYPERE_INVALID_ARG }; - opts.http1_headers_raw = enabled != 0; - hyper_code::HYPERE_OK - } -} - ffi_fn! { /// Set whether HTTP/1 connections will accept obsolete line folding for header values. /// Newline codepoints (\r and \n) will be transformed to spaces when parsing. diff --git a/src/ffi/http_types.rs b/src/ffi/http_types.rs index 885b31c73b..bea5c68916 100644 --- a/src/ffi/http_types.rs +++ b/src/ffi/http_types.rs @@ -278,27 +278,6 @@ ffi_fn! { } } -ffi_fn! { - /// Get a reference to the full raw headers of this response. - /// - /// You must have enabled `hyper_clientconn_options_headers_raw()`, or this - /// will return NULL. - /// - /// The returned `hyper_buf *` is just a reference, owned by the response. - /// You need to make a copy if you wish to use it after freeing the - /// response. - /// - /// The buffer is not null-terminated, see the `hyper_buf` functions for - /// getting the bytes and length. - fn hyper_response_headers_raw(resp: *const hyper_response) -> *const hyper_buf { - let resp = non_null!(&*resp ?= std::ptr::null()); - match resp.0.extensions().get::() { - Some(raw) => &raw.0, - None => std::ptr::null(), - } - } ?= std::ptr::null() -} - ffi_fn! { /// Get the HTTP version used by this response. ///