@@ -49,19 +49,6 @@ public static NioCorsConfigBuilder forAnyOrigin() {
4949 return new NioCorsConfigBuilder ();
5050 }
5151
52- /**
53- * Creates a {@link NioCorsConfigBuilder} instance with the specified origin.
54- *
55- * @return {@link NioCorsConfigBuilder} to support method chaining.
56- */
57- public static NioCorsConfigBuilder forOrigin (final String origin ) {
58- if ("*" .equals (origin )) {
59- return new NioCorsConfigBuilder ();
60- }
61- return new NioCorsConfigBuilder (origin );
62- }
63-
64-
6552 /**
6653 * Create a {@link NioCorsConfigBuilder} instance with the specified pattern origin.
6754 *
@@ -87,14 +74,12 @@ public static NioCorsConfigBuilder forOrigins(final String... origins) {
8774 Optional <Set <String >> origins ;
8875 Optional <Pattern > pattern ;
8976 final boolean anyOrigin ;
90- boolean allowNullOrigin ;
9177 boolean enabled = true ;
9278 boolean allowCredentials ;
9379 long maxAge ;
9480 final Set <HttpMethod > requestMethods = new HashSet <>();
9581 final Set <String > requestHeaders = new HashSet <>();
9682 final Map <CharSequence , Callable <?>> preflightHeaders = new HashMap <>();
97- private boolean noPreflightHeaders ;
9883 boolean shortCircuit ;
9984
10085 /**
@@ -130,18 +115,6 @@ public static NioCorsConfigBuilder forOrigins(final String... origins) {
130115 anyOrigin = false ;
131116 }
132117
133- /**
134- * Web browsers may set the 'Origin' request header to 'null' if a resource is loaded
135- * from the local file system. Calling this method will enable a successful CORS response
136- * with a wildcard for the CORS response header 'Access-Control-Allow-Origin'.
137- *
138- * @return {@link NioCorsConfigBuilder} to support method chaining.
139- */
140- NioCorsConfigBuilder allowNullOrigin () {
141- allowNullOrigin = true ;
142- return this ;
143- }
144-
145118 /**
146119 * Disables CORS support.
147120 *
@@ -219,71 +192,6 @@ public NioCorsConfigBuilder allowedRequestHeaders(final String... headers) {
219192 return this ;
220193 }
221194
222- /**
223- * Returns HTTP response headers that should be added to a CORS preflight response.
224- *
225- * An intermediary like a load balancer might require that a CORS preflight request
226- * have certain headers set. This enables such headers to be added.
227- *
228- * @param name the name of the HTTP header.
229- * @param values the values for the HTTP header.
230- * @return {@link NioCorsConfigBuilder} to support method chaining.
231- */
232- public NioCorsConfigBuilder preflightResponseHeader (final CharSequence name , final Object ... values ) {
233- if (values .length == 1 ) {
234- preflightHeaders .put (name , new ConstantValueGenerator (values [0 ]));
235- } else {
236- preflightResponseHeader (name , Arrays .asList (values ));
237- }
238- return this ;
239- }
240-
241- /**
242- * Returns HTTP response headers that should be added to a CORS preflight response.
243- *
244- * An intermediary like a load balancer might require that a CORS preflight request
245- * have certain headers set. This enables such headers to be added.
246- *
247- * @param name the name of the HTTP header.
248- * @param value the values for the HTTP header.
249- * @param <T> the type of values that the Iterable contains.
250- * @return {@link NioCorsConfigBuilder} to support method chaining.
251- */
252- public <T > NioCorsConfigBuilder preflightResponseHeader (final CharSequence name , final Iterable <T > value ) {
253- preflightHeaders .put (name , new ConstantValueGenerator (value ));
254- return this ;
255- }
256-
257- /**
258- * Returns HTTP response headers that should be added to a CORS preflight response.
259- *
260- * An intermediary like a load balancer might require that a CORS preflight request
261- * have certain headers set. This enables such headers to be added.
262- *
263- * Some values must be dynamically created when the HTTP response is created, for
264- * example the 'Date' response header. This can be accomplished by using a Callable
265- * which will have its 'call' method invoked when the HTTP response is created.
266- *
267- * @param name the name of the HTTP header.
268- * @param valueGenerator a Callable which will be invoked at HTTP response creation.
269- * @param <T> the type of the value that the Callable can return.
270- * @return {@link NioCorsConfigBuilder} to support method chaining.
271- */
272- public <T > NioCorsConfigBuilder preflightResponseHeader (final CharSequence name , final Callable <T > valueGenerator ) {
273- preflightHeaders .put (name , valueGenerator );
274- return this ;
275- }
276-
277- /**
278- * Specifies that no preflight response headers should be added to a preflight response.
279- *
280- * @return {@link NioCorsConfigBuilder} to support method chaining.
281- */
282- public NioCorsConfigBuilder noPreflightResponseHeaders () {
283- noPreflightHeaders = true ;
284- return this ;
285- }
286-
287195 /**
288196 * Specifies that a CORS request should be rejected if it's invalid before being
289197 * further processing.
@@ -305,7 +213,7 @@ public NioCorsConfigBuilder shortCircuit() {
305213 * @return {@link NioCorsConfig} the configured CorsConfig instance.
306214 */
307215 public NioCorsConfig build () {
308- if (preflightHeaders .isEmpty () && ! noPreflightHeaders ) {
216+ if (preflightHeaders .isEmpty ()) {
309217 preflightHeaders .put ("date" , DateValueGenerator .INSTANCE );
310218 preflightHeaders .put ("content-length" , new ConstantValueGenerator ("0" ));
311219 }
0 commit comments