Send the client's credentials and proxy target on a stream request

open_stream(), and with it stream::Get() and SSEClient, wrote its own
request head and left out what a buffered request gets: the
Authorization from set_basic_auth() or set_bearer_token_auth(), and
through a plain HTTP proxy the absolute-form target (RFC 9112 3.2.2)
and Proxy-Authorization. A proxy refused such a request, and an origin
that needs credentials answered 401.

Move the two decisions out of write_request() and handle_request() into
add_credential_headers() and proxy_target_prefix(), and use them in
open_stream() too, after connecting as a buffered request does. A
Digest challenge or a redirect is still handed to the caller.
This commit is contained in:
yhirose committed 2026-10-18 20:32:27 -04:00
1 parent ebcd5551fd
commit f17d314979
5 files changed
+124 -27

No files matched your search

+2
View File
@@ -161,6 +161,8 @@ httplib::sse::SSEClient sse(cli, "/events", headers);
sse.start();
```
The `Client`'s `set_basic_auth()` and `set_bearer_token_auth()` apply too; an `Authorization` header passed like this takes precedence.
### Refreshing Auth Token on Reconnect
```cpp