zhfeng commented on code in PR #17528:
URL: https://github.com/apache/camel/pull/17528#discussion_r2009678179
##########
components/camel-platform-http-vertx/src/main/java/org/apache/camel/component/platform/http/vertx/DefaultHttpRequestBodyHandler.java:
##########
@@ -27,21 +27,27 @@
import static
org.apache.camel.component.platform.http.vertx.VertxPlatformHttpSupport.isMultiPartFormData;
/**
- * Default {@link HttpRequestBodyHandler} that will read to read the entire
HTTP request body into memory.
+ * Default {@link HttpRequestBodyHandler} that will read the entire HTTP
request body into memory if useBodyHandler is
+ * enabled.
*/
class DefaultHttpRequestBodyHandler extends HttpRequestBodyHandler {
- DefaultHttpRequestBodyHandler(Handler<RoutingContext> delegate) {
+ final boolean useBodyHandler;
+
+ DefaultHttpRequestBodyHandler(Handler<RoutingContext> delegate, boolean
useBodyHandler) {
Review Comment:
Hi @jamesnetherton ,
I create such a test
```java
public class VertxPlatformHttpNoBodyHandlerTest {
private final int port = AvailablePortFinder.getNextAvailable();
private final WireMockServer wireMockServer = new
WireMockServer(options().port(port));
@BeforeEach
void before() {
wireMockServer.stubFor(post(urlPathEqualTo("/test"))
.withRequestBody(containing("Hello World"))
.willReturn(aResponse()
.withBody("This is a test")));
wireMockServer.start();
}
@AfterEach
void after() {
if (wireMockServer != null) {
wireMockServer.stop();
}
}
@Test
void testNoBodyHandler() throws Exception {
final CamelContext context =
VertxPlatformHttpEngineTest.createCamelContext();
final var mockUrl = "http://localhost:" + wireMockServer.port();
try {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
from("platform-http:/camel?matchOnUriPrefix=true&useBodyHandler=false")
.process(exchange -> {
HttpMessage message =
exchange.getMessage(HttpMessage.class);
message.setBody(message.getRequest());
})
.removeHeader("CamelHttpUri")
.setHeader("OrgCamelHttpUri", simple(mockUrl +
"${header.CamelHttpPath}"))
.setHeader("CamelHttpPath", simple(""))
.toD("${bean:" + PathCreator.class.getName()
+
"?method=createNewUri(${header.OrgCamelHttpUri})}?bridgeEndpoint=true");
}
});
context.start();
given()
.body("Hello World")
.post("/camel/test")
.then()
.statusCode(200)
.body(is("This is a test"));
} finally {
context.stop();
}
}
}
```
But the test is hanging and can not get any response. When I remove the line
`message.setBody(message.getRequest());`, it starts to work. I'm struggling for
a while. Can you give me some lights?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]