Skip to content

Expose HTTP response trailers on RestResponse #2413

Description

@Benziza

Problem

.NET exposes HTTP response trailer fields through HttpResponseMessage.TrailingHeaders, but RestSharp currently maps only the regular response headers and content headers to RestResponse. The internal HttpResponseMessage is disposed after execution, so callers using the standard ExecuteAsync path cannot access trailer fields.

Trailer fields are useful for message integrity checks, signatures, delivery metrics, and post-processing status information. RFC 9110 also recommends storing them separately from the initial header section.

Proposed change

  • Add a TrailingHeaders collection to RestResponseBase, separate from Headers and ContentHeaders.
  • Populate it after the response body has been fully consumed, because .NET exposes received trailers only after content completion.
  • Keep the collection empty on target frameworks where HttpResponseMessage.TrailingHeaders is unavailable.
  • Add tests verifying that trailers are preserved and remain separate from regular headers.

Compatibility

This would be an additive public API change. RestSharp targets
etstandard2.0, .NET Framework, and modern .NET, so the property can be available on all targets while population is guarded for supported modern .NET targets.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions