Skip to main content

Definition

Assembly: CloudNimble.Breakdance.DotHttp.dll Namespace: CloudNimble.Breakdance.DotHttp Inheritance: System.Object

Syntax

CloudNimble.Breakdance.DotHttp.ResponseCapture

Summary

Captures HTTP responses from named requests for use in request chaining.

Remarks

Supports {{name.response.body.$.path}} for JSONPath, {{name.response.body./xpath}} for XPath, and {{name.response.headers.HeaderName}} for header extraction.

Examples

var capture = new ResponseCapture();
await capture.CaptureAsync("login", loginResponse);

// Later, resolve a reference from the captured response
var token = capture.ResolveReference("{{login.response.body.$.token}}");
var header = capture.ResolveReference("{{login.response.headers.X-Request-Id}}");

Constructors

.ctor

Syntax

public ResponseCapture()

.ctor Inherited

Inherited from object

Syntax

public Object()

Methods

CaptureAsync

Captures a response for later reference.

Syntax

public System.Threading.Tasks.Task CaptureAsync(string name, System.Net.Http.HttpResponseMessage response, string requestBody = null)

Parameters

NameTypeDescription
namestringThe request name (from # @name directive).
responseSystem.Net.Http.HttpResponseMessageThe HTTP response.
requestBodystringThe original request body (for {{name.request.body}} references).

Returns

Type: System.Threading.Tasks.Task

Examples

var capture = new ResponseCapture();
var response = await httpClient.SendAsync(request);
await capture.CaptureAsync("createUser", response, requestBodyJson);

Clear

Clears all captured responses.

Syntax

public void Clear()

Examples

var capture = new ResponseCapture();
// ... capture some responses ...
capture.Clear(); // Reset for new test

Equals Inherited Virtual

Inherited from object

Syntax

public virtual bool Equals(object obj)

Parameters

NameTypeDescription
objobject?-

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

public static bool Equals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetResponseBody

Gets the captured response body for a named request.

Syntax

public string GetResponseBody(string name)

Parameters

NameTypeDescription
namestringThe request name.

Returns

Type: string The response body, or null if not captured.

Examples

var capture = new ResponseCapture();
await capture.CaptureAsync("login", response);
var body = capture.GetResponseBody("login");

GetType Inherited

Inherited from object

Syntax

public System.Type GetType()

Returns

Type: System.Type

HasResponse

Checks if a captured response exists for the given name.

Syntax

public bool HasResponse(string name)

Parameters

NameTypeDescription
namestringThe request name.

Returns

Type: bool True if the response has been captured.

Examples

if (capture.HasResponse("login"))
{
    var token = capture.ResolveReference("{{login.response.body.$.token}}");
}

MemberwiseClone Inherited

Inherited from object

Syntax

protected internal object MemberwiseClone()

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

ResolveAllReferences

Resolves all response references in a string.

Syntax

public string ResolveAllReferences(string input)

Parameters

NameTypeDescription
inputstringThe input string containing response references.

Returns

Type: string The resolved string.

Examples

var url = "https://api.example.com/users/{{login.response.body.$.userId}}";
var resolvedUrl = capture.ResolveAllReferences(url);

ResolveReference

Resolves a response reference to its actual value.

Syntax

public string ResolveReference(string reference)

Parameters

NameTypeDescription
referencestringThe full reference string (e.g., "{{login.response.body.$.token}}").

Returns

Type: string The resolved value, or the original reference if not found.

Examples

var capture = new ResponseCapture();
await capture.CaptureAsync("login", response);
var token = capture.ResolveReference("{{login.response.body.$.token}}");

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?