Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-10973

SolrJ: ContentType is not parsed properly in HttpSolrClient

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 6.6
    • 6.7, 7.0
    • SolrJ
    • None

    Description

      When multipart posting is used, the content type is passed to the constructor for InputStreamBody as a simple string:

                  parts.add(new FormBodyPart(name,
                      new InputStreamBody(
                          content.getStream(),
                          contentType,
                          content.getName())));
      

      This is incorrect; HttpClient does not parse that contentType as anything other than a mime type and thus blows up when you pass in something like "text/plain; charset=utf-8". The correct code is:

                  parts.add(new FormBodyPart(name,
                      new InputStreamBody(
                          content.getStream(),
                          ContentType.parse(contentType),
                          content.getName())));
      

      This was discovered by a ManifoldCF user.

      Attachments

        Activity

          People

            kwright@metacarta.com Karl Wright
            kwright@metacarta.com Karl Wright
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: