Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/root/api/starting_envoy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,34 @@ Specify whether to use Happy Eyeballs when multiple IP stacks may be supported.
// Swift
builder.enableHappyEyeballs(true)

~~~~~~~~~~~~~~~~~~~~~~~
``enableGzip``
~~~~~~~~~~~~~~~~~~~~~~~

Specify whether to enable transparent response Gzip decompression. Defaults to true.

**Example**::

// Kotlin
builder.enableGzip(false)

// Swift
builder.enableGzip(false)

~~~~~~~~~~~~~~~~~~~~~~~
``enableBrotli``
~~~~~~~~~~~~~~~~~~~~~~~

Specify whether to enable transparent response Brotli decompression. Defaults to false.

**Example**::

// Kotlin
builder.enableBrotli(true)

// Swift
builder.enableBrotli(true)

~~~~~~~~~~~~~~~~~~~~~~~~~~
``enableInterfaceBinding``
~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
4 changes: 2 additions & 2 deletions docs/root/intro/version_history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Features:
- Android & iOS: add support for registering a platform KV store (:issue: `#2134 <2134>`) (:issue: `#2335 <2335>`)
- api: add option to extend the keepalive timeout when any frame is received on the owning HTTP/2 connection. (:issue:`#2229 <2229>`)
- api: add option to control whether Envoy should drain connections after a soft DNS refresh completes. (:issue:`#2225 <2225>`, :issue:`#2242 <2242>`)
- api: add option to disable the gzip decompressor. (:issue: `#2321 <2321>`)
- api: add option to enable the brotli decompressor. (:issue `#2342 <2342>`)
- api: add option to disable the gzip decompressor. (:issue: `#2321 <2321>`) (:issue: `#2349 <2349>`)
- api: add option to enable the brotli decompressor. (:issue `#2342 <2342>`) (:issue: `#2349 <2349>`)
- configuration: enable h2 ping by default. (:issue: `#2270 <2270>`)
- android: enable the filtering of unroutable families by default. (:issues: `#2267 <2267>`)
- instrumentation: add timers and warnings to platform-provided callbacks (:issue: `#2300 <2300>`)
Expand Down
14 changes: 14 additions & 0 deletions library/objective-c/EnvoyConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ - (instancetype)initWithAdminInterfaceEnabled:(BOOL)adminInterfaceEnabled
dnsMinRefreshSeconds:(UInt32)dnsMinRefreshSeconds
dnsPreresolveHostnames:(NSString *)dnsPreresolveHostnames
enableHappyEyeballs:(BOOL)enableHappyEyeballs
enableGzip:(BOOL)enableGzip
enableBrotli:(BOOL)enableBrotli
enableInterfaceBinding:(BOOL)enableInterfaceBinding
enableDrainPostDnsRefresh:(BOOL)enableDrainPostDnsRefresh
enforceTrustChainVerification:(BOOL)enforceTrustChainVerification
Expand Down Expand Up @@ -56,6 +58,8 @@ - (instancetype)initWithAdminInterfaceEnabled:(BOOL)adminInterfaceEnabled
self.dnsMinRefreshSeconds = dnsMinRefreshSeconds;
self.dnsPreresolveHostnames = dnsPreresolveHostnames;
self.enableHappyEyeballs = enableHappyEyeballs;
self.enableGzip = enableGzip;
self.enableBrotli = enableBrotli;
self.enableInterfaceBinding = enableInterfaceBinding;
self.enableDrainPostDnsRefresh = enableDrainPostDnsRefresh;
self.enforceTrustChainVerification = enforceTrustChainVerification;
Expand Down Expand Up @@ -104,6 +108,16 @@ - (nullable NSString *)resolveTemplate:(NSString *)templateYAML {
[customFilters appendString:filterConfig];
}

if (self.enableGzip) {
NSString *gzipFilterInsert = [[NSString alloc] initWithUTF8String:gzip_config_insert];
[customFilters appendString:gzipFilterInsert];
}

if (self.enableBrotli) {
NSString *brotliFilterInsert = [[NSString alloc] initWithUTF8String:brotli_config_insert];
[customFilters appendString:brotliFilterInsert];
}

