Skip to content

Commit

Permalink
cherry-pick(#9806): ignoreHTTPSErrors after redirects
Browse files Browse the repository at this point in the history
PR #9806 SHA dd0dae6

Fixes #9768
  • Loading branch information
yury-s authored and aslushnikov committed Oct 27, 2021
1 parent 810fa55 commit cf98ab7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/playwright-core/src/server/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,17 @@ 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,
maxRedirects: options.maxRedirects - 1,
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) {
Expand Down
7 changes: 7 additions & 0 deletions tests/global-fetch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit cf98ab7

Please sign in to comment.