apache-httpclient-4.x

Can JCIFS be used with Jersey?

流过昼夜 提交于 2019-12-11 05:28:14
问题 I have trouble adding NTLM authentication to my existing application that uses Jersey and Apache HttpClient. I was only able to authenticate using JCIFS, the default NTLM authentication from HttpClient does not work (I get 401 ). The example from Apache HttpClient page shows how to use CloseableHttpClient: https://hc.apache.org/httpcomponents-client-4.5.x/ntlm.html Registry<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create() .register(AuthSchemes.NTLM, new

Every second request using Apache HTTPClient fails

隐身守侯 提交于 2019-12-11 03:35:15
问题 I am trying to use Apache HTTPClient 4.5.1 to do some rest requests. Unfortunately every second request ends up in "java.net.SocketTimeoutException: Read timed out" (or hangs forever if the socket timeout is not set). I am building my client like this: ConnectionSocketFactory sf = new PlainConnectionSocketFactory(); Registry<ConnectionSocketFactory> r = RegistryBuilder.<ConnectionSocketFactory> create() .register("http", sf) .build(); Lookup<AuthSchemeProvider> authProviders = RegistryBuilder

How to use AWSRequestSigningApacheInterceptor with AWS SDK2

扶醉桌前 提交于 2019-12-11 03:09:20
问题 I am trying to use REST calls to Neptune SPARQL on existing Java code which already uses Apache HTTP clients. I'd like to not mix and match AWS SDK1 and SDK2 (which I use for the S3 portion of loading owl to Neptune). I see these solutions: AWSRequestSigningApacheInterceptor that works with SDK1, but can't find the equivalent in SDK2. aws-request-signing-apache-interceptor on github for building an adaptor class so it can be used in SDK 2 with mix-and-match SDK 1 & 2 javaquery/Examples where

Spring Rest template with http client for NTLM authentication

拥有回忆 提交于 2019-12-11 02:38:32
问题 We have a web service deployed in IIS server which authenticate based on NTLM authentication. When i try to access the web service by passing username and password in httpCleint UserNamePasswordCredentials, am getting warnings as NTLM authentication error: Credentials cannot be used for NTLM authentication: org.apache.http.auth.UsernamePasswordCredentials Please clarify how to user http client with spring rest template to pass the NTLM authentication with user name and password. Note:Though

Httpclient doesn't correctly caches responses

对着背影说爱祢 提交于 2019-12-11 01:59:18
问题 I'm trying to use apache httpclient to load images with caching. After request the file is saved but after repeating same request it begins to download again and new file saved as cache. So cached images not reused. And not deleting. File names differ only by hash 1389449846612.0000000000000001-3f1e8b88.localhost.-images-goods-212250-7841874.jpg 1389449952782.0000000000000001-5720e341.localhost.-images-goods-212250-7841874.jpg I want, that image will be loaded once and be able to show cached

How to make batch http call in java

只谈情不闲聊 提交于 2019-12-11 00:21:33
问题 I am trying to access another service by Http to fetch data using HttpClient. The uri should look like endpoint:80/.../itemId. I am wondering if there is a way to make a batch call to specify a set of itemIds? I did find someone suggests to .setHeader(HttpHeaders.CONNECTION, "keep-alive") when creating request. Via doing this, how could I release the client after getting all data? Also, seems like this method still need to get one response then send another request? Is this possible to do it

Why does Apache CloseableHttpResponse not consume the entity on close?

梦想与她 提交于 2019-12-10 23:19:31
问题 Looking at the quick start guide it gives the following code example: CloseableHttpClient httpclient = HttpClients.createDefault(); HttpGet httpGet = new HttpGet("http://targethost/homepage"); CloseableHttpResponse response1 = httpclient.execute(httpGet); // The underlying HTTP connection is still held by the response object // to allow the response content to be streamed directly from the network socket. // In order to ensure correct deallocation of system resources // the user MUST call

Java Apache HttpClient error uploading files

浪尽此生 提交于 2019-12-10 20:09:59
问题 I want to upload a file using HttpClient 4.3.1. I need to add to form multipart an inputstream (to control upload progress.) instead of a File object. This is my code: byte[] dump = ...; HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(SENDLOG_URL); MultipartEntityBuilder meb = MultipartEntityBuilder.create(); meb.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); // THIS WORKS!! meb.addBinaryBody("log", new File("C:\\temp.zip"), ContentType.APPLICATION_OCTET

How to use Elasticsearch Rest api in java?

十年热恋 提交于 2019-12-10 17:41:04
问题 I am using Apache Http client for making use of ElasticSearch Rest Api, but I am always getting HTTP error code as 200. Please help Java code import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.util.Scanner; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client

Java's XML DocumentBuilder fails with parse time out?

那年仲夏 提交于 2019-12-10 17:34:44
问题 I have what I would think was a typical use case. I am using Apache HttpClient to make a POST to a remote (internal) server. The response from the server is XML. I get the response from the entity as a stream and parse it directly to an XML Document. This code snippet shows what I am doing. HttpResponse response = httpClient.execute(request); int code = response.getStatusLine().getStatusCode(); if(code != 200) { returnValue.addParameter("msg", "Recieved invalid status code '" + code + "'"); }