mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-19 11:19:36 +00:00
Support HTTP proxies in WebSocketClient (#2635)
WebSocketClient gets the proxy setters Client has: set_proxy(), set_proxy_basic_auth(), set_proxy_bearer_token_auth(), set_no_proxy() and, in SSL builds, set_proxy_digest_auth(). connect() opens a CONNECT tunnel for ws:// as well as wss:// (RFC 6455 4.1) and sends the proxy credentials on the CONNECT request only. A proxy that does not answer 200 is reported as Error::ProxyConnection, with its status and headers in Result.
This commit is contained in:
1 parent
7220bdb8b2
commit
94cf1b5c9a
5 files changed
+683
-221
No files matched your search
+16
-2
@@ -170,8 +170,10 @@ bool is_valid() const;
|
||||
// only when the handshake fully succeeded; on failure it describes what went
|
||||
// wrong:
|
||||
// res.error() httplib::Error identifying the failing layer
|
||||
// res.status() HTTP status of the upgrade response (-1 if none)
|
||||
// res.headers() headers of the upgrade response
|
||||
// res.status() HTTP status of the upgrade response (-1 if none),
|
||||
// or of the proxy's CONNECT reply when error() is
|
||||
// Error::ProxyConnection
|
||||
// res.headers() headers of that same response
|
||||
// res.ssl_error() TLS error detail (wss://, SSL builds only)
|
||||
// res.ssl_backend_error() backend-specific TLS error code (SSL builds only)
|
||||
Result connect();
|
||||
@@ -187,6 +189,18 @@ void close(CloseStatus status = CloseStatus::Normal,
|
||||
const std::string &reason = "");
|
||||
bool is_open() const;
|
||||
|
||||
// Proxy - the same setters Client has. connect() opens a CONNECT tunnel
|
||||
// through the proxy for ws:// as well as wss:// (RFC 6455 4.1); the proxy
|
||||
// credentials are sent only on the CONNECT request, never through the tunnel.
|
||||
// Hosts matching set_no_proxy() are connected to directly.
|
||||
void set_proxy(const std::string &host, int port);
|
||||
void set_proxy_basic_auth(const std::string &username,
|
||||
const std::string &password);
|
||||
void set_proxy_bearer_token_auth(const std::string &token);
|
||||
void set_no_proxy(const std::vector<std::string> &patterns);
|
||||
void set_proxy_digest_auth(const std::string &username,
|
||||
const std::string &password); // SSL builds only
|
||||
|
||||
// Timeouts
|
||||
void set_read_timeout(time_t sec, time_t usec = 0);
|
||||
void set_write_timeout(time_t sec, time_t usec = 0);
|
||||
|
||||
Reference in new issue
Block a user