spring-cloud-gateway: gateway MVC - Multi-part + query string not working
Describe the bug
With spring cloud gateway mvc 2023.0.0 when we perform an post request with multi part and query string, the query string was loose.
Exemple with an test server on port 9008 and a gateway on port 9007
if i point on the server directly :
if i use the gateway :
Sample http-interceptor : (it’s juste a test server to print the query param)
public class MainStandAlone {
public static void main(String[] args) throws IOException {
ThreadPoolExecutor threadPoolExecutor = (ThreadPoolExecutor) Executors.newFixedThreadPool(10);
HttpServer server = HttpServer.create(new InetSocketAddress("localhost", 9008), 0);
server.createContext("/", exchange -> {
System.out.println(exchange.getRequestURI());
exchange.getResponseBody().write("OK".getBytes(StandardCharsets.UTF_8));
exchange.sendResponseHeaders(200, "OK".length());
exchange.getResponseBody().flush();
exchange.getResponseBody().close();
});
server.setExecutor(threadPoolExecutor);
server.start();
System.out.println(" Server started on port 9008");
}
}
gateway : (spring initializr)
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Configuration
public static class GatewayConfiguration {
@Bean
public RouterFunction<ServerResponse> routerFunction() {
return route()
.POST("/test", http("http://localhost:9008"))
.build();
}
}
}
EDIT:
Moreover the header Content-Length are delete by the gateway
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 5
- Comments: 15 (2 by maintainers)
Is Spring Cloud Gateway a maintained project? How comes this issue is not solved? This is the second issue (double url encoding https://github.com/spring-cloud/spring-cloud-gateway/issues/2065) with broken base functionality i’m facing when using Spring Cloud Gateway MVC.
Any indication when this issue will be solved?
I’m experiencing the same issue with spring cloud gateway mvc.
@spencergibb kindly help to check this issue
I had the same issue, i ended up overriding the ProxyExchangeHandlerFunction, `package com.apigateway;
import lombok.extern.Slf4j.Slf4j; import org.springframework.beans.factory.ObjectProvider; import org.springframework.cloud.gateway.server.mvc.common.MvcUtils; import org.springframework.cloud.gateway.server.mvc.filter.HttpHeadersFilter; import org.springframework.cloud.gateway.server.mvc.handler.ProxyExchange; import org.springframework.cloud.gateway.server.mvc.handler.ProxyExchangeHandlerFunction; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.servlet.function.ServerRequest; import org.springframework.web.servlet.function.ServerResponse; import org.springframework.web.util.UriComponentsBuilder;
import java.net.URI; import java.util.Set; import java.util.function.Function; import java.util.stream.Stream;
@Slf4j @Component public class ProxyExchangeHandler extends ProxyExchangeHandlerFunction {
} `
How do I edit this? @lohoso
I have the same problem! How should this problem be solved? I use Spring Cloud Gateway MVC 4.1.2 and Spring Boot 3.2.4