test: content-length is recomputed for postBody override (#16169)
This commit is contained in:
parent
a2fc636f8e
commit
0bab5c60c4
|
|
@ -173,6 +173,25 @@ it.describe('post data', () => {
|
|||
expect((await serverRequest.postBody).toString('utf8')).toBe('doggo');
|
||||
});
|
||||
|
||||
it('should compute content-length from post data', async ({ page, server, browserName }) => {
|
||||
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/16027' });
|
||||
it.fixme(browserName === 'firefox');
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
const data = 'a'.repeat(7500);
|
||||
await page.route('**/*', route => {
|
||||
const headers = route.request().headers();
|
||||
headers['content-type'] = 'application/json';
|
||||
route.continue({ postData: data, headers });
|
||||
});
|
||||
const [serverRequest] = await Promise.all([
|
||||
server.waitForRequest('/sleep.zzz'),
|
||||
page.evaluate(() => fetch('/sleep.zzz', { method: 'PATCH', body: 'birdy' }))
|
||||
]);
|
||||
expect((await serverRequest.postBody).toString('utf8')).toBe(data);
|
||||
expect(serverRequest.headers['content-length']).toBe(String(data.length));
|
||||
expect(serverRequest.headers['content-type']).toBe('application/json');
|
||||
});
|
||||
|
||||
it('should amend method and post data', async ({ page, server }) => {
|
||||
await page.goto(server.EMPTY_PAGE);
|
||||
await page.route('**/*', route => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue