Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cwaldren-ld committed Nov 12, 2024
1 parent bf4f63a commit ecceda3
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,28 @@ LDClientConfigBuilder_HttpProperties_Header(LDClientConfigBuilder b,
char const* key,
char const* value);

/**
* Specifies an HTTP proxy which the client should use to communicate
* with LaunchDarkly.
*
* SDK <-- HTTP, plaintext --> Proxy <-- HTTPS --> LaunchDarkly
*
* This setting affects streaming mode, polling mode, and event delivery.
* The argument should be of the form: 'http://proxy.example.com:8080'.
*
* The scheme must be 'http' and the port is optional (80 if not
* specified.)
*
* The SDK respects the 'http_proxy' environment variable as an alternative
* to this method. If both are set, this method takes precedence.
*
* @param b Client config builder. Must not be NULL.
* @param http_proxy HTTP proxy URL. Must not be NULL.
*/
LD_EXPORT(void)
LDClientConfigBuilder_HttpProperties_HttpProxy(LDClientConfigBuilder b,
char const* http_proxy);

/**
* Sets the TLS options builder. The builder is automatically freed.
*
Expand Down
9 changes: 9 additions & 0 deletions libs/client-sdk/src/bindings/c/builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,15 @@ LDClientConfigBuilder_HttpProperties_Header(LDClientConfigBuilder b,
TO_BUILDER(b)->HttpProperties().Header(key, value);
}

LD_EXPORT(void)
LDClientConfigBuilder_HttpProperties_HttpProxy(LDClientConfigBuilder b,
char const* http_proxy) {
LD_ASSERT_NOT_NULL(b);
LD_ASSERT_NOT_NULL(http_proxy);

TO_BUILDER(b)->HttpProperties().HttpProxy(http_proxy);
}

LD_EXPORT(void)
LDClientConfigBuilder_HttpProperties_Tls(
LDClientConfigBuilder b,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,24 @@ class HttpPropertiesBuilder {
HttpPropertiesBuilder& Tls(TlsBuilder<SDK> builder);

/**
* Sets an HTTP proxy URL.
* @param http_proxy The proxy, for example 'http://proxy.example.com:8080'.
* @return A reference to this builder.
* Specifies an HTTP proxy which the client should use to communicate
* with LaunchDarkly.
*
* SDK <-- HTTP, plaintext --> Proxy <-- HTTPS --> LaunchDarkly
*
* This setting affects streaming mode, polling mode, and event delivery.
* The argument should be of the form: 'http://proxy.example.com:8080'.
*
* The scheme must be 'http' and the port is optional (80 if not
* specified.)
*
* The SDK respects the 'http_proxy' environment variable as an alternative
* to this method. If both are set, this method takes precedence.
*
* @param http_proxy HTTP proxy URL.
*/
HttpPropertiesBuilder& HttpProxy(std::string http_proxy);

/**
* Build a set of HttpProperties.
* @return The built properties.
*/
[[nodiscard]] built::HttpProperties Build() const;

private:
Expand Down
2 changes: 1 addition & 1 deletion libs/common/src/config/http_properties_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ built::HttpProperties HttpPropertiesBuilder<SDK>::Build() const {
response_timeout_,
std::move(headers),
tls_.Build(),
http_proxy_ ? *http_proxy_ : HttpProxyFromEnv()};
http_proxy_.has_value() ? http_proxy_ : HttpProxyFromEnv()};
}

template class TlsBuilder<config::shared::ClientSDK>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ void StreamingDataSource::StartAsync(
client_builder.custom_ca_file(*ca_file);
}

if (http_config_.HttpProxy()) {
client_builder.http_proxy(*http_config_.HttpProxy());
}

auto weak_self = weak_from_this();

client_builder.receiver([weak_self](launchdarkly::sse::Event const& event) {
Expand Down
7 changes: 0 additions & 7 deletions libs/server-sent-events/src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,13 +660,6 @@ std::shared_ptr<Client> Builder::build() {
return nullptr;
}

// Although a proxy might talk HTTP on port 443, that would be
// very weird and is likely a misconfiguration.
if (http_proxy_components->has_port() &&
http_proxy_components->port() == "443") {
return nullptr;
}

tcp_host = http_proxy_components->host();

// If they didn't specify a port, then the uri is of the form
Expand Down

0 comments on commit ecceda3

Please sign in to comment.