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

SolrJ does not send "Expect: 100-continue" header

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 7.7
    • Fix Version/s: None
    • Component/s: SolrJ
    • Labels:
      None

      Description

      SolrJ does not set the "Expect: 100-continue" header, even though it's configured in HttpClient:

      builder.setDefaultRequestConfig(RequestConfig.custom().setExpectContinueEnabled(true).build());

      A HttpClient developer has reviewed the code and says we're setting up
      the client correctly, so we have a reason to believe there is a bug in
      SolrJ. It's actually a problem we are facing in ManifoldCF, explained in:
      https://issues.apache.org/jira/browse/CONNECTORS-1564

      The problem can be reproduced by building and running the following small Maven project:

      http://folk.uio.no/erlendfg/solr/missing-header.zip

      The application runs SolrJ code where the header does not show up and HttpClient code where the header is present.

       

      HttpClientBuilder builder = HttpClients.custom();
      // This should add an Expect: 100-continue header:
      builder.setDefaultRequestConfig(RequestConfig.custom().setExpectContinueEnabled(true).build());
      HttpClient httpClient = builder.build();
      
      // Start Solr and create a core named "test".
      String baseUrl = "http://localhost:8983/solr/test";
      
      // Test using SolrJ — no expect 100 header
      HttpSolrClient client = new HttpSolrClient.Builder()
        .withHttpClient(httpClient)
        .withBaseSolrUrl(baseUrl).build();
      SolrQuery query = new SolrQuery();
      query.setQuery("*:*");
      client.query(query);
      
      // Test using HttpClient directly — expect 100 header shows up:
      HttpPost httpPost = new HttpPost(baseUrl);
      HttpEntity entity = new InputStreamEntity(new ByteArrayInputStream("test".getBytes()));
      httpPost.setEntity(entity);
      httpClient.execute(httpPost);
      

      When using the last HttpClient test, the expect 100 header appears in missing-header.log:

      http-outgoing-1 >> Expect: 100-continue

        Attachments

        1. SOLR-13270.patch
          12 kB
          Jason Gerlowski

          Activity

            People

            • Assignee:
              gerlowskija Jason Gerlowski
              Reporter:
              erlendfg Erlend Garåsen
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated: