Package io.github.mahmoudimus.http2
Record Class RequestHeaders
java.lang.Object
java.lang.Record
io.github.mahmoudimus.http2.RequestHeaders
- Record Components:
method-:methodscheme-:scheme, or null for ordinary CONNECT-:authority, or thehostfield when that is absent; null if neither is presentpath-:path, or null for ordinary CONNECTfields- the regular fields in order (lower-case names; cookie crumbs joined into one field)contentLength- thecontent-length, or -1 if absentprotocol- RFC 8441:protocol, or null without extended CONNECT
public record RequestHeaders(String method, String scheme, String authority, String path, List<HeaderField> fields, long contentLength, String protocol)
extends Record
A validated HTTP/2 request header section: the control data from the pseudo-header fields and
the remaining fields, as
Http2Headers.toRequest(int, java.util.List<io.github.mahmoudimus.http2.HeaderField>) produces it.-
Constructor Summary
ConstructorsConstructorDescriptionRequestHeaders(String method, String scheme, String authority, String path, List<HeaderField> fields, long contentLength) Creates request headers without extended CONNECT metadata.RequestHeaders(String method, String scheme, String authority, String path, List<HeaderField> fields, long contentLength, String protocol) Creates request headers and takes an immutable copy of the regular fields. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theauthorityrecord component.longReturns the value of thecontentLengthrecord component.final booleanIndicates whether some other object is "equal to" this one.fields()Returns the value of thefieldsrecord component.The value of the first field with this (lower-case) name, or null.The values of every field with this (lower-case) name.final inthashCode()Returns a hash code value for this object.booleanChecks the request method.method()Returns the value of themethodrecord component.path()Returns the value of thepathrecord component.protocol()Returns the value of theprotocolrecord component.scheme()Returns the value of theschemerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
RequestHeaders
public RequestHeaders(String method, String scheme, String authority, String path, List<HeaderField> fields, long contentLength) Creates request headers without extended CONNECT metadata.- Parameters:
method- the non-null request methodscheme- the URI scheme, or null for ordinary CONNECTauthority- the target authority, or null if unavailablepath- the request path, or null for ordinary CONNECTfields- the regular fields in order, copied into an immutable listcontentLength- the declared content length, or -1 if absent
-
RequestHeaders
public RequestHeaders(String method, String scheme, String authority, String path, List<HeaderField> fields, long contentLength, String protocol) Creates request headers and takes an immutable copy of the regular fields.- Parameters:
method- the non-null request methodscheme- the URI scheme, or null for ordinary CONNECTauthority- the target authority, or null if unavailablepath- the request path, or null for ordinary CONNECTfields- the regular fields in order, copied into an immutable listcontentLength- the declared content length, or -1 if absentprotocol- the extended CONNECT protocol, or null if absent
-
-
Method Details
-
isConnect
public boolean isConnect()Checks the request method.- Returns:
- whether the method is CONNECT
-
get
The value of the first field with this (lower-case) name, or null.- Parameters:
name- the lower-case field name- Returns:
- the first matching value, or null if absent
-
getAll
The values of every field with this (lower-case) name.- Parameters:
name- the lower-case field name- Returns:
- the matching values in field order, or an empty list
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
method
Returns the value of themethodrecord component.- Returns:
- the value of the
methodrecord component
-
scheme
Returns the value of theschemerecord component.- Returns:
- the value of the
schemerecord component
-
authority
Returns the value of theauthorityrecord component.- Returns:
- the value of the
authorityrecord component
-
path
Returns the value of thepathrecord component.- Returns:
- the value of the
pathrecord component
-
fields
Returns the value of thefieldsrecord component.- Returns:
- the value of the
fieldsrecord component
-
contentLength
public long contentLength()Returns the value of thecontentLengthrecord component.- Returns:
- the value of the
contentLengthrecord component
-
protocol
Returns the value of theprotocolrecord component.- Returns:
- the value of the
protocolrecord component
-