# Storefront HTTP client

# Storefront HTTP client

# Storefront HTTP client

The authenticated HTTP client for the Storefront push, media and identity routes.


## media_timeout

```rust
pub fn media_timeout(bytes : u64) -> Duration;
```

Timeout for a media upload of `bytes`: 60 s plus 1 s per 256 KiB, so a
100 MiB file gets about 7 minutes instead of the fixed 30 s.


## RetryPolicy

```rust
pub struct RetryPolicy { pub max_attempts : u32, pub base_delay : Duration, }
```

Bounded retry for transient failures: connect errors, timeouts, and
429/502/503/504. The delay doubles each attempt.


## StorefrontClient

```rust
pub struct StorefrontClient { http : reqwest::Client, base_url : String, token : String, retry : RetryPolicy, }
```

An authenticated client for the Storefront `POST /api/pages/push` contract
(`docs/api.md`, `src/content_push.rs` in the Storefront repo). Every call
sends `Accept: application/json` because Storefront otherwise answers a
browser-shaped request with an HTML error page, which would
collapse a real failure into an unreadable body.


## StorefrontClient::post_multipart

```rust
pub async fn post_multipart(& self, path : & str, size : u64, build_form : impl Fn() -> Form,) -> Result < Response, ClientError >;
```

`build_form` runs once per attempt because sending consumes a `Form`.
`size` (bytes) scales the request timeout via `media_timeout`.
