[ 
https://issues.apache.org/jira/browse/CONNECTORS-1564?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16735944#comment-16735944
 ] 

Erlend Garåsen commented on CONNECTORS-1564:
--------------------------------------------

[~michael-o], as you can see below, the Expect header should already be there. 
This is the original code, except the last line which I have added.

{code:title=HttpPoster.java|borderStyle=solid}

RequestConfig.Builder requestBuilder = RequestConfig.custom()
  .setCircularRedirectsAllowed(true)
  .setSocketTimeout(socketTimeout)
  .setExpectContinueEnabled(true)
  .setConnectTimeout(connectionTimeout)
  .setConnectionRequestTimeout(socketTimeout);

HttpClientBuilder clientBuilder = HttpClients.custom()
  .setConnectionManager(connectionManager)
  .disableAutomaticRetries()
  .setDefaultRequestConfig(requestBuilder.build())
  .setRedirectStrategy(new LaxRedirectStrategy())
  .setRequestExecutor(new HttpRequestExecutor(socketTimeout));

if (userID != null && userID.length() > 0 && password != null)
{
  CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
  Credentials credentials = new UsernamePasswordCredentials(userID, password);
  if (realm != null)
    credentialsProvider.setCredentials(new AuthScope(AuthScope.ANY_HOST, 
AuthScope.ANY_PORT, realm), credentials);
  else
    credentialsProvider.setCredentials(AuthScope.ANY, credentials);

  clientBuilder.setDefaultCredentialsProvider(credentialsProvider);
  clientBuilder.addInterceptorLast(new PreemptiveAuthInterceptor());
}

{code}

> Support preemptive authentication to Solr connector
> ---------------------------------------------------
>
>                 Key: CONNECTORS-1564
>                 URL: https://issues.apache.org/jira/browse/CONNECTORS-1564
>             Project: ManifoldCF
>          Issue Type: Improvement
>          Components: Lucene/SOLR connector
>            Reporter: Erlend Garåsen
>            Assignee: Karl Wright
>            Priority: Major
>         Attachments: CONNECTORS-1564.patch
>
>
> We should post preemptively in case the Solr server requires basic 
> authentication. This will make the communication between ManifoldCF and Solr 
> much more effective instead of the following:
>  * Send a HTTP POST request to Solr
>  * Solr sends a 401 response
>  * Send the same request, but with a "{{Authorization: Basic}}" header
> With preemptive authentication, we can send the header in the first request.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to