async_file 0.1.3

An executor-agnostic async file IO library
Documentation
# async_file Test Server

A minimal Vercel project that serves test files with proper CORS headers for browser-based WASM tests.

## Purpose

Browser-based wasm-bindgen tests need a server that:
1. Serves compressed content (to test `CompressedResponse` error detection)
2. Returns proper CORS headers for `Range` header preflight requests
3. Exposes `Content-Encoding` header to JavaScript

## Deployment

```bash
cd test-server
vercel --prod
```

## Required CORS Headers

**Note:** These headers are only required for cross-origin requests (when the file is served from a different origin than the page). Same-origin requests have full access to all response headers without any special configuration.

### `Access-Control-Allow-Origin: *`

**Why:** Allows cross-origin requests from the browser test runner. Without this, the browser blocks all fetch requests to the server.

### `Access-Control-Allow-Methods: GET, HEAD, OPTIONS`

**Why:** `async_file` uses HEAD requests to fetch metadata (file size) and GET requests with Range headers for partial reads. OPTIONS is required for CORS preflight requests.

### `Access-Control-Allow-Headers: Range`

**Why:** The `Range` header is not a "simple" CORS header, so browsers send a preflight OPTIONS request before any request that includes it. The server must explicitly allow `Range` in the preflight response, otherwise the browser blocks the actual request.

Without this header, you'll see errors like:
```
Request header field range is not allowed by Access-Control-Allow-Headers in preflight response
```

### `Access-Control-Expose-Headers: Content-Length, Content-Range, Content-Encoding`

**Why:** By default, JavaScript can only access a limited set of response headers ("CORS-safelisted" headers). These three headers are essential for `async_file`:

- **Content-Length**: Required to determine file size from HEAD requests
- **Content-Range**: Required to verify partial read responses
- **Content-Encoding**: Required to detect compressed responses and return `CompressedResponse` error

Without exposing these headers, `response.headers().get("Content-Length")` returns `None` in JavaScript even though the header is present in the HTTP response.

## Test Files

- `/test.txt` - Text file that Vercel will compress with gzip/brotli

## Usage in Tests

```rust
set_default_origin("https://asyncfile.vercel.app");
let file = File::open("test.txt", Priority::unit_test()).await?;
let result = file.metadata(Priority::unit_test()).await;
// Should return Err(CompressedResponse("br")) or similar
```