Skip to content

HttpTransaction Class ​

Definition ​

Represents a high-performance, diagnostic-aware HTTP client wrapper for issuing web requests, featuring detailed metadata capture, precise timing via pooled HttpClients, and flexible payload support.

Designed for reliability and transparency, this client supports JSON, form-data, and stream uploads, along with SSL certificate inspection, advanced authentication modes, and resilient socket management via base-address client pooling.

  • Namespace: JASE.Network
  • Assembly: JASE.Network.dll

Properties ​

NameDescription
ChainStatusDetails of the SSL chain
ClientPoolKeyGets the normalized key used to resolve the HttpClientPool instance
ContentGets the response bytes decoded using ResponseEncoding.
CookiesCookies returned by the web operation
ElapsedMSDuration of the web operation in milliseconds
EncodingEncoding for the Request operation, default is UTF-8
EndEnding timestamp for the web operation in UTC
ExceptionProvides Exception if any occurred
ExecutionThreadIDThread Id the web operation executed on
IdUnique identifier for the request
MethodTransaction METHOD or VERB
RequestHeadersCollection of headers received in the web operation Request
RequestPayloadRaw bytes sent in the transaction request, not populated for Stream post
ResponseBytesRaw bytes returned by the web operation
ResponseEncodingEncoding for the web Response
ResponseHeadersCollection of headers received in the web operation Response
ResponseUriFinal response URI after any redirects or request rewriting.
ServerCertificateThe SSL certificate presented by the Server
SslPolicyErrorsAccess to policy errors encountered during the web operation
StartBeginning timestamp for the web operation in UTC
StatusCodeHTTP status code as an integer
StatusCodeTextHTTP status code as a string
TrustedCertificateChainTrue if the Server presented an SSL certificate and its chain was trusted
UriRequest Uri for the web operation

Methods ​

NameDescription
Task<HttpTransaction> Delete(string url, string contentType = null, string userAgent = null, IReadOnlyDictionary<string, string> headers = null, string payload = null, ClientCredential credentials = null, CookieCollection cookies = null, Encoding encoding = null, CancellationToken cancellationToken = null)Sends an HTTP DELETE request to the specified URL and returns a WebClient object containing the response data.
Task<HttpTransaction> Get(string url, string userAgent = null, IReadOnlyDictionary<string, string> headers = null, ClientCredential credentials = null, CookieCollection cookies = null, CancellationToken cancellationToken = null)Sends an HTTP GET request to the specified URL.
IReadOnlyList<string> GetClientKeys()Returns a list of known client keys
ReadOnlyDictionary<string, List<string>> GetRedactedHeaders(string redactValue = null, IEnumerable<string> additionalSensitiveHeaders = null)Returns a redacted copy of RequestHeaders suitable for logging and exception messages. Sensitive headers (for example Authorization, Cookie, token, secret, apikey) are replaced with a constant value.
string GetRequestPayload()Returns the Request payload as a string
Task<HttpTransaction> Head(string url, string userAgent = null, IReadOnlyDictionary<string, string> headers = null, ClientCredential credentials = null, CookieCollection cookies = null, CancellationToken cancellationToken = null)Sends an HTTP HEAD request to the specified URL. Retrieves only the response headers without downloading the response body content. Useful for checking resource availability, metadata, or headers without transferring full data.
bool Is200Range()True if the HTTP status code is between 200 - 299
bool IsExcepted()True if the transaction encountered an exception
bool IsFailed()True if the HTTP status code is greater than or equal to 400
bool IsRateLimit()True if the HTTP status code indicates rate limiting (code == 429)
bool IsSuccessRange()True if the HTTP status code is 200 - 299
Task<HttpTransaction> Patch(string url, string contentType = null, string userAgent = null, IReadOnlyDictionary<string, string> headers = null, string payload = null, ClientCredential credentials = null, CookieCollection cookies = null, Encoding encoding = null, CancellationToken cancellationToken = null)Sends an HTTP PATCH request to the specified URL and returns a WebClient object that represents the response.
Task<HttpTransaction> Post(string url, FormContentType contentType = null, string userAgent = null, IReadOnlyDictionary<string, string> headers = null, FormDataCollection payload = null, ClientCredential credentials = null, CookieCollection cookies = null, Encoding encoding = null, CancellationToken cancellationToken = null)Sends an HTTP POST request to the specified URL.
Task<HttpTransaction> Post(string url, string contentType = null, string userAgent = null, IReadOnlyDictionary<string, string> headers = null, string payload = null, ClientCredential credentials = null, CookieCollection cookies = null, Encoding encoding = null, CancellationToken cancellationToken = null)Sends an HTTP POST request to the specified URL and returns a HttpTransaction object representing the response.
Task<HttpTransaction> PostStream(string url, StreamContent content, string contentType = null, string userAgent = null, IReadOnlyDictionary<string, string> headers = null, ClientCredential credentials = null, CookieCollection cookies = null, CancellationToken cancellationToken = null)POST to a url as Stream content
Task<HttpTransaction> PostStream(string url, byte[] content, string contentType = null, string userAgent = null, IReadOnlyDictionary<string, string> headers = null, ClientCredential credentials = null, CookieCollection cookies = null, CancellationToken cancellationToken = null)POST a byte[] to a url as Stream content
Task<HttpTransaction> Put(string url, FormContentType contentType = null, string userAgent = null, IReadOnlyDictionary<string, string> headers = null, FormDataCollection payload = null, ClientCredential credentials = null, CookieCollection cookies = null, Encoding encoding = null, CancellationToken cancellationToken = null)Sends an HTTP PUT request to the specified URL.
Task<HttpTransaction> Put(string url, string contentType = null, string userAgent = null, IReadOnlyDictionary<string, string> headers = null, string payload = null, ClientCredential credentials = null, CookieCollection cookies = null, Encoding encoding = null, CancellationToken cancellationToken = null)Sends a PUT request to the specified URL with the given payload and headers using the specified content type.
Task<HttpTransaction> PutStream(string url, StreamContent content, string contentType = null, string userAgent = null, IReadOnlyDictionary<string, string> headers = null, ClientCredential credentials = null, CookieCollection cookies = null, CancellationToken cancellationToken = null)PUT to a url as Stream content
Task<HttpTransaction> PutStream(string url, byte[] content, string contentType = null, string userAgent = null, IReadOnlyDictionary<string, string> headers = null, ClientCredential credentials = null, CookieCollection cookies = null, CancellationToken cancellationToken = null)PUT a byte[] to a url as Stream content
bool SetMaxConnections(Uri uri, int maxConnections)Set the max concurrent connections to a server resource
bool SetMaxConnections(string url, int maxConnections)Set the max concurrent connections to a server resource
bool TryEvictHost(Uri uri)Attempts to evict (dispose) the pooled HttpClient and its transport connections associated with the given absolute Uri.
bool TryEvictHost(string keyOrUri)Attempts to evict (dispose) the pooled HttpClient and its transport connections for the specified host key or absolute URI string.
bool TryGetSnapshot(Uri uri, out PooledClientSnapshot output)Attempts to retrieve a point-in-time telemetry snapshot for a pooled HTTP client identified by an absolute Uri.
bool TryGetSnapshot(string keyOrUri, out PooledClientSnapshot output)Attempts to retrieve a point-in-time telemetry snapshot for a pooled HTTP client identified by either a normalized host key or an absolute URI string.