34
34
35
35
public class NetworkOptions {
36
36
37
+ private static final String NETWORK_SECTION = "network" ;
38
+
37
39
private final Config config ;
38
40
// These are commonly used by process which can't set various headers.
39
41
private final Set <String > SKIP_CHECKS_ON = ImmutableSet .of ("/status" , "/readyz" );
@@ -50,16 +52,16 @@ public Filter getSpecComplianceChecks() {
50
52
// Base case: we do nothing
51
53
Filter toReturn = httpHandler -> httpHandler ;
52
54
53
- if (config .getBool ("network" , "relax-checks" ).orElse (false )) {
55
+ if (config .getBool (NETWORK_SECTION , "relax-checks" ).orElse (false )) {
54
56
return toReturn ;
55
57
}
56
58
57
- if (config .getBool ("network" , "check_content_type" ).orElse (true )) {
59
+ if (config .getBool (NETWORK_SECTION , "check_content_type" ).orElse (true )) {
58
60
toReturn = toReturn .andThen (new CheckContentTypeHeader (SKIP_CHECKS_ON ));
59
61
}
60
62
61
- boolean checkOrigin = config .getBool ("network" , "check_origin_header" ).orElse (true );
62
- Optional <List <String >> allowedOrigins = config .getAll ("network" , "allowed_origins" );
63
+ boolean checkOrigin = config .getBool (NETWORK_SECTION , "check_origin_header" ).orElse (true );
64
+ Optional <List <String >> allowedOrigins = config .getAll (NETWORK_SECTION , "allowed_origins" );
63
65
64
66
if (checkOrigin || allowedOrigins .isPresent ()) {
65
67
toReturn = toReturn .andThen (new CheckOriginHeader (allowedOrigins .orElse (ImmutableList .of ()), SKIP_CHECKS_ON ));
0 commit comments