lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erlend GarĂ¥sen <e.f.gara...@usit.uio.no>
Subject SolrJ removes header set by HttpClient
Date Fri, 01 Feb 2019 12:44:21 GMT

For some reasons, the "Expect: 100-continue" header will not be set,
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 I 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

I have created a small application which can build by Maven in order to
test it. It logs the http traffic to missing-header.log. The application
also adds another header which *does* show up in the app log:
builder.setDefaultHeaders(Arrays.asList(new
BasicHeader("X-Default-Header", "default header")));

DEBUG 01.02.2019 13:14:59:768 (Wire.java:wire:73) - http-outgoing-0 >>
"X-Default-Header: default header[\r][\n]"

But no Expect: 100-continue header.

The small app/code example is available here:
http://folk.uio.no/erlendfg/solr/

Solr 7.4.0 is used in the app, but the same happens by using 7.6.0 (can
be configured in pom.xml).

It's actually as simple as this:
HttpClientBuilder builder = HttpClients.custom();
// This header shows up:
builder.setDefaultHeaders(Arrays.asList(new
BasicHeader("X-Default-Header", "default header")));
// This should add an Expect: 100-continue header, but it's missing:
 builder.setDefaultRequestConfig(RequestConfig.custom().setExpectContinueEnabled(true).build());

HttpClient httpClient = builder.build();
HttpSolrClient client = new HttpSolrClient.Builder()
  .withHttpClient(httpClient)
  .withBaseSolrUrl("http://localhost:8983/solr").build();

Erlend

Mime
View raw message