Package io.muserver
Class ForwardedHeader
- java.lang.Object
-
- io.muserver.ForwardedHeader
-
public class ForwardedHeader extends java.lang.ObjectRepresents a
Forwardedheader as described by RFC-7239.
-
-
Constructor Summary
Constructors Constructor Description ForwardedHeader(java.lang.String by, java.lang.String forValue, java.lang.String host, java.lang.String proto, java.util.Map<java.lang.String,java.lang.String> extensions)Creates a new Forwarded Header.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringby()booleanequals(java.lang.Object o)java.util.Map<java.lang.String,java.lang.String>extensions()java.lang.StringforValue()static java.util.List<ForwardedHeader>fromString(java.lang.String input)Parses the value of aForwardedheader into an object.inthashCode()java.lang.Stringhost()java.lang.Stringproto()java.lang.StringtoString()Converts the HeaderValue into a string, suitable for printing in an HTTP header.static java.lang.StringtoString(java.util.List<ForwardedHeader> headers)Converts a list of headers into a single string that can be put into a Forwarded header field.
-
-
-
Constructor Detail
-
ForwardedHeader
public ForwardedHeader(java.lang.String by, java.lang.String forValue, java.lang.String host, java.lang.String proto, java.util.Map<java.lang.String,java.lang.String> extensions)Creates a new Forwarded Header. All values are optional.- Parameters:
by- The address of the node proxying the request, or nullforValue- The address of the client that initiated the request, or nullhost- The host that the client used, or nullproto- The protocol the client used, or nullextensions- Any extensions, or null
-
-
Method Detail
-
by
public java.lang.String by()
- Returns:
- The interface where the request came in to the proxy server (e.g. the IP address of the reverse
proxy that forwarded this request), or
nullif not specified.
-
forValue
public java.lang.String forValue()
- Returns:
- The interface where the request came in to the proxy server, e.g. the IP address of the client
that originated the request), or
nullif not specified.
-
host
public java.lang.String host()
- Returns:
- The Host request header field as received by the proxy (e.g. the hostname used on the original
request), or
nullif not specified.
-
proto
public java.lang.String proto()
- Returns:
- Indicates which protocol was used to make the request (typically "http" or "https"), or
nullif not specified.
-
extensions
public java.util.Map<java.lang.String,java.lang.String> extensions()
- Returns:
- Values not covered by by, for, host, or proto.
-
fromString
public static java.util.List<ForwardedHeader> fromString(java.lang.String input)
Parses the value of a
Forwardedheader into an object.Where multiple reverse proxies have resulted in multiple Forwarded headers, the first value in the list should contain the information of the original request.
Null or blank strings return an empty list.
- Parameters:
input- The value to parse- Returns:
- A list of ForwardedHeader objects
- Throws:
java.lang.IllegalArgumentException- The value cannot be parsed
-
toString
public java.lang.String toString()
Converts the HeaderValue into a string, suitable for printing in an HTTP header.- Overrides:
toStringin classjava.lang.Object- Returns:
- A String, such as "some-value" or "content-type:text/html;charset=UTF-8"
-
toString
public static java.lang.String toString(java.util.List<ForwardedHeader> headers)
Converts a list of headers into a single string that can be put into a Forwarded header field.- Parameters:
headers- The headers to serialise- Returns:
- An RFC-7239 compliant Forwarded header value.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-