File Operations
Content-Disposition Header
DownloadValidateMedium
Description
Test Content-Disposition header parsing. Verify filename extraction including special characters and encoding.
Test Scenario
// Playwright: Parse Content-Disposition
const response = await request.get('/api/v1/files/download?format=csv');
const disposition = response.headers()['content-disposition'];
expect(disposition).toContain('attachment');
// Parse filename from header
const filenameMatch = disposition.match(/filename="?([^";]+)"?/);
expect(filenameMatch).not.toBeNull();
const filename = filenameMatch[1];
expect(filename).toMatch(/\.csv$/);
console.log('Downloaded:', filename);Endpoint
/api/v1/files/download?format=csvTesting Tips
- •Content-Disposition can be inline or attachment
- •Filename may be URL-encoded for special chars
- •Check for filename* parameter (RFC 5987)
- •Handle missing Content-Disposition gracefully
// 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: content-disposition
2 frameworks available
API Playground
Send requests and inspect responses
Endpoint: /api/v1/files/download?format=csv
Press Enter to send