File Operations
Chunked Transfer Encoding
DownloadValidateExpert
Description
Handle Transfer-Encoding: chunked responses where Content-Length is not known in advance.
Test Scenario
// Playwright: Handle chunked transfer
const response = await request.get('/api/v1/files/download?format=stream');
// Note: Content-Length may be absent for chunked encoding
expect(response.headers()['transfer-encoding']).toBe('chunked');
// Collect all chunks
const chunks: string[] = [];
const body = await response.text();
// Body contains all chunks concatenated
const lines = body.trim().split('\n');
expect(lines.length).toBe(10); // 10 chunks
lines.forEach((line, i) => {
expect(line).toContain(`Chunk ${i + 1}`);
});Endpoint
/api/v1/files/download?format=streamTesting Tips
- •Chunked responses have no Content-Length
- •Each chunk starts with size in hex
- •Final chunk has size 0
- •Use streaming APIs to process chunks
// Playwright API Testing - File Operationsimport { test, expect } from '@playwright/test';test('File download', async ({ request }) => {const response = await request.get('/api/files/download/report.pdf');expect(response.ok()).toBeTruthy();expect(response.headers()['content-type']).toContain('application/pdf');const buffer = await response.body();expect(buffer.length).toBeGreaterThan(0);});
Challenge ID: chunked-transfer
2 frameworks available
API Playground
Send requests and inspect responses
Endpoint: /api/v1/files/download?format=stream
Press Enter to send