Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST p:http-request gives "MIME type may not contain reserved characters" #290

gimsieke opened this issue Apr 7, 2019 · 5 comments


Copy link

@gimsieke gimsieke commented Apr 7, 2019

This happens first in 1.1.25 (all Saxon versions) and is probably related to the upgrade to httpclient-4.5.5.jar

Running this pipeline:

<p:declare-step xmlns:p="" 
  xmlns:c="" version="1.0" name="mystep">

  <p:input port="source" primary="true">
  <p:output port="result" primary="true">
    <p:pipe port="result" step="post"/>

  <p:import href=""/>
  <p:in-scope-names name="vars"/>
  <p:template name="http-request">
    <p:input port="template">
        <c:request href="" method="POST" detailed="true">
          <c:multipart content-type="multipart/form-data" boundary="=-=-=-=-=">
            <c:body content-type="application/xml" disposition='form-data; name="data"; filename="test.xml"'>
    <p:input port="source">
      <p:pipe step="mystep" port="source"/>
    <p:input port="parameters">
      <p:pipe step="vars" port="result"/>

  <p:http-request name="post"/>
  <p:store href="result.json" cx:decode="true">
    <p:input port="source" select="/c:response/c:body"/>

succeeds in all versions up to and including 1.1.24. It fails with

ERROR: Pipeline failed: MIME type may not contain reserved characters

in 1.1.25 and newer.

Copy link

@ndw ndw commented Apr 9, 2019

I believe that it's related to the 4.4.6 version of the httpclient library:

elastic/elasticsearch#26438 (comment)

(My build.gradle file is only requesting 4.4.5, but I see that 4.4.9 is being pulled in.)

The content type includes the boundary parameter and therefore contains a ";" which is what the 4.4.6+ version is complaining about.

AFAICT, the MultipartEntityBuilder is the new/right way to build multipart bodies. However, it appears to have a completely fatal flaw in that there's no provision for providing additional headers for the various parts.

I have no idea what to do with this.

In the short term, if you can force your app to use the 4.4.5 httpclient library, I think the problem will go away.

Copy link
Contributor Author

@gimsieke gimsieke commented Apr 9, 2019

I replaced httpclient-4.5.5.jar and httpcore-4.4.9.jar with httpclient-4.5.2.jar and httpcore-4.4.5.jar in the lib directory of the extracted 1.1.22-99 release zip, but then I get:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/http/client/HttpRequestRetryHandler
So maybe you’re already using some newer httpclient functionality?

Copy link

@ndw ndw commented Apr 10, 2019

I made a small amount of progress with the MultipartEntityBuilder but it seems fundamentally designed with form submissions in mind. I've just joined the httpclient-users mailing list, hopefully I can get some more answers from there.


Copy link

@ndw ndw commented Jun 2, 2019

I believe this is fixed in 1.1.27.

The content-disposition of parts is labeled "form-data" even when it isn't, but I'm hoping this doesn't cause any problems.

@ndw ndw closed this Jun 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants