Villam, this is a question for httpclient, I think you want to enable preemptive authentication so as to avoid the need to repeat the query after the "unauthorized" response is sent. http://hc.apache.org/httpclient-3.x/authentication.html#Preemptive_Authentication
paul Le 8 août 2012 à 17:08, vilo a écrit : > I have protected my solr server with basic authentication. Now I want to > connect to it using SOLRJ. CommonsHttpSolrServer is now deprecated, so I try > to use HttpSolrServer, but I fail to send credentials. If I put them to the > url, I get 401 (http://user:passw...@example.com/solr). I tried this: > > HttpSolrServer solr = new HttpSolrServer(urlString); > DefaultHttpClient httpClient = (DefaultHttpClient) solr.getHttpClient(); > httpClient.getCredentialsProvider().setCredentials( > new AuthScope(url.getHost(), url.getPort()), > new UsernamePasswordCredentials(username, password)); > > but I get "org.apache.http.client.NonRepeatableRequestException: Cannot > retry request with a non-repeatable request entity". Here is complete call > stack: > > Caused by: org.apache.solr.client.solrj.SolrServerException: IOException > occured when talking to server at: http://devel1.kios.sk:8280/solr > at > org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:439) > at > org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:221) > at > org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:105) > at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:121) > at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:106) > at > kinet.common.fulltext.FullTextQueueProcessor.processEntry(FullTextQueueProcessor.java:181) > ... 3 more > Caused by: org.apache.http.client.ClientProtocolException > at > org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:822) > at > org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:754) > at > org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:732) > at > org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:383) > ... 8 more > Caused by: org.apache.http.client.NonRepeatableRequestException: Cannot > retry request with a non-repeatable request entity. > at > org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:625) > at > org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:464) > at > org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820) > ... 11 more > > Has someone succeeded with basic authentication in combination with the > HttpSolrServer? > > Thanks, Viliam > > > > -- > View this message in context: > http://lucene.472066.n3.nabble.com/HTTP-Basic-Authentication-with-HttpSolrServer-tp3999829.html > Sent from the Solr - User mailing list archive at Nabble.com.