fix(fetch): ignoreHTTPSErrors after redirects (#9806)

This commit is contained in:
Yury Semikhatsky 2021-10-26 23:20:52 -07:00 committed by GitHub
parent c8addef03a
commit dd0dae623b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -231,7 +231,7 @@ export abstract class FetchRequest extends SdkObject {
delete headers[`content-type`];
}
const redirectOptions: http.RequestOptions & { maxRedirects: number, deadline: number } = {
const redirectOptions: https.RequestOptions & { maxRedirects: number, deadline: number } = {
method,
headers,
agent: options.agent,
@ -239,6 +239,9 @@ export abstract class FetchRequest extends SdkObject {
timeout: options.timeout,
deadline: options.deadline
};
// rejectUnauthorized = undefined is treated as true in node 12.
if (options.rejectUnauthorized === false)
redirectOptions.rejectUnauthorized = false;
// HTTP-redirect fetch step 4: If locationURL is null, then return response.
if (response.headers.location) {

View File

@ -146,6 +146,13 @@ it('should support global ignoreHTTPSErrors option', async ({ playwright, httpsS
expect(response.status()).toBe(200);
});
it('should propagate ignoreHTTPSErrors on redirects', async ({ playwright, httpsServer }) => {
httpsServer.setRedirect('/redir', '/empty.html');
const request = await playwright.request.newContext();
const response = await request.get(httpsServer.PREFIX + '/redir', { ignoreHTTPSErrors: true });
expect(response.status()).toBe(200);
});
it('should resolve url relative to gobal baseURL option', async ({ playwright, server }) => {
const request = await playwright.request.newContext({ baseURL: server.PREFIX });
const response = await request.get('/empty.html');