From b0f8fac22f569baa7c5daa15955591adf512dac9 Mon Sep 17 00:00:00 2001 From: Gabriel Oprisan Date: Mon, 11 Dec 2023 18:21:08 +0200 Subject: [PATCH] Added ngx_http_request::accept_encoding() --- nginx_module/Cargo.toml | 2 +- nginx_module/src/http_request.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/nginx_module/Cargo.toml b/nginx_module/Cargo.toml index c5cdbc0..63785e8 100644 --- a/nginx_module/Cargo.toml +++ b/nginx_module/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nginx_module" -version = "0.1.3" +version = "0.1.4" edition = "2021" build = "build.rs" authors = ["Gabriel Oprisan "] diff --git a/nginx_module/src/http_request.rs b/nginx_module/src/http_request.rs index a9c55bd..dc09ede 100644 --- a/nginx_module/src/http_request.rs +++ b/nginx_module/src/http_request.rs @@ -340,4 +340,16 @@ impl<'a> HttpRequest<'a> { } } } + + pub fn accept_encoding(&self) -> Option> { + let accept_enconding_entry = self.0.headers_in.accept_encoding; + if accept_enconding_entry.is_null() { + None + } else { + unsafe { + let accept_encoding = (*accept_enconding_entry).value; + Some(NgxStr::from_raw(accept_encoding)) + } + } + } }