Issue #3012 Compliance modes.
Fixed up httpCompliance configuration. Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
parent
d8695f0712
commit
481cedaa94
|
@ -23,6 +23,7 @@ import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import org.eclipse.jetty.util.log.Log;
|
import org.eclipse.jetty.util.log.Log;
|
||||||
import org.eclipse.jetty.util.log.Logger;
|
import org.eclipse.jetty.util.log.Logger;
|
||||||
|
@ -31,7 +32,6 @@ import static java.util.Arrays.asList;
|
||||||
import static java.util.Collections.unmodifiableSet;
|
import static java.util.Collections.unmodifiableSet;
|
||||||
import static java.util.EnumSet.allOf;
|
import static java.util.EnumSet.allOf;
|
||||||
import static java.util.EnumSet.complementOf;
|
import static java.util.EnumSet.complementOf;
|
||||||
import static java.util.EnumSet.copyOf;
|
|
||||||
import static java.util.EnumSet.noneOf;
|
import static java.util.EnumSet.noneOf;
|
||||||
import static java.util.EnumSet.of;
|
import static java.util.EnumSet.of;
|
||||||
|
|
||||||
|
@ -99,6 +99,7 @@ public final class HttpCompliance implements ComplianceViolation.Mode
|
||||||
|
|
||||||
|
|
||||||
private final static List<HttpCompliance> KNOWN_MODES = Arrays.asList(RFC7230,RFC2616,LEGACY,RFC2616_LEGACY,RFC7230_LEGACY);
|
private final static List<HttpCompliance> KNOWN_MODES = Arrays.asList(RFC7230,RFC2616,LEGACY,RFC2616_LEGACY,RFC7230_LEGACY);
|
||||||
|
private final static AtomicInteger __custom = new AtomicInteger();
|
||||||
|
|
||||||
public static HttpCompliance valueOf(String name)
|
public static HttpCompliance valueOf(String name)
|
||||||
{
|
{
|
||||||
|
@ -124,9 +125,9 @@ public final class HttpCompliance implements ComplianceViolation.Mode
|
||||||
* with a '-' to exclude thm from the mode.
|
* with a '-' to exclude thm from the mode.
|
||||||
* <p>
|
* <p>
|
||||||
*/
|
*/
|
||||||
static EnumSet<Violation> violationBySpec(String spec)
|
public static HttpCompliance from(String spec)
|
||||||
{
|
{
|
||||||
EnumSet<Violation> sections;
|
Set<Violation> sections;
|
||||||
String[] elements = spec.split("\\s*,\\s*");
|
String[] elements = spec.split("\\s*,\\s*");
|
||||||
switch(elements[0])
|
switch(elements[0])
|
||||||
{
|
{
|
||||||
|
@ -164,10 +165,9 @@ public final class HttpCompliance implements ComplianceViolation.Mode
|
||||||
sections.remove(section);
|
sections.remove(section);
|
||||||
else
|
else
|
||||||
sections.add(section);
|
sections.add(section);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sections;
|
return new HttpCompliance("CUSTOM" + __custom.getAndIncrement(), sections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ public final class HttpCompliance implements ComplianceViolation.Mode
|
||||||
{
|
{
|
||||||
Objects.nonNull(violations);
|
Objects.nonNull(violations);
|
||||||
_name = name;
|
_name = name;
|
||||||
_violations = unmodifiableSet(copyOf(violations));
|
_violations = unmodifiableSet(violations.isEmpty()?noneOf(Violation.class):copyOf(violations));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -217,8 +217,8 @@ public final class HttpCompliance implements ComplianceViolation.Mode
|
||||||
*/
|
*/
|
||||||
public HttpCompliance with(String name, Violation... violations)
|
public HttpCompliance with(String name, Violation... violations)
|
||||||
{
|
{
|
||||||
EnumSet<Violation> union = _violations.isEmpty()?EnumSet.noneOf(Violation.class):copyOf(_violations);
|
Set<Violation> union = _violations.isEmpty()?EnumSet.noneOf(Violation.class):copyOf(_violations);
|
||||||
union.addAll(copyOf(asList(violations)));
|
union.addAll(copyOf(violations));
|
||||||
return new HttpCompliance(name, union);
|
return new HttpCompliance(name, union);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,8 +230,8 @@ public final class HttpCompliance implements ComplianceViolation.Mode
|
||||||
*/
|
*/
|
||||||
public HttpCompliance without(String name, Violation... violations)
|
public HttpCompliance without(String name, Violation... violations)
|
||||||
{
|
{
|
||||||
EnumSet<Violation> remainder = _violations.isEmpty()?EnumSet.noneOf(Violation.class):copyOf(_violations);
|
Set<Violation> remainder = _violations.isEmpty()?EnumSet.noneOf(Violation.class):copyOf(_violations);
|
||||||
remainder.removeAll(copyOf(asList(violations)));
|
remainder.removeAll(copyOf(violations));
|
||||||
return new HttpCompliance(name, remainder);
|
return new HttpCompliance(name, remainder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,4 +240,19 @@ public final class HttpCompliance implements ComplianceViolation.Mode
|
||||||
{
|
{
|
||||||
return String.format("%s%s",_name,_violations);
|
return String.format("%s%s",_name,_violations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static Set<Violation> copyOf(Violation[] violations)
|
||||||
|
{
|
||||||
|
if (violations==null || violations.length==0)
|
||||||
|
return EnumSet.noneOf(Violation.class);
|
||||||
|
return EnumSet.copyOf(asList(violations));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Set<Violation> copyOf(Set<Violation> violations)
|
||||||
|
{
|
||||||
|
if (violations==null || violations.isEmpty())
|
||||||
|
return EnumSet.noneOf(Violation.class);
|
||||||
|
return EnumSet.copyOf(violations);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
<Set name="delayDispatchUntilContent"><Property name="jetty.httpConfig.delayDispatchUntilContent" deprecated="jetty.delayDispatchUntilContent" default="true"/></Set>
|
<Set name="delayDispatchUntilContent"><Property name="jetty.httpConfig.delayDispatchUntilContent" deprecated="jetty.delayDispatchUntilContent" default="true"/></Set>
|
||||||
<Set name="maxErrorDispatches"><Property name="jetty.httpConfig.maxErrorDispatches" default="10"/></Set>
|
<Set name="maxErrorDispatches"><Property name="jetty.httpConfig.maxErrorDispatches" default="10"/></Set>
|
||||||
<Set name="persistentConnectionsEnabled"><Property name="jetty.httpConfig.persistentConnectionsEnabled" default="true"/></Set>
|
<Set name="persistentConnectionsEnabled"><Property name="jetty.httpConfig.persistentConnectionsEnabled" default="true"/></Set>
|
||||||
|
<Set name="httpCompliance"><Call class="org.eclipse.jetty.http.HttpCompliance" name="from"><Arg><Property name="jetty.httpConfig.compliance" deprecated="jetty.http.compliance" default="RFC7230"/></Arg></Call></Set>
|
||||||
<Set name="requestCookieCompliance"><Call class="org.eclipse.jetty.http.CookieCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.requestCookieCompliance" default="RFC6265"/></Arg></Call></Set>
|
<Set name="requestCookieCompliance"><Call class="org.eclipse.jetty.http.CookieCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.requestCookieCompliance" default="RFC6265"/></Arg></Call></Set>
|
||||||
<Set name="responseCookieCompliance"><Call class="org.eclipse.jetty.http.CookieCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.responseCookieCompliance" default="RFC6265"/></Arg></Call></Set>
|
<Set name="responseCookieCompliance"><Call class="org.eclipse.jetty.http.CookieCompliance" name="valueOf"><Arg><Property name="jetty.httpConfig.responseCookieCompliance" default="RFC6265"/></Arg></Call></Set>
|
||||||
</New>
|
</New>
|
||||||
|
|
|
@ -41,6 +41,3 @@ etc/jetty-http.xml
|
||||||
|
|
||||||
## Connect Timeout in milliseconds
|
## Connect Timeout in milliseconds
|
||||||
# jetty.http.connectTimeout=15000
|
# jetty.http.connectTimeout=15000
|
||||||
|
|
||||||
## HTTP Compliance: RFC7230, RFC7230_LEGACY, RFC2616, RFC2616_LEGACY, LEGACY or CUSTOMn
|
|
||||||
# jetty.http.compliance=RFC7230_LEGACY
|
|
||||||
|
|
|
@ -59,15 +59,15 @@ etc/jetty.xml
|
||||||
## Maximum number of error dispatches to prevent looping
|
## Maximum number of error dispatches to prevent looping
|
||||||
# jetty.httpConfig.maxErrorDispatches=10
|
# jetty.httpConfig.maxErrorDispatches=10
|
||||||
|
|
||||||
|
## HTTP Compliance: RFC7230, RFC7230_LEGACY, RFC2616, RFC2616_LEGACY, LEGACY
|
||||||
|
# jetty.httpConfig.compliance=RFC7230
|
||||||
|
|
||||||
## Cookie compliance mode for parsing request Cookie headers: RFC2965, RFC6265
|
## Cookie compliance mode for parsing request Cookie headers: RFC2965, RFC6265
|
||||||
# jetty.httpConfig.requestCookieCompliance=RFC6265
|
# jetty.httpConfig.requestCookieCompliance=RFC6265
|
||||||
|
|
||||||
## Cookie compliance mode for generating response Set-Cookie: RFC2965, RFC6265
|
## Cookie compliance mode for generating response Set-Cookie: RFC2965, RFC6265
|
||||||
# jetty.httpConfig.responseCookieCompliance=RFC6265
|
# jetty.httpConfig.responseCookieCompliance=RFC6265
|
||||||
|
|
||||||
## multipart/form-data compliance mode of: LEGACY(slow), RFC7578(fast)
|
|
||||||
# jetty.httpConfig.multiPartFormDataCompliance=LEGACY
|
|
||||||
|
|
||||||
### Server configuration
|
### Server configuration
|
||||||
## Whether ctrl+c on the console gracefully stops the Jetty server
|
## Whether ctrl+c on the console gracefully stops the Jetty server
|
||||||
# jetty.server.stopAtShutdown=true
|
# jetty.server.stopAtShutdown=true
|
||||||
|
|
Loading…
Reference in New Issue