Remove deprecated web APIs
See gh-33809
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.http.client.reactive;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
@@ -76,21 +75,6 @@ public class JettyClientHttpConnector implements ClientHttpConnector {
|
||||
this.httpClient = httpClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with an {@link JettyResourceFactory} that will manage shared resources.
|
||||
* @param resourceFactory the {@link JettyResourceFactory} to use
|
||||
* @param customizer the lambda used to customize the {@link HttpClient}
|
||||
* @deprecated as of 5.2, in favor of
|
||||
* {@link JettyClientHttpConnector#JettyClientHttpConnector(HttpClient, JettyResourceFactory)}
|
||||
*/
|
||||
@Deprecated
|
||||
public JettyClientHttpConnector(JettyResourceFactory resourceFactory, @Nullable Consumer<HttpClient> customizer) {
|
||||
this(new HttpClient(), resourceFactory);
|
||||
if (customizer != null) {
|
||||
customizer.accept(this.httpClient);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the buffer factory to use.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,7 +20,6 @@ import java.util.Collection;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.handler.codec.http.cookie.Cookie;
|
||||
import io.netty.handler.codec.http.cookie.DefaultCookie;
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -81,19 +80,6 @@ class ReactorClientHttpResponse implements ClientHttpResponse {
|
||||
this.bufferFactory = new NettyDataBufferFactory(connection.outbound().alloc());
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with inputs extracted from a {@link Connection}.
|
||||
* @deprecated as of 5.2.8, in favor of {@link #ReactorClientHttpResponse(HttpClientResponse, Connection)}
|
||||
*/
|
||||
@Deprecated
|
||||
public ReactorClientHttpResponse(HttpClientResponse response, NettyInbound inbound, ByteBufAllocator alloc) {
|
||||
this.response = response;
|
||||
MultiValueMap<String, String> adapter = new Netty4HeadersAdapter(response.responseHeaders());
|
||||
this.headers = HttpHeaders.readOnlyHttpHeaders(adapter);
|
||||
this.inbound = inbound;
|
||||
this.bufferFactory = new NettyDataBufferFactory(alloc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -326,60 +326,6 @@ public interface CodecConfigurer {
|
||||
* @since 5.1.13
|
||||
*/
|
||||
void registerWithDefaultConfig(Object codec, Consumer<DefaultCodecConfig> configConsumer);
|
||||
|
||||
/**
|
||||
* Add a custom {@code Decoder} internally wrapped with
|
||||
* {@link DecoderHttpMessageReader}).
|
||||
* @param decoder the decoder to add
|
||||
* @deprecated as of 5.1.13, use {@link #register(Object)} or
|
||||
* {@link #registerWithDefaultConfig(Object)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void decoder(Decoder<?> decoder);
|
||||
|
||||
/**
|
||||
* Add a custom {@code Encoder}, internally wrapped with
|
||||
* {@link EncoderHttpMessageWriter}.
|
||||
* @param encoder the encoder to add
|
||||
* @deprecated as of 5.1.13, use {@link #register(Object)} or
|
||||
* {@link #registerWithDefaultConfig(Object)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void encoder(Encoder<?> encoder);
|
||||
|
||||
/**
|
||||
* Add a custom {@link HttpMessageReader}. For readers of type
|
||||
* {@link DecoderHttpMessageReader} consider using the shortcut
|
||||
* {@link #decoder(Decoder)} instead.
|
||||
* @param reader the reader to add
|
||||
* @deprecated as of 5.1.13, use {@link #register(Object)} or
|
||||
* {@link #registerWithDefaultConfig(Object)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void reader(HttpMessageReader<?> reader);
|
||||
|
||||
/**
|
||||
* Add a custom {@link HttpMessageWriter}. For writers of type
|
||||
* {@link EncoderHttpMessageWriter} consider using the shortcut
|
||||
* {@link #encoder(Encoder)} instead.
|
||||
* @param writer the writer to add
|
||||
* @deprecated as of 5.1.13, use {@link #register(Object)} or
|
||||
* {@link #registerWithDefaultConfig(Object)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void writer(HttpMessageWriter<?> writer);
|
||||
|
||||
/**
|
||||
* Register a callback for the {@link DefaultCodecConfig configuration}
|
||||
* applied to default codecs. This allows custom codecs to follow general
|
||||
* guidelines applied to default ones, such as logging details and limiting
|
||||
* the amount of buffered data.
|
||||
* @param codecsConfigConsumer the default codecs configuration callback
|
||||
* @deprecated as of 5.1.13, use {@link #registerWithDefaultConfig(Object)}
|
||||
* or {@link #registerWithDefaultConfig(Object, Consumer)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
void withDefaultCodecConfig(Consumer<DefaultCodecConfig> codecsConfigConsumer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -166,36 +166,6 @@ abstract class BaseCodecConfigurer implements CodecConfigurer {
|
||||
this.defaultConfigConsumers.add(configConsumer);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void decoder(Decoder<?> decoder) {
|
||||
addCodec(decoder, false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void encoder(Encoder<?> encoder) {
|
||||
addCodec(encoder, false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void reader(HttpMessageReader<?> reader) {
|
||||
addCodec(reader, false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void writer(HttpMessageWriter<?> writer) {
|
||||
addCodec(writer, false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void withDefaultCodecConfig(Consumer<DefaultCodecConfig> codecsConfigConsumer) {
|
||||
this.defaultConfigConsumers.add(codecsConfigConsumer);
|
||||
}
|
||||
|
||||
private void addCodec(Object codec, boolean applyDefaultConfig) {
|
||||
|
||||
if (codec instanceof Decoder<?> decoder) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,29 +35,6 @@ public class HttpMessageNotReadableException extends HttpMessageConversionExcept
|
||||
private final @Nullable HttpInputMessage httpInputMessage;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new HttpMessageNotReadableException.
|
||||
* @param msg the detail message
|
||||
* @deprecated as of 5.1, in favor of {@link #HttpMessageNotReadableException(String, HttpInputMessage)}
|
||||
*/
|
||||
@Deprecated
|
||||
public HttpMessageNotReadableException(String msg) {
|
||||
super(msg);
|
||||
this.httpInputMessage = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new HttpMessageNotReadableException.
|
||||
* @param msg the detail message
|
||||
* @param cause the root cause (if any)
|
||||
* @deprecated as of 5.1, in favor of {@link #HttpMessageNotReadableException(String, Throwable, HttpInputMessage)}
|
||||
*/
|
||||
@Deprecated
|
||||
public HttpMessageNotReadableException(String msg, @Nullable Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.httpInputMessage = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new HttpMessageNotReadableException.
|
||||
* @param msg the detail message
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -248,18 +248,6 @@ public abstract class AbstractListenerWriteProcessor<T> implements Processor<T,
|
||||
*/
|
||||
protected abstract boolean write(T data) throws IOException;
|
||||
|
||||
/**
|
||||
* Invoked after the current data has been written and before requesting
|
||||
* the next item from the upstream, write Publisher.
|
||||
* <p>The default implementation is a no-op.
|
||||
* @deprecated originally introduced for Undertow to stop write notifications
|
||||
* when no data is available, but deprecated as of 5.0.6 since constant
|
||||
* switching on every requested item causes a significant slowdown.
|
||||
*/
|
||||
@Deprecated
|
||||
protected void writingPaused() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked after onComplete or onError notification.
|
||||
* <p>The default implementation is a no-op.
|
||||
@@ -409,7 +397,6 @@ public abstract class AbstractListenerWriteProcessor<T> implements Processor<T,
|
||||
processor.changeStateToReceived(REQUESTED);
|
||||
}
|
||||
else {
|
||||
processor.writingPaused();
|
||||
Assert.state(processor.subscription != null, "No subscription");
|
||||
processor.subscription.request(1);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -72,21 +72,6 @@ public abstract class AbstractServerHttpRequest implements ServerHttpRequest {
|
||||
private @Nullable Supplier<Map<String, Object>> attributesSupplier;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor with the method, URI and headers for the request.
|
||||
* @param method the HTTP method for the request
|
||||
* @param uri the URI for the request
|
||||
* @param contextPath the context path for the request
|
||||
* @param headers the headers for the request (as {@link MultiValueMap})
|
||||
* @since 6.0.8
|
||||
* @deprecated Use {@link #AbstractServerHttpRequest(HttpMethod, URI, String, HttpHeaders)}
|
||||
*/
|
||||
@Deprecated
|
||||
public AbstractServerHttpRequest(HttpMethod method, URI uri, @Nullable String contextPath,
|
||||
MultiValueMap<String, String> headers) {
|
||||
this(method, uri, contextPath, new HttpHeaders(headers));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with the method, URI and headers for the request.
|
||||
* @param method the HTTP method for the request
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -97,25 +97,6 @@ public class DefaultResponseErrorHandler implements ResponseErrorHandler {
|
||||
return statusCode.isError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Template method called from {@link #hasError(ClientHttpResponse)}.
|
||||
* <p>The default implementation checks if the given status code is
|
||||
* {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR CLIENT_ERROR} or
|
||||
* {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR SERVER_ERROR}.
|
||||
* Can be overridden in subclasses.
|
||||
* @param statusCode the HTTP status code as raw value
|
||||
* @return {@code true} if the response indicates an error; {@code false} otherwise
|
||||
* @since 4.3.21
|
||||
* @see org.springframework.http.HttpStatus.Series#CLIENT_ERROR
|
||||
* @see org.springframework.http.HttpStatus.Series#SERVER_ERROR
|
||||
* @deprecated in favor of {@link #hasError(HttpStatusCode)}
|
||||
*/
|
||||
@Deprecated
|
||||
protected boolean hasError(int statusCode) {
|
||||
HttpStatus.Series series = HttpStatus.Series.resolve(statusCode);
|
||||
return (series == HttpStatus.Series.CLIENT_ERROR || series == HttpStatus.Series.SERVER_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the error in the given response with the given resolved status code
|
||||
* and extra information providing access to the request URL and HTTP method.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -823,24 +823,6 @@ public class RestTemplate extends InterceptingHttpAccessor implements RestOperat
|
||||
return doExecute(url, null, method, requestCallback, responseExtractor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given method on the provided URI.
|
||||
* <p>The {@link ClientHttpRequest} is processed using the {@link RequestCallback};
|
||||
* the response with the {@link ResponseExtractor}.
|
||||
* @param url the fully-expanded URL to connect to
|
||||
* @param method the HTTP method to execute (GET, POST, etc.)
|
||||
* @param requestCallback object that prepares the request (can be {@code null})
|
||||
* @param responseExtractor object that extracts the return value from the response (can be {@code null})
|
||||
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
|
||||
* @deprecated in favor of {@link #doExecute(URI, String, HttpMethod, RequestCallback, ResponseExtractor)}
|
||||
*/
|
||||
@Deprecated
|
||||
protected <T> @Nullable T doExecute(URI url, @Nullable HttpMethod method, @Nullable RequestCallback requestCallback,
|
||||
@Nullable ResponseExtractor<T> responseExtractor) throws RestClientException {
|
||||
|
||||
return doExecute(url, null, method, requestCallback, responseExtractor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given method on the provided URI.
|
||||
* <p>The {@link ClientHttpRequest} is processed using the {@link RequestCallback};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -62,8 +62,6 @@ public class UrlBasedCorsConfigurationSource implements CorsConfigurationSource
|
||||
|
||||
private PathMatcher pathMatcher = defaultPathMatcher;
|
||||
|
||||
private @Nullable String lookupPathAttributeName;
|
||||
|
||||
private boolean allowInitLookupPath = true;
|
||||
|
||||
private final Map<PathPattern, CorsConfiguration> corsConfigurations = new LinkedHashMap<>();
|
||||
@@ -180,19 +178,6 @@ public class UrlBasedCorsConfigurationSource implements CorsConfigurationSource
|
||||
this.allowInitLookupPath = allowInitLookupPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the name of the attribute that holds the lookupPath extracted
|
||||
* via {@link UrlPathHelper#getLookupPathForRequest(HttpServletRequest)}.
|
||||
* <p>By default this is {@link UrlPathHelper#PATH_ATTRIBUTE}.
|
||||
* @param name the request attribute to check
|
||||
* @since 5.2
|
||||
* @deprecated as of 5.3 in favor of {@link UrlPathHelper#PATH_ATTRIBUTE}.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setLookupPathAttributeName(String name) {
|
||||
this.lookupPathAttributeName = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure a {@code PathMatcher} to use for pattern matching.
|
||||
* <p>This is an advanced property that should be used only when a
|
||||
@@ -262,12 +247,9 @@ public class UrlBasedCorsConfigurationSource implements CorsConfigurationSource
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private Object resolvePath(HttpServletRequest request) {
|
||||
if (this.allowInitLookupPath && !ServletRequestPathUtils.hasCachedPath(request)) {
|
||||
return (this.lookupPathAttributeName != null ?
|
||||
this.urlPathHelper.getLookupPathForRequest(request, this.lookupPathAttributeName) :
|
||||
this.urlPathHelper.getLookupPathForRequest(request));
|
||||
return this.urlPathHelper.getLookupPathForRequest(request);
|
||||
}
|
||||
Object lookupPath = ServletRequestPathUtils.getCachedPath(request);
|
||||
if (this.pathMatcher != defaultPathMatcher) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,7 +40,6 @@ public abstract class CorsUtils {
|
||||
* Returns {@code true} if the request is a valid CORS one by checking {@code Origin}
|
||||
* header presence and ensuring that origins are different via {@link #isSameOrigin}.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static boolean isCorsRequest(ServerHttpRequest request) {
|
||||
return request.getHeaders().containsHeader(HttpHeaders.ORIGIN) && !isSameOrigin(request);
|
||||
}
|
||||
@@ -66,10 +65,8 @@ public abstract class CorsUtils {
|
||||
* to extract and use, or to discard such headers.
|
||||
* @return {@code true} if the request is a same-origin one, {@code false} in case
|
||||
* of a cross-origin request
|
||||
* @deprecated as of 5.2, same-origin checks are performed directly by {@link #isCorsRequest}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isSameOrigin(ServerHttpRequest request) {
|
||||
private static boolean isSameOrigin(ServerHttpRequest request) {
|
||||
String origin = request.getHeaders().getOrigin();
|
||||
if (origin == null) {
|
||||
return true;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -209,27 +209,6 @@ public class UrlPathHelper {
|
||||
return lookupPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Variant of {@link #getLookupPathForRequest(HttpServletRequest)} that
|
||||
* automates checking for a previously computed lookupPath saved as a
|
||||
* request attribute. The attribute is only used for lookup purposes.
|
||||
* @param request current HTTP request
|
||||
* @param name the request attribute that holds the lookupPath
|
||||
* @return the lookup path
|
||||
* @since 5.2
|
||||
* @deprecated as of 5.3 in favor of using
|
||||
* {@link #resolveAndCacheLookupPath(HttpServletRequest)} and
|
||||
* {@link #getResolvedLookupPath(ServletRequest)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public String getLookupPathForRequest(HttpServletRequest request, @Nullable String name) {
|
||||
String result = null;
|
||||
if (name != null) {
|
||||
result = (String) request.getAttribute(name);
|
||||
}
|
||||
return (result != null ? result : getLookupPathForRequest(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the mapping lookup path for the given request, within the current
|
||||
* servlet mapping if applicable, else within the web application.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.http.codec.support;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -413,19 +412,6 @@ class CodecConfigurerTests {
|
||||
assertThat(encoders).doesNotContain(jacksonEncoder, jaxb2Encoder, protoEncoder);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
void withDefaultCodecConfig() {
|
||||
AtomicBoolean callbackCalled = new AtomicBoolean();
|
||||
this.configurer.defaultCodecs().enableLoggingRequestDetails(true);
|
||||
this.configurer.customCodecs().withDefaultCodecConfig(config -> {
|
||||
assertThat(config.isEnableLoggingRequestDetails()).isTrue();
|
||||
callbackCalled.compareAndSet(false, true);
|
||||
});
|
||||
this.configurer.getReaders();
|
||||
assertThat(callbackCalled).isTrue();
|
||||
}
|
||||
|
||||
private Decoder<?> getNextDecoder(List<HttpMessageReader<?>> readers) {
|
||||
HttpMessageReader<?> reader = readers.get(this.index.getAndIncrement());
|
||||
assertThat(reader.getClass()).isEqualTo(DecoderHttpMessageReader.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2024 the original author or authors.
|
||||
* Copyright 2002-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -89,16 +89,14 @@ class CorsUtilsTests {
|
||||
}
|
||||
|
||||
@Test // SPR-16362
|
||||
@SuppressWarnings("deprecation")
|
||||
public void isSameOriginWithDifferentSchemes() {
|
||||
MockServerHttpRequest request = MockServerHttpRequest
|
||||
.get("http://mydomain1.example")
|
||||
.header(HttpHeaders.ORIGIN, "https://mydomain1.example")
|
||||
.build();
|
||||
assertThat(CorsUtils.isSameOrigin(request)).isFalse();
|
||||
assertThat(CorsUtils.isCorsRequest(request)).isTrue();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void testWithXForwardedHeaders(String serverName, int port,
|
||||
String forwardedProto, String forwardedHost, int forwardedPort, String originHeader) {
|
||||
|
||||
@@ -119,10 +117,9 @@ class CorsUtilsTests {
|
||||
}
|
||||
|
||||
ServerHttpRequest request = adaptFromForwardedHeaders(builder);
|
||||
assertThat(CorsUtils.isSameOrigin(request)).isTrue();
|
||||
assertThat(CorsUtils.isCorsRequest(request)).isFalse();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void testWithForwardedHeader(String serverName, int port,
|
||||
String forwardedHeader, String originHeader) {
|
||||
|
||||
@@ -136,7 +133,7 @@ class CorsUtilsTests {
|
||||
.header(HttpHeaders.ORIGIN, originHeader);
|
||||
|
||||
ServerHttpRequest request = adaptFromForwardedHeaders(builder);
|
||||
assertThat(CorsUtils.isSameOrigin(request)).isTrue();
|
||||
assertThat(CorsUtils.isCorsRequest(request)).isFalse();
|
||||
}
|
||||
|
||||
// SPR-16668
|
||||
|
||||
@@ -43,7 +43,6 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MimeType;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
/**
|
||||
@@ -210,22 +209,6 @@ public final class MockServerHttpRequest extends AbstractServerHttpRequest {
|
||||
return method(method, toUri(uri, vars));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a builder with a raw HTTP method value that is outside the
|
||||
* range of {@link HttpMethod} enum values.
|
||||
* @param httpMethod the HTTP methodValue value
|
||||
* @param uri the URI template for target the URL
|
||||
* @param vars variables to expand into the template
|
||||
* @return the created builder
|
||||
* @since 5.2.7
|
||||
* @deprecated in favor of {@link #method(HttpMethod, String, Object...)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static BodyBuilder method(String httpMethod, String uri, @Nullable Object... vars) {
|
||||
Assert.isTrue(StringUtils.hasText(httpMethod), "HTTP method is required.");
|
||||
return new DefaultBodyBuilder(HttpMethod.valueOf(httpMethod), toUri(uri, vars));
|
||||
}
|
||||
|
||||
private static URI toUri(String uri, @Nullable Object[] vars) {
|
||||
return UriComponentsBuilder.fromUriString(uri).buildAndExpand(vars).encode().toUri();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user