Skip to content

Commit

Permalink
feat: option to force HTTP/1(.1) protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
stefan-guggisberg committed Feb 27, 2020
1 parent c461417 commit 501d6a2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,4 +406,21 @@ describe('Fetch Tests', () => {
assert.equal(json['user-agent'], customUserAgent);
assert(!resp.fromCache);
});

it('forcing HTTP/1(.1) works', async () => {
// endpoint supporting http2 & http1
const url = 'https://www.nghttp2.org/httpbin/status/200';
// default context defaults to http2
let resp = await fetch(url);
assert.equal(resp.status, 200);
assert.equal(resp.httpVersion, 2);

// custom context forces http1
const { fetch: customFetch } = context({
httpsProtocols: ['http1'],
});
resp = await customFetch(url);
assert.equal(resp.status, 200);
assert.equal(resp.httpVersion, 1);
});
});

0 comments on commit 501d6a2

Please sign in to comment.