Repository navigation
fix(gaxios): honor maxContentLength and maxRedirects instance defaults #9778
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -343,7 +343,7 @@ describe('🥁 configuration options', () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| scope.done(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| it('should enforce maxContentLength on responses without a Content-Length header', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| it('should enforce maxContentLength on responses without a Content-Length header and from instance defaults', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const body = {hello: 'world'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for (const responseType of [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'json', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -358,6 +358,14 @@ describe('🥁 configuration options', () => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| scope.done(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const defaultScope = nock(url).get('/').reply(200, body); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const client = new Gaxios({maxContentLength: 5}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await assert.rejects( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| client.request({url}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (err: Error) => err instanceof GaxiosError && /limit/.test(err.message), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| defaultScope.done(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+362
to
369
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The pull request description and title mention honoring both
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| it('should support redirects by default', async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request fixes both
maxContentLengthandmaxRedirectsinstance defaults, but the added test only coversmaxContentLength. It would be great to also add a test case verifying thatmaxRedirectsinstance defaults are correctly honored and enforced.