Skip to content

Commit 7a41f6a

Browse files
committed
Revert "Handle URL Connection file not found 404"
This reverts commit 57c0258.
1 parent 57c0258 commit 7a41f6a

File tree

3 files changed

+6
-108
lines changed

3 files changed

+6
-108
lines changed

spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/handler/RestClientProxyExchange.java

+3-10
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.cloud.gateway.server.mvc.handler;
1818

19-
import java.io.FileNotFoundException;
2019
import java.io.IOException;
2120
import java.io.InputStream;
2221
import java.io.OutputStream;
@@ -70,15 +69,9 @@ private static int copyBody(Request request, OutputStream outputStream) throws I
7069
}
7170

7271
private ServerResponse doExchange(Request request, ClientHttpResponse clientResponse) throws IOException {
73-
try {
74-
InputStream body = clientResponse.getBody();
75-
// put the body input stream in a request attribute so filters can read it.
76-
MvcUtils.putAttribute(request.getServerRequest(), MvcUtils.CLIENT_RESPONSE_INPUT_STREAM_ATTR, body);
77-
}
78-
catch (FileNotFoundException e) {
79-
// if using SimpleClientHttpRequestFactory
80-
return ServerResponse.notFound().build();
81-
}
72+
InputStream body = clientResponse.getBody();
73+
// put the body input stream in a request attribute so filters can read it.
74+
MvcUtils.putAttribute(request.getServerRequest(), MvcUtils.CLIENT_RESPONSE_INPUT_STREAM_ATTR, body);
8275
ServerResponse serverResponse = GatewayServerResponse.status(clientResponse.getStatusCode())
8376
.build((req, httpServletResponse) -> {
8477
try (clientResponse) {

spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/ServerMvcIntegrationTests.java

+3-18
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,12 @@ public void stripPrefixPostWorks() {
275275
public void setStatusGatewayRouterFunctionWorks() {
276276
restClient.get()
277277
.uri("/status/201")
278-
.header("Host", "www.setstatus.org")
279278
.exchange()
280279
.expectStatus()
281280
.isEqualTo(HttpStatus.TOO_MANY_REQUESTS)
282281
.expectHeader()
283-
.valueEquals("x-status", "201");
282+
.valueEquals("x-status", "201"); // .expectBody(String.class).isEqualTo("Failed
283+
// with 201");
284284
}
285285

286286
@Test
@@ -981,11 +981,6 @@ public void clientResponseBodyAttributeWorks() {
981981
});
982982
}
983983

984-
@Test
985-
public void notFoundWorks() {
986-
restClient.get().uri("/status/404").header("Host", "www.notfound.org").exchange().expectStatus().isNotFound();
987-
}
988-
989984
@SpringBootConfiguration
990985
@EnableAutoConfiguration
991986
@LoadBalancerClient(name = "httpbin", configuration = TestLoadBalancerConfig.Httpbin.class)
@@ -1037,7 +1032,7 @@ public RouterFunction<ServerResponse> gatewayRouterFunctionsAddReqHeader() {
10371032
public RouterFunction<ServerResponse> gatewayRouterFunctionsSetStatusAndAddRespHeader() {
10381033
// @formatter:off
10391034
return route("testsetstatus")
1040-
.GET("/status/{status}", host("**.setstatus.org"), http())
1035+
.GET("/status/{status}", http())
10411036
.before(new HttpbinUriResolver())
10421037
.after(setStatus(HttpStatus.TOO_MANY_REQUESTS))
10431038
.after(addResponseHeader("X-Status", "{status}"))
@@ -1605,16 +1600,6 @@ public RouterFunction<ServerResponse> gatewayRouterFunctionsReadResponseBody() {
16051600
// @formatter:on
16061601
}
16071602

1608-
@Bean
1609-
public RouterFunction<ServerResponse> gatewayRouterFunctions404() {
1610-
// @formatter:off
1611-
return route("testnotfound")
1612-
.GET("/status/404", host("**.notfound.org"), http())
1613-
.before(new HttpbinUriResolver())
1614-
.build();
1615-
// @formatter:on
1616-
}
1617-
16181603
@Bean
16191604
public FilterRegistrationBean myFilter() {
16201605
FilterRegistrationBean<MyFilter> reg = new FilterRegistrationBean<>(new MyFilter());

spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/SimpleHttpClientIntegrationTests.java

-80
This file was deleted.

0 commit comments

Comments
 (0)