Package io.github.mahmoudimus.http2
Class OriginFrame
java.lang.Object
io.github.mahmoudimus.http2.OriginFrame
The ORIGIN frame (RFC 8336): a server names the origins it is authoritative for on the
connection, such as
https://b.example.com or https://b.example.com:8443, so a
client may send requests for them there without consulting DNS.
It is an extension frame, not one of RFC 9113's types, so it travels as a Frame.Unknown of type FrameType.ORIGIN: FrameReader returns it when asked to
(FrameReader.setDeliverOriginFrames(boolean)), and FrameWriter.writeFrame(Frame)
writes the one frame(java.util.List<java.lang.String>) builds. Its payload is a sequence of Origin-Entry fields, each a
16-bit length and that many octets of an origin's ASCII serialization. It defines no flags, and
one received on a stream other than 0 must be ignored (RFC 8336 section 2.1), as must one sent
to a server.
case Frame.Unknown u when OriginFrame.isOrigin(u) -> {
try {
originSet.addAll(OriginFrame.origins(u));
} catch (IllegalArgumentException malformed) {
// ignored, as any extension frame may be
}
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe longest origin an Origin-Entry can carry: its length is 16 bits. -
Method Summary
Modifier and TypeMethodDescriptiondecode(byte[] payload) Reads an ORIGIN frame's payload.static byte[]Builds an ORIGIN frame's payload.static Frame.UnknownAn ORIGIN frame namingorigins, on stream 0 and without flags, forFrameWriter.writeFrame(Frame).static booleanWhetherframeis an ORIGIN frame a client acts on: of typeFrameType.ORIGINand on stream 0 (one on any other stream is ignored).origins(Frame.Unknown frame) The origins an ORIGIN frame names, in the order it names them.
-
Field Details
-
MAX_ORIGIN_LENGTH
public static final int MAX_ORIGIN_LENGTHThe longest origin an Origin-Entry can carry: its length is 16 bits.- See Also:
-
-
Method Details
-
isOrigin
Whetherframeis an ORIGIN frame a client acts on: of typeFrameType.ORIGINand on stream 0 (one on any other stream is ignored).- Parameters:
frame- any frame- Returns:
- true for an ORIGIN frame on stream 0
-
origins
The origins an ORIGIN frame names, in the order it names them.- Parameters:
frame- an ORIGIN frame- Returns:
- the origins' ASCII serializations, as sent (an empty one stays empty)
- Throws:
IllegalArgumentException- if the frame is not of type ORIGIN, or is malformed: an entry runs past the end of the payload, or holds non-ASCII octets
-
decode
Reads an ORIGIN frame's payload.- Parameters:
payload- the frame's payload- Returns:
- the origins' ASCII serializations, in order
- Throws:
IllegalArgumentException- if an entry runs past the end of the payload, or holds non-ASCII octets
-
encode
Builds an ORIGIN frame's payload.- Parameters:
origins- the origins' ASCII serializations, such ashttps://example.com- Returns:
- the payload: each origin preceded by its 16-bit length
- Throws:
IllegalArgumentException- if an origin is not ASCII or longer thanMAX_ORIGIN_LENGTHoctets
-
frame
An ORIGIN frame namingorigins, on stream 0 and without flags, forFrameWriter.writeFrame(Frame).- Parameters:
origins- the origins' ASCII serializations- Returns:
- the frame
- Throws:
IllegalArgumentException- asencode(java.util.List<java.lang.String>)does
-