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

Unnecessary Content-Charset header in HttpSolrServer

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.6, 4.9
    • Fix Version/s: 4.10, 6.0
    • Component/s: clients - java
    • Labels:
      None

      Description

      The httpclient code in HttpSolrServer currently sets a "Content-Charset" header when making a POST request:

      post.setHeader("Content-Charset", "UTF-8");

      As far as I know this is not a real header and is not necessary. It seems this was a mistake in the original implementation of this class, when converting from httpclient v3 to httpclient v4. CommonsHttpSolrServer did this, which is what the line of code above seems to have been based on:

      post.getParams().setContentCharset("UTF-8");

      The actual way to set the charset in httpclient v4 is already being done correctly, with these lines:

      parts.add(new FormBodyPart(p, new StringBody(v, StandardCharsets.UTF_8)));
      post.setEntity(new UrlEncodedFormEntity(postParams, StandardCharsets.UTF_8));

      So basically, the Content-Charset line can just be removed.

      (I think the explicit setting of the Content-Type header also might be unnecessary, but I haven't taken the time to investigate that.)

      1. SOLR-6360.patch
        2 kB
        Uwe Schindler

        Issue Links

          Activity

          Hide
          thetaphi Uwe Schindler added a comment -

          Thanks. I just committed this. The header was totally unused and has no meaning in the HTTP spec. So it just wastes transfer bandwidth.

          Show
          thetaphi Uwe Schindler added a comment - Thanks. I just committed this. The header was totally unused and has no meaning in the HTTP spec. So it just wastes transfer bandwidth.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 1617219 from Uwe Schindler in branch 'dev/branches/branch_4x'
          [ https://svn.apache.org/r1617219 ]

          Merged revision(s) 1617218 from lucene/dev/trunk:
          SOLR-6360: Remove bogus "Content-Charset" header in HttpSolrServer

          Show
          jira-bot ASF subversion and git services added a comment - Commit 1617219 from Uwe Schindler in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1617219 ] Merged revision(s) 1617218 from lucene/dev/trunk: SOLR-6360 : Remove bogus "Content-Charset" header in HttpSolrServer
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 1617218 from Uwe Schindler in branch 'dev/trunk'
          [ https://svn.apache.org/r1617218 ]

          SOLR-6360: Remove bogus "Content-Charset" header in HttpSolrServer

          Show
          jira-bot ASF subversion and git services added a comment - Commit 1617218 from Uwe Schindler in branch 'dev/trunk' [ https://svn.apache.org/r1617218 ] SOLR-6360 : Remove bogus "Content-Charset" header in HttpSolrServer
          Hide
          thetaphi Uwe Schindler added a comment -

          Patch.

          Show
          thetaphi Uwe Schindler added a comment - Patch.
          Hide
          thetaphi Uwe Schindler added a comment -

          Thanks for reporting this, "Content-Charset" is indeed totally bogus. I will remove the header.

          Show
          thetaphi Uwe Schindler added a comment - Thanks for reporting this, "Content-Charset" is indeed totally bogus. I will remove the header.

            People

            • Assignee:
              thetaphi Uwe Schindler
              Reporter:
              michaelryan Michael Ryan
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development