@@ -49,19 +49,6 @@ public static Netty4CorsConfigBuilder forAnyOrigin() {
4949 return new Netty4CorsConfigBuilder ();
5050 }
5151
52- /**
53- * Creates a {@link Netty4CorsConfigBuilder} instance with the specified origin.
54- *
55- * @return {@link Netty4CorsConfigBuilder} to support method chaining.
56- */
57- public static Netty4CorsConfigBuilder forOrigin (final String origin ) {
58- if ("*" .equals (origin )) {
59- return new Netty4CorsConfigBuilder ();
60- }
61- return new Netty4CorsConfigBuilder (origin );
62- }
63-
64-
6552 /**
6653 * Create a {@link Netty4CorsConfigBuilder} instance with the specified pattern origin.
6754 *
@@ -94,7 +81,6 @@ public static Netty4CorsConfigBuilder forOrigins(final String... origins) {
9481 final Set <HttpMethod > requestMethods = new HashSet <>();
9582 final Set <String > requestHeaders = new HashSet <>();
9683 final Map <CharSequence , Callable <?>> preflightHeaders = new HashMap <>();
97- private boolean noPreflightHeaders ;
9884 boolean shortCircuit ;
9985
10086 /**
@@ -130,18 +116,6 @@ public static Netty4CorsConfigBuilder forOrigins(final String... origins) {
130116 anyOrigin = false ;
131117 }
132118
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 Netty4CorsConfigBuilder} to support method chaining.
139- */
140- Netty4CorsConfigBuilder allowNullOrigin () {
141- allowNullOrigin = true ;
142- return this ;
143- }
144-
145119 /**
146120 * Disables CORS support.
147121 *
@@ -219,71 +193,6 @@ public Netty4CorsConfigBuilder allowedRequestHeaders(final String... headers) {
219193 return this ;
220194 }
221195
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 Netty4CorsConfigBuilder} to support method chaining.
231- */
232- public Netty4CorsConfigBuilder 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 Netty4CorsConfigBuilder} to support method chaining.
251- */
252- public <T > Netty4CorsConfigBuilder 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 Netty4CorsConfigBuilder} to support method chaining.
271- */
272- public <T > Netty4CorsConfigBuilder 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 Netty4CorsConfigBuilder} to support method chaining.
281- */
282- public Netty4CorsConfigBuilder noPreflightResponseHeaders () {
283- noPreflightHeaders = true ;
284- return this ;
285- }
286-
287196 /**
288197 * Specifies that a CORS request should be rejected if it's invalid before being
289198 * further processing.
@@ -305,7 +214,7 @@ public Netty4CorsConfigBuilder shortCircuit() {
305214 * @return {@link Netty4CorsConfig} the configured CorsConfig instance.
306215 */
307216 public Netty4CorsConfig build () {
308- if (preflightHeaders .isEmpty () && ! noPreflightHeaders ) {
217+ if (preflightHeaders .isEmpty ()) {
309218 preflightHeaders .put ("date" , DateValueGenerator .INSTANCE );
310219 preflightHeaders .put ("content-length" , new ConstantValueGenerator ("0" ));
311220 }
0 commit comments