Skip to content

[BUG] route.fulfill failed with TimeoutError if the response headers contains newline #2358

@char101

Description

@char101

Context:

  • Playwright Version: 1.0.2
  • Operating System: Windows
  • Node version: 14.2.0
  • Browser: chromium

Code Snippet

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const context = await browser.newContext();
  await context.route('**/*', async route => {
    route.fulfill({
      status: 200,
      headers: {
        x: 'a\nb',
      },
      body: '<h1>Title</h1>',
    });
  });
  const page = await context.newPage();
  await page.goto('http://localhost/');
  console.log(await page.content());
  await browser.close();
})();

Describe the bug

route.fulfill hang if fed with response containing newline in its value but on the other hand response.headers() joins multiple headers (like multiple set-cookie headers) into a single line separated with newline.

set-cookie: a
set-cookie: b

becomes

{'set-cookie': 'a\nb'}

when fetch via response.headers().
I think there should be a standard on how to handle header field with multiple values. Having it returns and receive Array is better in my opinion.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions