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

# TestCacheWriteDelegatingHandler

> Handler for capturing HTTP responses and writing them to files.

## Definition

**Assembly:** CloudNimble.Breakdance.Assemblies.dll

**Namespace:** CloudNimble.Breakdance.Assemblies.Http

**Inheritance:** CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotCaptureHandler

## Syntax

```csharp theme={"dark"}
CloudNimble.Breakdance.Assemblies.Http.TestCacheWriteDelegatingHandler
```

## Summary

Handler for capturing HTTP responses and writing them to files.

## Remarks

This class is deprecated. Use [ResponseSnapshotCaptureHandler](https://easyaf.nimbleapps.cloud/breakdance/api-reference/CloudNimble/Breakdance/Assemblies/Http/ResponseSnapshotCaptureHandler.md) instead.

## Constructors

### &#x20;.ctor

Creates a new [TestCacheWriteDelegatingHandler](https://easyaf.nimbleapps.cloud/breakdance/api-reference/CloudNimble/Breakdance/Assemblies/Http/TestCacheWriteDelegatingHandler.md) with the specified root folder path.

#### Syntax

```csharp theme={"dark"}
public TestCacheWriteDelegatingHandler(string responseFilesPath)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `responseFilesPath` | `string` | Root folder path for storing static response files. |

#### Remarks

This constructor is deprecated. Use [ResponseSnapshotCaptureHandler](https://easyaf.nimbleapps.cloud/breakdance/api-reference/CloudNimble/Breakdance/Assemblies/Http/ResponseSnapshotCaptureHandler.md) instead.

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotCaptureHandler`

Creates a new [ResponseSnapshotCaptureHandler](https://easyaf.nimbleapps.cloud/breakdance/api-reference/CloudNimble/Breakdance/Assemblies/Http/ResponseSnapshotCaptureHandler.md) that saves response snapshots to the specified path.

#### Syntax

```csharp theme={"dark"}
public ResponseSnapshotCaptureHandler(string responseSnapshotsPath)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `responseSnapshotsPath` | `string` | Root folder path for storing response snapshot files. |

### &#x20;.ctor Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotHandlerBase`

Creates a new [ResponseSnapshotHandlerBase](https://easyaf.nimbleapps.cloud/breakdance/api-reference/CloudNimble/Breakdance/Assemblies/Http/ResponseSnapshotHandlerBase.md) with the specified snapshot storage path.

#### Syntax

```csharp theme={"dark"}
public ResponseSnapshotHandlerBase(string responseSnapshotsPath)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `responseSnapshotsPath` | `string` | Root folder path for storing response snapshot files. |

#### Examples

```csharp theme={"dark"}
var handler = new ResponseSnapshotReplayHandler("TestData/Snapshots");
var client = new HttpClient(handler);
```

## Properties

### &#x20;ResponseSnapshotsPath Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotHandlerBase`

Gets the root folder path where response snapshot files are stored.

#### Syntax

```csharp theme={"dark"}
public string ResponseSnapshotsPath { get; private set; }
```

#### Property Value

Type: `string`

## Methods

### &#x20;GetFileExtensionString Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotHandlerBase`

Maps the MediaType header in the [HttpRequestMessage](https://learn.microsoft.com/dotnet/api/system.net.http.httprequestmessage) to a known list of file extensions.

#### Syntax

```csharp theme={"dark"}
public static string GetFileExtensionString(System.Net.Http.HttpRequestMessage request)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `request` | `System.Net.Http.HttpRequestMessage` | The request to examine. |

#### Returns

Type: `string`
The file extension string for the request's Accept header.

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when request is null. |

### &#x20;GetPathInfo Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotHandlerBase`

Parses the RequestUri in the [HttpRequestMessage](https://learn.microsoft.com/dotnet/api/system.net.http.httprequestmessage) into a [Path](https://learn.microsoft.com/dotnet/api/system.io.path)-safe string
suitable for storing response snapshots on the file system.

#### Syntax

```csharp theme={"dark"}
internal static (string, string) GetPathInfo(System.Net.Http.HttpRequestMessage request, string responseSnapshotsPath)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `request` | `System.Net.Http.HttpRequestMessage` | The [HttpRequestMessage](https://learn.microsoft.com/dotnet/api/system.net.http.httprequestmessage) to parse. |
| `responseSnapshotsPath` | `string` | Root folder for storing snapshot files. |

#### Returns

Type: `(string, string)`
A tuple containing the directory path and file path components.

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentException` | Thrown when the request has an invalid RequestUri. |
| `InvalidOperationException` | Thrown when the URI cannot be converted to a valid file path. |

### &#x20;GetResponseMediaTypeString Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotHandlerBase`

Maps the file extension in the specified path to a known list of media types.

#### Syntax

```csharp theme={"dark"}
public static string GetResponseMediaTypeString(string filePath)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `filePath` | `string` | The file path to examine. |

#### Returns

Type: `string`
The MIME type string for the file extension.

### &#x20;SendAsync Override

> [!NOTE]
>
> Inherited from `CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotCaptureHandler`

Sends the request to the actual endpoint and captures the response as a snapshot file.

#### Syntax

```csharp theme={"dark"}
protected override System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `request` | `System.Net.Http.HttpRequestMessage` | The [HttpRequestMessage](https://learn.microsoft.com/dotnet/api/system.net.http.httprequestmessage) being intercepted. |
| `cancellationToken` | `System.Threading.CancellationToken` | Token for cancelling the asynchronous operation. |

#### Returns

Type: `System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>`
The [HttpResponseMessage](https://learn.microsoft.com/dotnet/api/system.net.http.httpresponsemessage) from the actual endpoint.

#### Exceptions

| Exception | Description |
| - | - |
| `ArgumentNullException` | Thrown when *request* is null. |

### &#x20;SendAsyncInternal Inherited

> [!NOTE]
>
> Inherited from `CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotCaptureHandler`

Allows test projects to call the otherwise inaccessible `CancellationToken)` method directly.

#### Syntax

```csharp theme={"dark"}
internal System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsyncInternal(System.Net.Http.HttpRequestMessage request)
```

#### Parameters

| Name | Type | Description |
| - | - | - |
| `request` | `System.Net.Http.HttpRequestMessage` | The [HttpRequestMessage](https://learn.microsoft.com/dotnet/api/system.net.http.httprequestmessage) to process. |

#### Returns

Type: `System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>`
The [HttpResponseMessage](https://learn.microsoft.com/dotnet/api/system.net.http.httpresponsemessage) from the actual endpoint.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.