Package org.eclipse.jetty.http
Class HttpCompliance
- java.lang.Object
-
- org.eclipse.jetty.http.HttpCompliance
-
- All Implemented Interfaces:
ComplianceViolation.Mode
public final class HttpCompliance extends java.lang.Object implements ComplianceViolation.Mode
HTTP compliance modes for Jetty HTTP parsing and handling. A Compliance mode consists of a set ofHttpCompliance.Violation
s which are applied when the mode is enabled.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HttpCompliance.Violation
-
Field Summary
Fields Modifier and Type Field Description static HttpCompliance
LEGACY
A legacy HttpCompliance mode that allows all violations except case-insensitive methods.protected static org.slf4j.Logger
LOG
static HttpCompliance
RFC2616
static HttpCompliance
RFC2616_LEGACY
A legacy HttpCompliance mode that supportsRFC2616
, but that also allows: case-insensitive methods; colons after field names;Transfer-Encoding
withContent-Length
fields; and multipleContent-Length
values.static HttpCompliance
RFC7230
The HttpCompliance mode that supports RFC 7230 with no known violations.static HttpCompliance
RFC7230_LEGACY
A legacy HttpCompliance mode that supportsRFC7230
, but with case-insensitive methods allowed.static java.lang.String
VIOLATIONS_ATTR
The request attribute which may be set to record any allowed HTTP violations.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
allows(ComplianceViolation violation)
static HttpCompliance
from(java.lang.String spec)
Create compliance mode from a String description.java.util.Set<HttpCompliance.Violation>
getAllowed()
java.util.Set<HttpCompliance.Violation>
getKnown()
java.lang.String
getName()
java.lang.String
toString()
static HttpCompliance
valueOf(java.lang.String name)
Get a known compliance mode by name.HttpCompliance
with(java.lang.String name, HttpCompliance.Violation... violations)
Create a new HttpCompliance mode that includes the passedHttpCompliance.Violation
s.HttpCompliance
without(java.lang.String name, HttpCompliance.Violation... violations)
Create a new HttpCompliance mode that excludes the passedHttpCompliance.Violation
s.
-
-
-
Field Detail
-
LOG
protected static final org.slf4j.Logger LOG
-
VIOLATIONS_ATTR
public static final java.lang.String VIOLATIONS_ATTR
The request attribute which may be set to record any allowed HTTP violations.- See Also:
- Constant Field Values
-
RFC7230
public static final HttpCompliance RFC7230
The HttpCompliance mode that supports RFC 7230 with no known violations.
-
RFC2616
public static final HttpCompliance RFC2616
-
LEGACY
public static final HttpCompliance LEGACY
A legacy HttpCompliance mode that allows all violations except case-insensitive methods.
-
RFC2616_LEGACY
public static final HttpCompliance RFC2616_LEGACY
A legacy HttpCompliance mode that supportsRFC2616
, but that also allows: case-insensitive methods; colons after field names;Transfer-Encoding
withContent-Length
fields; and multipleContent-Length
values.
-
RFC7230_LEGACY
public static final HttpCompliance RFC7230_LEGACY
A legacy HttpCompliance mode that supportsRFC7230
, but with case-insensitive methods allowed.
-
-
Method Detail
-
valueOf
public static HttpCompliance valueOf(java.lang.String name)
Get a known compliance mode by name.- Parameters:
name
- The name of a knownHttpCompliance
mode.- Returns:
- The mode matching the name.
-
from
public static HttpCompliance from(java.lang.String spec)
Create compliance mode from a String description.Format:
- 0
- No
HttpCompliance.Violation
s - *
- All
HttpCompliance.Violation
s - RFC2616
- The set of
HttpCompliance.Violation
s application to https://tools.ietf.org/html/rfc2616, but not https://tools.ietf.org/html/rfc7230 - RFC7230
- The set of
HttpCompliance.Violation
s application to https://tools.ietf.org/html/rfc7230 - name
- Any of the known modes defined in
KNOWN_MODES
The remainder of the list can contain then names of
HttpCompliance.Violation
s to include them in the mode, or prefixed with a '-' to exclude them from the mode.- Parameters:
spec
- A string describing the compliance- Returns:
- the HttpCompliance instance derived from the string description
-
allows
public boolean allows(ComplianceViolation violation)
- Specified by:
allows
in interfaceComplianceViolation.Mode
- Parameters:
violation
- TheComplianceViolation
to test- Returns:
- true iff the violation is allowed by this mode.
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfaceComplianceViolation.Mode
- Returns:
- The name of the compliance violation mode.
-
getAllowed
public java.util.Set<HttpCompliance.Violation> getAllowed()
- Specified by:
getAllowed
in interfaceComplianceViolation.Mode
- Returns:
- The immutable set of violations allowed by this mode.
-
getKnown
public java.util.Set<HttpCompliance.Violation> getKnown()
- Specified by:
getKnown
in interfaceComplianceViolation.Mode
- Returns:
- The immutable set of all known violations for this mode.
-
with
public HttpCompliance with(java.lang.String name, HttpCompliance.Violation... violations)
Create a new HttpCompliance mode that includes the passedHttpCompliance.Violation
s.- Parameters:
name
- The name of the new modeviolations
- The violations to include- Returns:
- A new
HttpCompliance
mode.
-
without
public HttpCompliance without(java.lang.String name, HttpCompliance.Violation... violations)
Create a new HttpCompliance mode that excludes the passedHttpCompliance.Violation
s.- Parameters:
name
- The name of the new modeviolations
- The violations to exclude- Returns:
- A new
HttpCompliance
mode.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-