Issue #3012 Compliance modes.
added valueOf methods for XML calls. Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
parent
c7f66521cb
commit
d8695f0712
|
@ -18,7 +18,9 @@
|
|||
|
||||
package org.eclipse.jetty.http;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -33,7 +35,6 @@ import static java.util.EnumSet.noneOf;
|
|||
*/
|
||||
public class CookieCompliance implements ComplianceViolation.Mode
|
||||
{
|
||||
|
||||
enum Violation implements ComplianceViolation
|
||||
{
|
||||
COMMA_NOT_VALID_OCTET("https://tools.ietf.org/html/rfc6265#section-4.1.1", "Comma not valid as cookie-octet or separator"),
|
||||
|
@ -70,6 +71,16 @@ public class CookieCompliance implements ComplianceViolation.Mode
|
|||
public static final CookieCompliance RFC6265 = new CookieCompliance("RFC6265", noneOf(Violation.class));
|
||||
public static final CookieCompliance RFC2965 = new CookieCompliance("RFC2965", allOf(Violation.class));
|
||||
|
||||
private final static List<CookieCompliance> KNOWN_MODES = Arrays.asList(RFC6265,RFC2965);
|
||||
|
||||
public static CookieCompliance valueOf(String name)
|
||||
{
|
||||
for (CookieCompliance compliance : KNOWN_MODES)
|
||||
if (compliance.getName().equals(name))
|
||||
return compliance;
|
||||
return null;
|
||||
}
|
||||
|
||||
private final String _name;
|
||||
private final Set<Violation> _violations;
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import java.util.Arrays;
|
|||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
@ -85,6 +84,9 @@ public final class HttpCompliance implements ComplianceViolation.Mode
|
|||
}
|
||||
}
|
||||
|
||||
private static final Logger LOG = Log.getLogger(HttpParser.class);
|
||||
public static final String VIOLATIONS_ATTR = "org.eclipse.jetty.http.compliance.violations";
|
||||
|
||||
public final static HttpCompliance RFC7230 = new HttpCompliance("RFC7230", noneOf(Violation.class));
|
||||
public final static HttpCompliance RFC2616 = new HttpCompliance("RFC2616", of(Violation.HTTP_0_9, Violation.MULTILINE_FIELD_VALUE));
|
||||
public final static HttpCompliance LEGACY = new HttpCompliance("LEGACY", complementOf(of(Violation.CASE_INSENSITIVE_METHOD)));
|
||||
|
@ -95,11 +97,16 @@ public final class HttpCompliance implements ComplianceViolation.Mode
|
|||
Violation.MULTIPLE_CONTENT_LENGTHS);
|
||||
public final static HttpCompliance RFC7230_LEGACY = RFC7230.with("RFC7230_LEGACY", Violation.CASE_INSENSITIVE_METHOD);
|
||||
|
||||
public final static List<HttpCompliance> KNOWN_MODES = Arrays.asList(RFC7230,RFC2616,LEGACY,RFC2616_LEGACY,RFC7230_LEGACY);
|
||||
|
||||
public static final String VIOLATIONS_ATTR = "org.eclipse.jetty.http.compliance.violations";
|
||||
private final static List<HttpCompliance> KNOWN_MODES = Arrays.asList(RFC7230,RFC2616,LEGACY,RFC2616_LEGACY,RFC7230_LEGACY);
|
||||
|
||||
private static final Logger LOG = Log.getLogger(HttpParser.class);
|
||||
public static HttpCompliance valueOf(String name)
|
||||
{
|
||||
for (HttpCompliance compliance : KNOWN_MODES)
|
||||
if (compliance.getName().equals(name))
|
||||
return compliance;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create violation set from string
|
||||
|
@ -133,12 +140,11 @@ public final class HttpCompliance implements ComplianceViolation.Mode
|
|||
|
||||
default:
|
||||
{
|
||||
Optional<HttpCompliance> mode =
|
||||
KNOWN_MODES.stream().filter(m -> m.getName().equals(elements[0])).findFirst();
|
||||
if (mode.isPresent())
|
||||
sections = copyOf(mode.get().getAllowed());
|
||||
else
|
||||
HttpCompliance mode = HttpCompliance.valueOf(elements[0]);
|
||||
if (mode==null)
|
||||
sections = noneOf(Violation.class);
|
||||
else
|
||||
sections = copyOf(mode.getAllowed());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -532,9 +532,9 @@ public class HttpConfiguration implements Dumpable
|
|||
return _httpCompliance;
|
||||
}
|
||||
|
||||
public void setHttpCompliance(HttpCompliance _httpCompliance)
|
||||
public void setHttpCompliance(HttpCompliance httpCompliance)
|
||||
{
|
||||
this._httpCompliance = _httpCompliance;
|
||||
_httpCompliance = httpCompliance;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue