2.16.0

(feat): Add support for accessing raw HTTP response data alongside typed response objects using .WithRawResponse().

HTTP endpoint methods now return WithRawResponseTask<T>, which provides two usage patterns:

  • Default behavior: Direct await returns just the typed data (zero-allocation fast path)
  • Raw response access: Await with .WithRawResponse() returns both data and HTTP metadata

Example usage:

1// Default behavior - returns just the data
2var userData = await client.Users.GetAsync("user-123");
3
4// Access raw response metadata
5var result = await client.Users.GetAsync("user-123").WithRawResponse();
6var data = result.Data;
7var statusCode = result.RawResponse.StatusCode; // HttpStatusCode
8var headers = result.RawResponse.Headers; // ResponseHeaders
9var url = result.RawResponse.Url; // Uri
10
11// Access specific headers (case-insensitive)
12if (headers.TryGetValue("X-Request-Id", out var requestId))
13{
14 Console.WriteLine($"Request ID: {requestId}");
15}
16
17// Check content type and length
18var contentType = headers.ContentType;
19var contentLength = headers.ContentLength;

New types:

  • WithRawResponseTask<T> - Awaitable task wrapper supporting both usage patterns
  • WithRawResponse<T> - Container for data + raw response metadata
  • RawResponse - HTTP response metadata (status code, headers, URL)
  • ResponseHeaders - Case-insensitive header collection with enumeration support

Benefits:

  • Zero overhead when raw response access isn’t needed
  • Backward compatible - implicit conversion to Task<T> supported
  • Type-safe access to HTTP metadata when debugging or logging
  • Case-insensitive header lookups following HTTP standards