Skip to main content
File Operations

Range Request (Resume Download)

DownloadValidateHard

Description

Implement partial file download using Range headers. This enables resume functionality for interrupted downloads.

Test Scenario

// Playwright: Range request for partial download
// First, get file size
const headResponse = await request.head('/api/v1/files/download?format=large&size=1');
const totalSize = parseInt(headResponse.headers()['content-length']);

// Download first 1KB
const response = await request.get('/api/v1/files/download?format=large&size=1', {
  headers: { 'Range': 'bytes=0-1023' }
});

expect(response.status()).toBe(206);
expect(response.headers()['content-range']).toMatch(/bytes 0-1023\/\d+/);

const chunk = await response.body();
expect(chunk.length).toBe(1024);

// Download next chunk
const response2 = await request.get('/api/v1/files/download?format=large&size=1', {
  headers: { 'Range': 'bytes=1024-2047' }
});
expect(response2.status()).toBe(206);
Endpoint/api/v1/files/download?format=large&size=1

Testing Tips

  • •Use Range header: bytes=0-1023
  • •Check for 206 Partial Content status
  • •Verify Content-Range header format
  • •Combine chunks to reconstruct full file
// Playwright API Testing - File Operations
import { 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: range-request

2 frameworks available

API Playground

Send requests and inspect responses

Endpoint: /api/v1/files/download?format=large&size=1

Press Enter to send