> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# HTTP Configuration

> Configure HTTP retry, timeout, and response compression settings for the PlayFab Services C SDK using PFSetHttpRetrySettings and related APIs.

The PlayFab Services SDK provides functions to configure how HTTP requests are made, including automatic retry behavior and response compression. These settings are global and apply to all PlayFab API calls made by the SDK.

Configure HTTP settings after calling [**PFInitialize**](/services/playfab/api-references/c/pfcore/functions/pfinitialize) and [**PFServicesInitialize**](/services/playfab/api-references/c/pfservices/functions/pfservicesinitialize), but before making any API calls.

## Retry settings

The **PFHttpRetrySettings** struct controls how the SDK handles transient HTTP failures, such as throttling errors (HTTP 429). By default, the SDK automatically retries these failures with backoff.

| Field                        | Type       | Default | Description                                                                                                                   |
| ---------------------------- | ---------- | ------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `allowRetry`                 | `bool`     | `true`  | Controls whether the SDK automatically retries select errors. Some errors are never retried and are always returned directly. |
| `minimumRetryDelayInSeconds` | `uint32_t` | 2       | The minimum number of seconds to wait before retrying a failed request. Can't be set below 2 seconds.                         |
| `timeoutWindowInSeconds`     | `uint32_t` | 20      | The maximum number of seconds the SDK attempts retries before returning the error to the caller.                              |

For more information on which errors the SDK retries automatically, see [Handling PlayFab Errors](/services/playfab/sdks/c/errors).

### Set retry settings

Call **PFSetHttpRetrySettings** to customize the retry behavior. For example, to increase the retry window for calls that can tolerate longer waits:

```cpp theme={null}
PFHttpRetrySettings retrySettings{};
retrySettings.allowRetry = true;
retrySettings.minimumRetryDelayInSeconds = 4;
retrySettings.timeoutWindowInSeconds = 60;

HRESULT hr = PFSetHttpRetrySettings(&retrySettings);
if (FAILED(hr))
{
    // Handle error
}
```

### Get retry settings

Call **PFGetHttpRetrySettings** to retrieve the current retry configuration:

```cpp theme={null}
PFHttpRetrySettings currentSettings{};
HRESULT hr = PFGetHttpRetrySettings(&currentSettings);
if (SUCCEEDED(hr))
{
    printf("Retry enabled: %s\n", currentSettings.allowRetry ? "true" : "false");
    printf("Min delay: %u seconds\n", currentSettings.minimumRetryDelayInSeconds);
    printf("Timeout window: %u seconds\n", currentSettings.timeoutWindowInSeconds);
}
```

### Disable automatic retries

If you want to handle all retry logic yourself, disable automatic retries:

```cpp theme={null}
PFHttpRetrySettings retrySettings{};
retrySettings.allowRetry = false;
retrySettings.minimumRetryDelayInSeconds = 2;
retrySettings.timeoutWindowInSeconds = 20;

HRESULT hr = PFSetHttpRetrySettings(&retrySettings);
```

## HTTP settings

The **PFHttpSettings** struct controls general HTTP behavior for all SDK requests.

| Field                        | Type   | Default | Description                                                                                                                         |
| ---------------------------- | ------ | ------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| `requestResponseCompression` | `bool` | `false` | When enabled, the SDK requests that API responses be gzip-compressed by setting the `Accept-Encoding` header to `application/gzip`. |

### Enable response compression

Enabling response compression can reduce bandwidth usage, which is useful for calls that return large payloads. Call **PFSetHttpSettings** to enable it:

```cpp theme={null}
PFHttpSettings httpSettings{};
httpSettings.requestResponseCompression = true;

HRESULT hr = PFSetHttpSettings(&httpSettings);
if (FAILED(hr))
{
    // Handle error
}
```

<Note>
  To decompress a compressed response, **HCHttpCallResponseSetGzipCompressed** must be called before calling **HCHttpCallPerformAsync**.
</Note>

### Get HTTP settings

Call **PFGetHttpSettings** to retrieve the current HTTP configuration:

```cpp theme={null}
PFHttpSettings currentSettings{};
HRESULT hr = PFGetHttpSettings(&currentSettings);
if (SUCCEEDED(hr))
{
    printf("Response compression: %s\n", currentSettings.requestResponseCompression ? "enabled" : "disabled");
}
```

## Typical initialization pattern

The following example shows where HTTP configuration fits into the overall SDK initialization flow:

```cpp theme={null}
// 1. Initialize the SDK
HRESULT hr = PFInitialize(nullptr);
hr = PFServicesInitialize(nullptr);

// 2. Configure HTTP settings before making any API calls
PFHttpRetrySettings retrySettings{};
retrySettings.allowRetry = true;
retrySettings.minimumRetryDelayInSeconds = 2;
retrySettings.timeoutWindowInSeconds = 30;
PFSetHttpRetrySettings(&retrySettings);

PFHttpSettings httpSettings{};
httpSettings.requestResponseCompression = true;
PFSetHttpSettings(&httpSettings);

// 3. Create service config and begin making API calls
// ...
```


## Related topics

- [Content Test Application (CTA) Stream Configuration Overview](/build/core-features/common/game-streaming/game-streaming-content-test-application-stream-config.md)
- [Running an HTTP server for testing](/services/playfab/identity/player-identity/platform-specific-authentication/running-an-http-server-for-testing.md)
- [Content & Configuration Reads Meter API Description](/services/playfab/pricing/meters/file-reads.md)
- [Content & Configuration Writes Meter API Description](/services/playfab/pricing/meters/file-writes.md)
- [Marketplace Error Handling](/services/playfab/economy-monetization/economy-v2/marketplace/marketplace-error-handling.md)
