Repository: seanmonstar/reqwest (language: rust)

Issue:
RequestBuilder::header unsets `sensitive` on header value
`RequestBuilder::header`:
https://github.com/seanmonstar/reqwest/blob/892569e10b69d1a0e5db1f53202d1ebf09924fc1/src/async_impl/request.rs#L189-L218
allows passing `HeaderValue`, however it overwrites `sensitive` to false, making it impossible to flag a header as `sensitive` right away unless going through the `.basic_auth` or `.bearer_auth` functions.

It looks like a bug: when simply going through `.header`, it looks like it should not overwrite the value of `sensitive` for the generated `HeaderValue`.


Discussion / hints:
It does? Perhaps I'm not seeing it. Which line specifically does it unset it?
Ah sorry I read the code for `blocking` in my editor, and actually linked the `async` one here.

The issue still lies here:
https://github.com/seanmonstar/reqwest/blob/892569e10b69d1a0e5db1f53202d1ebf09924fc1/src/blocking/request.rs#L191-L215

It seems that the issue was already reported in #1549 and fixed for `async` by d536ce261c6e92d9956cc9a3d28c4288046f454b, but the `blocking` implementation was forgotten.

I'll open a PR.

Fix patch:
diff --git a/src/blocking/request.rs b/src/blocking/request.rs
index 9acc1e16a..8ac112444 100644
--- a/src/blocking/request.rs
+++ b/src/blocking/request.rs
@@ -211,7 +211,12 @@ impl RequestBuilder {
             match <HeaderName as TryFrom<K>>::try_from(key) {
                 Ok(key) => match <HeaderValue as TryFrom<V>>::try_from(value) {
                     Ok(mut value) => {
-                        value.set_sensitive(sensitive);
+                        // We want to potentially make an unsensitive header
+                        // to be sensitive, not the reverse. So, don't turn off
+                        // a previously sensitive header.
+                        if sensitive {
+                            value.set_sensitive(true);
+                        }
                         req.headers_mut().append(key, value);
                     }
                     Err(e) => error = Some(crate::error::builder(e.into())),


Test patch: