Class HttpCompliance
java.lang.Object
org.eclipse.jetty.http.HttpCompliance
- All Implemented Interfaces:
ComplianceViolation.Mode
HTTP compliance modes for Jetty HTTP parsing and handling.
A Compliance mode consists of a set of
HttpCompliance.Violations which are applied
when the mode is enabled.-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HttpComplianceA legacy HttpCompliance mode that allows all violations except case-insensitive methods.static final HttpCompliancestatic final HttpComplianceA legacy HttpCompliance mode that supportsRFC2616, but that also allows: case-insensitive methods; colons after field names;Transfer-EncodingwithContent-Lengthfields; and multipleContent-Lengthvalues.static final HttpComplianceThe HttpCompliance mode that supports RFC 7230 with no known violations.static final HttpComplianceA legacy HttpCompliance mode that supportsRFC7230, but with case-insensitive methods allowed.static final StringDeprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionbooleanallows(ComplianceViolation violation) static voidcheckHttpCompliance(MetaData.Request request, HttpCompliance mode, ComplianceViolation.Listener listener) static HttpComplianceCreate compliance mode from a String description.getKnown()getName()toString()static HttpComplianceGet a known compliance mode by name.with(String name, HttpCompliance.Violation... violations) Create a new HttpCompliance mode that includes the passedHttpCompliance.Violations.without(String name, HttpCompliance.Violation... violations) Create a new HttpCompliance mode that excludes the passedHttpCompliance.Violations.
-
Field Details
-
VIOLATIONS_ATTR
Deprecated, for removal: This API element is subject to removal in a future version.useComplianceViolation.CapturingListener.VIOLATIONS_ATTR_KEYinstead.
(Note: new ATTR captures all Compliance violations, not just HTTP.
Make sure you haveHttpConnectionFactory.setRecordHttpComplianceViolations(true).
Also make sure that aComplianceViolation.CapturingListenerhas been added as a bean to either theConnectororServerfor the Attribute to be created.)The request attribute which may be set to record any allowed HTTP violations.- See Also:
-
RFC7230
The HttpCompliance mode that supports RFC 7230 with no known violations. -
RFC2616
-
LEGACY
A legacy HttpCompliance mode that allows all violations except case-insensitive methods. -
RFC2616_LEGACY
A legacy HttpCompliance mode that supportsRFC2616, but that also allows: case-insensitive methods; colons after field names;Transfer-EncodingwithContent-Lengthfields; and multipleContent-Lengthvalues. -
RFC7230_LEGACY
A legacy HttpCompliance mode that supportsRFC7230, but with case-insensitive methods allowed.
-
-
Method Details
-
valueOf
Get a known compliance mode by name.- Parameters:
name- The name of a knownHttpCompliancemode.- Returns:
- The mode matching the name.
-
from
Create compliance mode from a String description.Format:
- 0
- No
HttpCompliance.Violations - *
- All
HttpCompliance.Violations - RFC2616
- The set of
HttpCompliance.Violations application to RFC2616, but not RFC7230 - RFC7230
- The set of
HttpCompliance.Violations application to RFC7230 - name
- Any of the known modes defined in
KNOWN_MODES
The remainder of the list can contain then names of
HttpCompliance.Violations 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
- Specified by:
allowsin interfaceComplianceViolation.Mode- Parameters:
violation- TheComplianceViolationto test- Returns:
- true iff the violation is allowed by this mode.
-
getName
- Specified by:
getNamein interfaceComplianceViolation.Mode- Returns:
- The name of the compliance violation mode.
-
getAllowed
- Specified by:
getAllowedin interfaceComplianceViolation.Mode- Returns:
- The immutable set of violations allowed by this mode.
-
getKnown
- Specified by:
getKnownin interfaceComplianceViolation.Mode- Returns:
- The immutable set of all known violations for this mode.
-
with
Create a new HttpCompliance mode that includes the passedHttpCompliance.Violations.- Parameters:
name- The name of the new modeviolations- The violations to include- Returns:
- A new
HttpCompliancemode.
-
without
Create a new HttpCompliance mode that excludes the passedHttpCompliance.Violations.- Parameters:
name- The name of the new modeviolations- The violations to exclude- Returns:
- A new
HttpCompliancemode.
-
toString
-
checkHttpCompliance
public static void checkHttpCompliance(MetaData.Request request, HttpCompliance mode, ComplianceViolation.Listener listener)
-
ComplianceViolation.CapturingListener.VIOLATIONS_ATTR_KEYinstead.(Note: new ATTR captures all Compliance violations, not just HTTP.
Make sure you have
HttpConnectionFactory.setRecordHttpComplianceViolations(true).Also make sure that a
ComplianceViolation.CapturingListenerhas been added as a bean to either theConnectororServerfor the Attribute to be created.)