apache-commons-httpclient

Timeout between request retries Apache HttpClient

僤鯓⒐⒋嵵緔 提交于 2019-12-06 07:20:15
问题 Could somebody share how to configure modern HttpClient 4.5.3 to retry failed requests and wait for some time before each retry? So far it looks like I got it correctly that .setRetryHandler(new DefaultHttpRequestRetryHandler(X, false)) will allow to retry requests X times. But I cannot understand how to configure backoff: .setConnectionBackoffStrategy() / .setBackoffManager() according to JavaDocs regulate something else, not timeout between retries. 回答1: About the dynamic delay, I want to

outbound-gateway with Basic Authentication in spring-integration

喜夏-厌秋 提交于 2019-12-06 05:58:52
With spring-integration I would like to call an outbound-gateway with an Basic Authentication. I have something like this : <int-http:inbound-gateway id="versionRequestGateway" supported-methods="POST" request-channel="requestVersionChannel" reply-channel="requestTransformerVersionChannel" path="/consultersite" reply-timeout="10000" request-payload-type="java.lang.String"> </int-http:inbound-gateway> <int-http:outbound-gateway order="1" request-channel="requestVersionChannel" url-expression="@urlExpressionGateway.getUrlFor(payload) + '/consultersite'" reply-channel="responseVersionChannel"

Why is this simple SOAP client not working (org.apache.http)?

社会主义新天地 提交于 2019-12-06 05:47:58
问题 I want to send an XML file as a request to a SOAP server. Here is the code I have: (modified from Sending HTTP Post request with SOAP action using org.apache.http ) import org.apache.http.client.*; import org.apache.http.client.methods.*; import org.apache.http.impl.client.*; import org.apache.http.entity.StringEntity; import org.apache.http.protocol.HTTP; import org.apache.http.HttpResponse; import java.net.URI; public static void req() { try { HttpClient httpclient = new DefaultHttpClient()

Migrate from Commons HttpClient to HttpComponents Client

元气小坏坏 提交于 2019-12-06 03:52:38
I would like to migrate from Commons HttpClient (3.x) to HttpComponents Client (4.x) but having difficulty how to handle redirects. The code works properly under Commons HttpClient but breaks when migrated to HttpComponents Client. Some of the links get undesirable redirects but when I set "http.protocol.handle-redirects" to 'false' a large number links stop working altogether. Commons HttpClient 3.x: private static HttpClient httpClient = null; private static MultiThreadedHttpConnectionManager connectionManager = null; private static final long MAX_CONNECTION_IDLE_TIME = 60000; //

Converting from HttpClient 3 to 4

倖福魔咒の 提交于 2019-12-05 19:54:06
问题 I've managed to make changes to everything but the following: HttpClient client; HttpPost method; client = new DefaultHttpClient(); method = new HttpPost(url); InputStream rstream; try { rstream = method.getResponseBodyAsStream(); } catch (IOException e) { return BadSpot(e.getMessage()); } What I'm not sure of is what I should replace getResponseBodyAsStream() with. 回答1: InputStream rstream; try { HttpResponse response = client.execute(HttpHost, method); rstream = response.getEntity()

Get the final URL of a redirected request with unconventional scheme

不羁的心 提交于 2019-12-05 16:09:37
My code (below) tries to get the final URL returned from a server that does a bit of redirecting. It works fine as long as the URLs have an http scheme. My problem arises when I want to return a URL with a different scheme. Ultimately I want, in some situations, to return a market:// url or other app launch schemes since this is for Android and I want to start Intents with them. So this gets me as far as retrieving the final http url, but when the final url is market:// it throws the exception seen (java.lang.IllegalStateException: Scheme 'market' not registered), and then getURI doesn't

HttpRoutePlanner - How does it work with an HTTPS Proxy

て烟熏妆下的殇ゞ 提交于 2019-12-05 12:24:19
I have an HTTPS proxy set up so that HTTP clients can send plain HTTP requests securely to the proxy. For example, a client can send an encrypted HTTP GET request to the proxy, which will remove the encryption and send the plain HTTP GET request to the end-site. I learned that this is not a common set up and only Google Chrome has in-built features to support such a scenario. (Info here - http://wiki.squid-cache.org/Features/HTTPS#Encrypted_browser-Squid_connection ). I have made Google Chrome work with my HTTPS proxy and hence there is no trouble on the proxy side. I wish to write an HTTP

Downsampling audio from 44.1kHz to 16kHz in Java

喜夏-厌秋 提交于 2019-12-05 10:57:33
I have an application that records a speech sample from the user's microphone and uploads it to a server which then does some stuff with it. It seems I must record with the following parameters to avoid an IllegalArgumentException : Encoding encoding = AudioFormat.Encoding.PCM_SIGNED; float sampleRate = 44100.0F; int sampleSizeInBits = 16; int channels = 2; int frameSize = 4; float frameRate = 44100.0F; boolean bigEndian = false; But I need to have it recorded at 16khz, not 44.1, (sampleRate and framerate both, I assume) and it must be in mono (1 channel). The PCM signed is also mandatory, so

HttpClient 4.2, Basic Authentication, and AuthScope

心不动则不痛 提交于 2019-12-05 09:10:55
I have an application connecting to sites that require basic authentication. The sites are provided at run time and not known at compile time. I am using HttpClient 4.2. I am not sure if the code below is how I am supposed to specify basic authentication, but the documentation would suggest it is. However, I don't know what to pass in the constructor of AuthScope . I had thought that a null parameter meant that the credentials supplied should be used for all URLs, but it throws a NullPointerException , so clearly I am wrong. m_client = new DefaultHttpClient(); UsernamePasswordCredentials

Apache HTTP Client Android Exception on Execute only for LG G3 6.0

雨燕双飞 提交于 2019-12-05 05:12:06
问题 I've taken over an android app that takes pictures and attaches them to jobs for a larger software system at a company's home base- it has worked fine until recently. It seems that only on LG G3 phones that have upgraded to Android 6.0 there is an exception in this prodecure: public static String frapiGetRequest(String transaction, ArrayList<Content> parameters) { StringBuilder builder = new StringBuilder(); DefaultHttpClient client = new DefaultHttpClient(); HttpHost targetHost = new