Skip to content

Commit

Permalink
Refactor(ffi): remove the "raw" headers option in C API
Browse files Browse the repository at this point in the history
  • Loading branch information
dannasman committed Oct 3, 2022
1 parent bd7928f commit 2d2461a
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 67 deletions.
6 changes: 0 additions & 6 deletions capi/examples/upload.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
26 changes: 0 additions & 26 deletions capi/include/hyper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
14 changes: 0 additions & 14 deletions src/ffi/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 0 additions & 21 deletions src/ffi/http_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<RawHeaders>() {
Some(raw) => &raw.0,
None => std::ptr::null(),
}
} ?= std::ptr::null()
}

ffi_fn! {
/// Get the HTTP version used by this response.
///
Expand Down

0 comments on commit 2d2461a

Please sign in to comment.