BOOL hasDirectResponses = self.directResponses.length > 0;
if (hasDirectResponses) {
templateYAML = [templateYAML stringByReplacingOccurrencesOfString:@"#{fake_remote_responses}"
Expand Down
4 changes: 4 additions & 0 deletions library/objective-c/EnvoyEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ extern const int kEnvoyFilterResumeStatusResumeIteration;
@property (nonatomic, strong) NSString *dnsPreresolveHostnames;
@property (nonatomic, assign) UInt32 dnsRefreshSeconds;
@property (nonatomic, assign) BOOL enableHappyEyeballs;
@property (nonatomic, assign) BOOL enableGzip;
@property (nonatomic, assign) BOOL enableBrotli;
@property (nonatomic, assign) BOOL enableInterfaceBinding;
@property (nonatomic, assign) BOOL enableDrainPostDnsRefresh;
@property (nonatomic, assign) BOOL enforceTrustChainVerification;
Expand Down Expand Up @@ -390,6 +392,8 @@ extern const int kEnvoyFilterResumeStatusResumeIteration;
dnsMinRefreshSeconds:(UInt32)dnsMinRefreshSeconds
dnsPreresolveHostnames:(NSString *)dnsPreresolveHostnames
enableHappyEyeballs:(BOOL)enableHappyEyeballs
enableGzip:(BOOL)enableGzip
enableBrotli:(BOOL)enableBrotli
enableInterfaceBinding:(BOOL)enableInterfaceBinding
enableDrainPostDnsRefresh:(BOOL)enableDrainPostDnsRefresh
enforceTrustChainVerification:(BOOL)enforceTrustChainVerification
Expand Down
26 changes: 26 additions & 0 deletions library/swift/EngineBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ open class EngineBuilder: NSObject {
private var dnsPreresolveHostnames: String = "[]"
private var dnsRefreshSeconds: UInt32 = 60
private var enableHappyEyeballs: Bool = true
private var enableGzip: Bool = true
private var enableBrotli: Bool = false
private var enableInterfaceBinding: Bool = false
private var enforceTrustChainVerification: Bool = true
private var enableDrainPostDnsRefresh: Bool = false
Expand Down Expand Up @@ -167,6 +169,28 @@ open class EngineBuilder: NSObject {
return self
}

/// Specify whether to do gzip response decompression or not. Defaults to true.
///
/// - parameter enableGzip: whether or not to gunzip responses.
///
/// - returns: This builder.
@discardableResult
public func enableGzip(_ enableGzip: Bool) -> Self {
self.enableGzip = enableGzip
return self
}

/// Specify whether to do brotli response decompression or not. Defaults to false.
///
/// - parameter enableBrotli: whether or not to brotli decompress responses.
///
/// - returns: This builder.
@discardableResult
public func enableBrotli(_ enableBrotli: Bool) -> Self {
self.enableBrotli = enableBrotli
return self
}

/// Specify whether sockets may attempt to bind to a specific interface, based on network
/// conditions.
///
Expand Down Expand Up @@ -472,6 +496,8 @@ open class EngineBuilder: NSObject {
dnsMinRefreshSeconds: self.dnsMinRefreshSeconds,
dnsPreresolveHostnames: self.dnsPreresolveHostnames,
enableHappyEyeballs: self.enableHappyEyeballs,
enableGzip: self.enableGzip,
enableBrotli: self.enableBrotli,
enableInterfaceBinding: self.enableInterfaceBinding,
enableDrainPostDnsRefresh: self.enableDrainPostDnsRefresh,
enforceTrustChainVerification: self.enforceTrustChainVerification,
Expand Down
14 changes: 14 additions & 0 deletions test/swift/EngineBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ final class EngineBuilderTests: XCTestCase {
dnsMinRefreshSeconds: 100,
dnsPreresolveHostnames: "[test]",
enableHappyEyeballs: true,
enableGzip: true,
enableBrotli: false,
enableInterfaceBinding: true,
enableDrainPostDnsRefresh: false,
enforceTrustChainVerification: false,
Expand Down Expand Up @@ -518,6 +520,10 @@ final class EngineBuilderTests: XCTestCase {

XCTAssertFalse(resolvedYAML.contains("admin: *admin_interface"))

// Decompression
XCTAssertTrue(resolvedYAML.contains("decompressor.v3.Gzip"))
XCTAssertFalse(resolvedYAML.contains("decompressor.v3.Brotli"))

// Metadata
XCTAssertTrue(resolvedYAML.contains("device_os: iOS"))
XCTAssertTrue(resolvedYAML.contains("app_version: v1.2.3"))
Expand Down Expand Up @@ -547,6 +553,8 @@ final class EngineBuilderTests: XCTestCase {
dnsMinRefreshSeconds: 100,
dnsPreresolveHostnames: "[test]",
enableHappyEyeballs: false,
enableGzip: false,
enableBrotli: true,
enableInterfaceBinding: false,
enableDrainPostDnsRefresh: true,
enforceTrustChainVerification: true,
Expand Down Expand Up @@ -579,6 +587,10 @@ final class EngineBuilderTests: XCTestCase {
XCTAssertTrue(resolvedYAML.contains("&trust_chain_verification VERIFY_TRUST_CHAIN"))
XCTAssertTrue(resolvedYAML.contains("&h2_delay_keepalive_timeout false"))
XCTAssertTrue(resolvedYAML.contains("&enable_drain_post_dns_refresh true"))

// Decompression
XCTAssertFalse(resolvedYAML.contains("decompressor.v3.Gzip"))
XCTAssertTrue(resolvedYAML.contains("decompressor.v3.Brotli"))
}

func testReturnsNilWhenUnresolvedValueInTemplate() {
Expand All @@ -593,6 +605,8 @@ final class EngineBuilderTests: XCTestCase {
dnsMinRefreshSeconds: 100,
dnsPreresolveHostnames: "[test]",
enableHappyEyeballs: false,
enableGzip: false,
enableBrotli: false,
enableInterfaceBinding: false,
enableDrainPostDnsRefresh: false,
enforceTrustChainVerification: true,
Expand Down