Class ResponseSerializer

java.lang.Object
dev.relism.flash.models.ResponseSerializer

public final class ResponseSerializer extends Object
The protocol-neutral enumeration of a Response's header fields — one source of truth consumed by every protocol's writer, so field selection cannot drift between HTTP/1 and HTTP/2.

Scope: response-object fields only, not connection framing

Deliberately does not enumerate Content-Length, Connection, or Date — those are connection/transport framing decisions (body length, keep-alive negotiation, wall-clock time), not properties of the Response object itself, and HTTP/2 has no equivalent of Connection at all (RFC 9113 §8.2.2 forbids connection-specific fields in h2). Each protocol's own writer computes and emits those itself, exactly as Http1ResponseWriter already did before this class existed.

Scope: excludes Response.header(byte[])'s legacy entries

A header added via the raw, fully-pre-rendered header(byte[]) overload has no recoverable (name, value) structure — see that method's own Javadoc — so it cannot appear in this enumeration. HTTP/1 still renders it via Response.writeHeaders(java.io.OutputStream); HTTP/2 cannot recover its field structure and ignores it.
  • Method Details

    • forEachField

      public static void forEachField(Response response, ResponseSerializer.FieldConsumer consumer)
      Enumerates response's fields in a fixed order: non-empty Content-Type, then structured custom fields in call order. Every range is a slice of existing response storage.
    • forEachCustomField

      public static void forEachCustomField(Response response, ResponseSerializer.FieldConsumer consumer)
      Enumerates structured custom fields only, excluding content-type.
    • forEachTrailerField

      public static void forEachTrailerField(Response response, ResponseSerializer.FieldConsumer consumer)
      Enumerates response trailers in declaration order.