Skip to main content

Definition

Assembly: CloudNimble.Breakdance.Assemblies.dll Namespace: CloudNimble.Breakdance.Assemblies.Http Inheritance: CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotReplayHandler

Syntax

CloudNimble.Breakdance.Assemblies.Http.TestCacheReadDelegatingHandler

Summary

Handler for returning HTTP responses from cached files.

Remarks

This class is deprecated. Use ResponseSnapshotReplayHandler instead.

Constructors

.ctor

Creates a new TestCacheReadDelegatingHandler with the specified root folder path.

Syntax

public TestCacheReadDelegatingHandler(string responseFilesPath)

Parameters

NameTypeDescription
responseFilesPathstringRoot folder path for storing static response files.

Remarks

This constructor is deprecated. Use ResponseSnapshotReplayHandler instead.

.ctor Inherited

Inherited from CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotReplayHandler
Creates a new ResponseSnapshotReplayHandler that reads response snapshots from the specified path.

Syntax

public ResponseSnapshotReplayHandler(string responseSnapshotsPath)

Parameters

NameTypeDescription
responseSnapshotsPathstringRoot folder path containing response snapshot files.

.ctor Inherited

Inherited from CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotHandlerBase
Creates a new ResponseSnapshotHandlerBase with the specified snapshot storage path.

Syntax

public ResponseSnapshotHandlerBase(string responseSnapshotsPath)

Parameters

NameTypeDescription
responseSnapshotsPathstringRoot folder path for storing response snapshot files.

Examples

var handler = new ResponseSnapshotReplayHandler("TestData/Snapshots");
var client = new HttpClient(handler);

Properties

ResponseSnapshotsPath Inherited

Inherited from CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotHandlerBase
Gets the root folder path where response snapshot files are stored.

Syntax

public string ResponseSnapshotsPath { get; private set; }

Property Value

Type: string

Methods

GetFileExtensionString Inherited

Inherited from CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotHandlerBase
Maps the MediaType header in the HttpRequestMessage to a known list of file extensions.

Syntax

public static string GetFileExtensionString(System.Net.Http.HttpRequestMessage request)

Parameters

NameTypeDescription
requestSystem.Net.Http.HttpRequestMessageThe request to examine.

Returns

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

Exceptions

ExceptionDescription
ArgumentNullExceptionThrown when request is null.

GetPathInfo Inherited

Inherited from CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotHandlerBase
Parses the RequestUri in the HttpRequestMessage into a Path-safe string suitable for storing response snapshots on the file system.

Syntax

internal static (string, string) GetPathInfo(System.Net.Http.HttpRequestMessage request, string responseSnapshotsPath)

Parameters

NameTypeDescription
requestSystem.Net.Http.HttpRequestMessageThe HttpRequestMessage to parse.
responseSnapshotsPathstringRoot folder for storing snapshot files.

Returns

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

Exceptions

ExceptionDescription
ArgumentExceptionThrown when the request has an invalid RequestUri.
InvalidOperationExceptionThrown when the URI cannot be converted to a valid file path.

GetResponseMediaTypeString Inherited

Inherited from CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotHandlerBase
Maps the file extension in the specified path to a known list of media types.

Syntax

public static string GetResponseMediaTypeString(string filePath)

Parameters

NameTypeDescription
filePathstringThe file path to examine.

Returns

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

SendAsync Override

Inherited from CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotReplayHandler
Intercepts the HTTP request and returns a response loaded from a snapshot file.

Syntax

protected override System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsync(System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)

Parameters

NameTypeDescription
requestSystem.Net.Http.HttpRequestMessageThe HttpRequestMessage being intercepted.
cancellationTokenSystem.Threading.CancellationTokenToken for cancelling the asynchronous operation.

Returns

Type: System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> An HttpResponseMessage with content loaded from the corresponding snapshot file.

Exceptions

ExceptionDescription
ArgumentNullExceptionThrown when request is null.
InvalidOperationExceptionThrown when no snapshot file exists for the request.

SendAsyncInternal Inherited

Inherited from CloudNimble.Breakdance.Assemblies.Http.ResponseSnapshotReplayHandler
Allows test projects to call the otherwise inaccessible CancellationToken) method directly.

Syntax

internal System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> SendAsyncInternal(System.Net.Http.HttpRequestMessage request)

Parameters

NameTypeDescription
requestSystem.Net.Http.HttpRequestMessageThe HttpRequestMessage to process.

Returns

Type: System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> The HttpResponseMessage loaded from the snapshot file.