Skip to main content

Content-Disposition Header

Test Content-Disposition header parsing. Verify filename extraction including special characters and encoding.

MEDIUM

🔗 Endpoint

GET /api/v1/files/download?format=csvOpen in browser ↗

💡 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

💻 Code Example

// 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);

🖥️ curl Command

curl -O "https://api.qa-practice.dev/api/v1/files/download?format=csv"