spring-cloud / spring-cloud/spring-cloud-gateway
gateway MVC - Multi-part + query string not working
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.9k
- Forks
- 3.5k
- Avg merge
- 20h 57m
- Merged PRs (30d)
- 8
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MVC gateway route in the sample GatewayConfiguration and reproduce the POST to /test using the provided multipart request and query string, comparing it with the direct server request. Trace the forwarded request and verify that the query string and Content-Length are preserved; done means the downstream server receives both correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100