Why is Jetty-http throwing an "Incomplete Multipart" exception?

68 views Asked by At

I have an Apache ServiceMix-based Jetty9 (v2022) with Apache Camel 2.25.4 running, but I get an exception when requesting the following Jetty endpoint with a Multipart-Request out of Firefox Dev-Tools.

My route in Apache Camel (Blueprint XML)

<route id="restservice">
<from uri="jetty:http://0.0.0.0:10060/input?handlers=securityHandler&amp;httpMethodRestrict=PUT,POST&amp;mapHttpMessageBody=true"/>
<log message="1 DEBUG BODY: ${body}"/>
<toD uri="log:showdetails?showAll=true"/>
</route>

My Request:

await fetch("DUMMY", {
    "credentials": "include",
    "headers": {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0",
        "Accept": "*/*",
        "Accept-Language": "de,en-US;q=0.7,en;q=0.3",
        "Sec-Fetch-Dest": "empty",
        "Sec-Fetch-Mode": "no-cors",
        "Sec-Fetch-Site": "same-origin",
        "Pragma": "no-cache",
        "Cache-Control": "no-cache",
        "Authorization": DUMMY
        "Content-Length": 151 (<= bytes, not Characters)
        "Content-Type": "multipart/form-data;boundary=---------------------------2446457052814"
    },
    "referrer": "DUMMY",
    "body": "-----------------------------24464570528145\nContent-Disposition: form-data; name=\"f\";\n\n\nthe larger icon\n-----------------------------24464570528145--\n",
    "method": "POST",
    "mode": "cors"
});

-----------------------------24464570528145
Content-Disposition: form-data; name="f";


the larger icon
-----------------------------24464570528145--

From Jetty Comp I get:

org.eclipse.jetty.util - 9.4.46.v20220331 | handleException /path java.io.IOException: Incomplete Multipart

and in the Response:

HTTP ERROR 500 Server Error
URI: /path
STATUS: 500
MESSAGE: Server Error
SERVLET: org.apache.camel.component.jetty.CamelContinuationServlet-71f4fb97
CAUSED BY java.io.IOException: Incomplete Multipart
java.io.IOException: Incomplete Multipart
    at org.eclipse.jetty.http.MultiPartFormInputStream.parse(MultiPartFormInputStream.java:570)
    at org.eclipse.jetty.http.MultiPartFormInputStream.getParts(MultiPartFormInputStream.java:427)
    at org.eclipse.jetty.server.MultiParts$MultiPartsHttpParser.getParts(MultiParts.java:67)
    at org.eclipse.jetty.server.Request.getParts(Request.java:2425)
    at org.eclipse.jetty.server.Request.getParts(Request.java:2409)
    at org.apache.camel.component.jetty.MultiPartFilter.doFilter(MultiPartFilter.java:53)
    at org.apache.camel.component.jetty.CamelFilterWrapper.doFilter(CamelFilterWrapper.java:44)
    at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
    at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1440)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
    at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1355)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:560)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
    at org.eclipse.jetty.server.Server.handle(Server.java:516)
    at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:487)
    at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:732)
    at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:479)
    at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
    at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
    at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
    at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)
    at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
    at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:409)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
    at java.lang.Thread.run(Thread.java:750)
    Suppressed: java.lang.Throwable
        at org.eclipse.jetty.http.MultiPartFormInputStream.throwIfError(MultiPartFormInputStream.java:470)
        at org.eclipse.jetty.http.MultiPartFormInputStream.getParts(MultiPartFormInputStream.java:428)
        ... 33 more

Jetty Code causing the failure is here i assume: GitHub Code Ref of the MultipartInputStreamParser From the code I assume, 470 * @throws IOException if unable to get the parts is the problem, but I don't get why?

I tried to send different Bodys to check if my Headers are incorrect like: --f-- and they seem to go threw. So the Headers work, but if I put stuff in the Body, it breaks.

I expect it to work like a charm ;)

Can someone explain to me why this is happening?

Actually there is a post: Post on StackOverflow which deals with the same problem, but I already checked the solution.

What can I do to get clean parts that the Parser can work with?

0

There are 0 answers