Mule
  1. Mule
  2. MULE-5628

Mule breaks multipart/form-data encoded messages

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 3.1.1
    • Fix Version/s: 3.1.4 (EE only), 3.2.1
    • Component/s: Modules: Jersey
    • Labels:
    • Environment:

      Fedora 15
      java-1.6.0-openjdk-1.6.0.0-58.1.10.2.fc15.i686

    • User impact:
      High
    • Configuration:
      Hide
      <?xml version="1.0" encoding="UTF-8"?>
      <mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:spring="http://www.springframework.org/schema/beans"
      xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey"
      xsi:schemaLocation="
      http://www.springframework.org/schema/beans
      http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
      http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd
      http://www.mulesoft.org/schema/mule/jersey
      http://www.mulesoft.org/schema/mule/jersey/3.0/mule-jersey.xsd
      http://jersey.apache.org/core http://jersey.apache.org/schemas/core.xsd">
      
      	<flow name="X12ToSummaryHtml">
      		<inbound-endpoint address="http://localhost:8080/jersey" />
      		<jersey:resources>
      			<component class="com.optuminsight.unionstation.service.X12ToSummaryHtml" />
      		</jersey:resources>
      	</flow>
      </mule>
      
          @POST
          @Path("/getSummaryHtml")
          @Consumes(MediaType.MULTIPART_FORM_DATA)
          @Produces("text/html")
          public final Response getSummaryHtml(@FormDataParam("x12file") final InputStream x12file) throws IOException {
              LOG.info("called getSummaryHtml");
              return Response.ok(IOUtils.toString(x12file)).build();
          }
      
      Show
      <?xml version= "1.0" encoding= "UTF-8" ?> <mule xmlns= "http://www.mulesoft.org/schema/mule/core" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns:spring = "http://www.springframework.org/schema/beans" xmlns:jersey = "http://www.mulesoft.org/schema/mule/jersey" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd http://www.mulesoft.org/schema/mule/jersey http://www.mulesoft.org/schema/mule/jersey/3.0/mule-jersey.xsd http://jersey.apache.org/core http://jersey.apache.org/schemas/core.xsd"> <flow name= "X12ToSummaryHtml" > <inbound-endpoint address= "http://localhost:8080/jersey" /> <jersey:resources> <component class= "com.optuminsight.unionstation.service.X12ToSummaryHtml" /> </jersey:resources> </flow> </mule> @POST @Path( "/getSummaryHtml" ) @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces( "text/html" ) public final Response getSummaryHtml(@FormDataParam( "x12file" ) final InputStream x12file) throws IOException { LOG.info( "called getSummaryHtml" ); return Response.ok(IOUtils.toString(x12file)).build(); }
    • Log Output:
      Hide
      About to connect() to localhost port 8080 (#0)
      Trying 127.0.0.1... connected
      Connected to localhost (127.0.0.1) port 8080 (#0)

      POST /jersey/X12ToSummaryHtml/getHtml/ HTTP/1.1
      User-Agent: curl/7.21.3 (i386-redhat-linux-gnu) libcurl/7.21.3 NSS/3.12.10.0 zlib/1.2.5 libidn/1.19 libssh2/1.2.7
      Host: localhost:8080
      Accept: /
      Content-Length: 2706
      Expect: 100-continue
      Content-Type: multipart/form-data; boundary=----------------------------55b24ac88245
      < HTTP/1.1 100 Continue
      < Content-Type: text/plain
      < Content-Length: 0
      < Connection: close
      < HTTP/1.1 400 Bad Request
      < Content-Type: multipart/form-data; boundary=----------------------------55b24ac88245
      < Date: Sat, 25 Jun 2011 01:29:10 MDT
      < Server: Mule Core/3.1.1
      < Expires: Sat, 25 Jun 2011 01:29:10 MDT
      < http.status: 400
      < MULE_ENCODING: UTF-8
      < Transfer-Encoding: chunked
      < Connection: close
      <
      Show
      About to connect() to localhost port 8080 (#0) Trying 127.0.0.1... connected Connected to localhost (127.0.0.1) port 8080 (#0) POST /jersey/X12ToSummaryHtml/getHtml/ HTTP/1.1 User-Agent: curl/7.21.3 (i386-redhat-linux-gnu) libcurl/7.21.3 NSS/3.12.10.0 zlib/1.2.5 libidn/1.19 libssh2/1.2.7 Host: localhost:8080 Accept: / Content-Length: 2706 Expect: 100-continue Content-Type: multipart/form-data; boundary=----------------------------55b24ac88245 < HTTP/1.1 100 Continue < Content-Type: text/plain < Content-Length: 0 < Connection: close < HTTP/1.1 400 Bad Request < Content-Type: multipart/form-data; boundary=----------------------------55b24ac88245 < Date: Sat, 25 Jun 2011 01:29:10 MDT < Server: Mule Core/3.1.1 < Expires: Sat, 25 Jun 2011 01:29:10 MDT < http.status: 400 < MULE_ENCODING: UTF-8 < Transfer-Encoding: chunked < Connection: close <
    • Similar Issues:
      None

      Description

      I wrote a Jersey class that was supposed to accept a multipart/form-data encoded POST from a html form. It returned a 400 error. Digging into the actual problem, I found that a MIMEParsingException is being thrown by mimepull (a Jersey dependency). The body of the post is getting corrupted somehow. I've confirmed that the Jersey class is working correctly by deploying it in a Jetty container and testing it there.

      Until this gets fixed, I can't create a web service that accepts files

      The original report is at http://forums.mulesoft.org/thread.jspa?messageID=16784#16784

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Santiago Vacas
              Reporter:
              Ben Mathews
            • Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                7/Dec/11

                Development