From 09e35668e5b094d679efb4b98ecde9cb6f9f2f93 Mon Sep 17 00:00:00 2001 From: deantvv Date: Wed, 20 Jul 2022 03:18:09 +0800 Subject: [PATCH] feat(ffi): add http1_allow_multiline_headers (#2918) --- capi/include/hyper.h | 10 ++++++++++ src/ffi/client.rs | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/capi/include/hyper.h b/capi/include/hyper.h index 1f938b8714..16487f0813 100644 --- a/capi/include/hyper.h +++ b/capi/include/hyper.h @@ -402,6 +402,16 @@ enum hyper_code hyper_clientconn_options_http2(struct hyper_clientconn_options * 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. + + Pass `0` to disable, `1` to enable. + + */ +enum hyper_code hyper_clientconn_options_http1_allow_multiline_headers(struct hyper_clientconn_options *opts, + int enabled); + /* Frees a `hyper_error`. */ diff --git a/src/ffi/client.rs b/src/ffi/client.rs index 4cdb257e30..580718f4fc 100644 --- a/src/ffi/client.rs +++ b/src/ffi/client.rs @@ -179,3 +179,16 @@ ffi_fn! { 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. + /// + /// Pass `0` to disable, `1` to enable. + /// + fn hyper_clientconn_options_http1_allow_multiline_headers(opts: *mut hyper_clientconn_options, enabled: c_int) -> hyper_code { + let opts = non_null! { &mut *opts ?= hyper_code::HYPERE_INVALID_ARG }; + opts.builder.http1_allow_obsolete_multiline_headers_in_responses(enabled != 0); + hyper_code::HYPERE_OK + } +}