Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for Accept-Encoding: gzip in HTTP headers #497

Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

### Unreleased
* Added support for `Accept-Encoding: gzip` in HTTP headers

### 6.2.0 / 2024-09-24
* Added query support for folders
* Added dependency on `ostruct` gem
Expand Down
3 changes: 2 additions & 1 deletion lib/nylas/handler/http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def build_request(
def default_headers
@default_headers ||= {
"X-Nylas-API-Wrapper" => "ruby",
"User-Agent" => "Nylas Ruby SDK #{Nylas::VERSION} - #{RUBY_VERSION}"
"User-Agent" => "Nylas Ruby SDK #{Nylas::VERSION} - #{RUBY_VERSION}",
"Accept-Encoding" => "gzip"
}
end

Expand Down
21 changes: 14 additions & 7 deletions spec/nylas/handler/http_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class TestHttpClient
it "returns the default headers" do
expect(http_client.send(:default_headers)).to eq(
"User-Agent" => "Nylas Ruby SDK 1.0.0 - 5.0.0",
"X-Nylas-API-Wrapper" => "ruby"
"X-Nylas-API-Wrapper" => "ruby",
"Accept-Encoding" => "gzip"
)
end
end
Expand Down Expand Up @@ -64,7 +65,8 @@ class TestHttpClient
expect(request[:headers]).to eq(
"User-Agent" => "Nylas Ruby SDK 1.0.0 - 5.0.0",
"X-Nylas-API-Wrapper" => "ruby",
"Authorization" => "Bearer fake-key"
"Authorization" => "Bearer fake-key",
"Accept-Encoding" => "gzip"
)
end

Expand All @@ -84,7 +86,8 @@ class TestHttpClient
"X-Nylas-API-Wrapper" => "ruby",
"Authorization" => "Bearer fake-key",
"X-Custom-Header" => "custom-value",
"X-Custom-Header-2" => "custom-value-2"
"X-Custom-Header-2" => "custom-value-2",
"Accept-Encoding" => "gzip"
)
end

Expand All @@ -98,7 +101,8 @@ class TestHttpClient
expect(request[:headers]).to eq(
"User-Agent" => "Nylas Ruby SDK 1.0.0 - 5.0.0",
"X-Nylas-API-Wrapper" => "ruby",
"Authorization" => "Bearer fake-key"
"Authorization" => "Bearer fake-key",
"Accept-Encoding" => "gzip"
)
expect(request[:timeout]).to eq(30)
end
Expand All @@ -114,7 +118,8 @@ class TestHttpClient
expect(request[:headers]).to eq(
"User-Agent" => "Nylas Ruby SDK 1.0.0 - 5.0.0",
"X-Nylas-API-Wrapper" => "ruby",
"Authorization" => "Bearer fake-key"
"Authorization" => "Bearer fake-key",
"Accept-Encoding" => "gzip"
)
end

Expand All @@ -131,7 +136,8 @@ class TestHttpClient
"User-Agent" => "Nylas Ruby SDK 1.0.0 - 5.0.0",
"X-Nylas-API-Wrapper" => "ruby",
"Authorization" => "Bearer fake-key",
"Content-type" => "application/json"
"Content-type" => "application/json",
"Accept-Encoding" => "gzip"
)
end

Expand All @@ -146,7 +152,8 @@ class TestHttpClient
expect(request[:headers]).to eq(
"User-Agent" => "Nylas Ruby SDK 1.0.0 - 5.0.0",
"X-Nylas-API-Wrapper" => "ruby",
"Authorization" => "Bearer fake-key"
"Authorization" => "Bearer fake-key",
"Accept-Encoding" => "gzip"
)
end
end
Expand Down
Loading