apache-httpclient-4.x

java filechannel cpu usage growing with time

笑着哭i 提交于 2019-12-02 14:31:05
问题 I am using java nio filechannel transferFrom function along with Apache httpclient to download files from internet. Its starts normally but cpu usage suddenly grows after some time. And download speed decreases and eventually becomes zero. try (CloseableHttpResponse response = client.execute(get); ReadableByteChannel inputChannel = Channels.newChannel( response.getEntity().getContent())) { while (start < end && currentState.get() == 1) { delta = fileChannel.transferFrom(inputChannel, start,

How to send parallel GET requests and wait for result responses?

陌路散爱 提交于 2019-12-02 14:19:19
I'm using apache http client within spring mvc 3.2.2 to send 5 get requests synchronously as illustrated. How can I send all of these asynchronously (in parallel) and wait for the requests to return in order to return a parsed payload string from all GET requests? public String myMVCControllerGETdataMethod() { // Send 1st request HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet("http://api/data?type=1"); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody = httpclient.execute(httpget, responseHandler); // Send 2st request

Solrj to index document from Android

孤者浪人 提交于 2019-12-02 13:07:20
问题 I'm trying to index document using Solrj from my android application, but it seems to not work. I following this LINK This is the code I'm writing: package com.example.secondapp; import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Intent; import android.content.IntentSender; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.Environment; import android.view.View; import android.widget.Button;

binding network interface to Apache httpclient

戏子无情 提交于 2019-12-02 11:37:17
问题 I am using Apache HttpClient on a machine which has two network cards. I can not find how I can bind HttpClient to use one of the NICs only. I have found some solutions but they are all depreciated now. I am using Apache HttpClient 4.5.2 Are there any examples that use GET/POST requests while using NIC binding? 回答1: Arya , you will have to get the list of network interfaces and use the RequestBuilder interfaces to get this accomplished. The following will give you a rough cut idea. import

The API package 'remote_socket' or call 'Resolve()' was not found - GAE Java

为君一笑 提交于 2019-12-02 09:21:43
I'm trying to call a Google Service in a GAE application hosted in GAE cloud: private String doPost(String URL) throws ClientProtocolException, IOException { // Params: List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("accountType", "HOSTED_OR_GOOGLE")); params.add(new BasicNameValuePair("Email", _DEFAULT_USER)); params.add(new BasicNameValuePair("Passwd", _DEFAULT_PASS)); params.add(new BasicNameValuePair("service", "ah")); // Call HttpClient httpClient = new DefaultHttpClient(); HttpPost post = new HttpPost(URL); // URL: // https://www.google.com

SonarQube How to login with the Web API

耗尽温柔 提交于 2019-12-02 07:22:17
问题 I'm writing a web application that can display code smell result from the Sonarqube, but I also want it can create custom rules sometimes. Currently, I'm able to get the data from the server using HTTPClient in Java or XMLHttpRequest in Js. However, I'm really stuck on POST message to the server. In Js , I've tried these code to log in: (the CORS has been disabled in my chrome) request.open("POST", "http://localhost:9000/api/authentication/login?login=admin&password=admin", true); request

binding network interface to Apache httpclient

心不动则不痛 提交于 2019-12-02 07:14:53
I am using Apache HttpClient on a machine which has two network cards. I can not find how I can bind HttpClient to use one of the NICs only. I have found some solutions but they are all depreciated now. I am using Apache HttpClient 4.5.2 Are there any examples that use GET/POST requests while using NIC binding? Ramachandran.A.G Arya , you will have to get the list of network interfaces and use the RequestBuilder interfaces to get this accomplished. The following will give you a rough cut idea. import java.net.InetAddress; import java.net.NetworkInterface; import java.util.Enumeration; import

Java HTTPPost Request with Apache HttpClient

眉间皱痕 提交于 2019-12-02 03:59:51
问题 I need a java program to generate the following request. I am using Apache HttpClient Library but still not able to produce a request like this: This is what my python program generates and i wrote an equivalent java program. but its throwing 403. 2012-09-10 15:12:05G INFO: G2OAuth auth data = "3, 0.0.0.0, 0.0.0.0, 1347289925, 3223833979, crlakamai" 2012-09-10 15:12:05G INFO: G2OAuth sign string = "3, 0.0.0.0, 0.0.0.0, 1347289925, 3223833979, akamai/182228\nx-akamai-acs-action:version=1

What Java properties to pass to a Java app to authenticate with a http proxy

余生长醉 提交于 2019-12-01 19:23:27
I have a Java application that is trying to access a web service via http proxy. The Java app is 3rd party app for which we don't have access to source code. Its launch can be configured by passing Java launch parameters among other things. I am wondering what are the java properties that one can pass so that the app can use the logged in user's NTLM credentials to authenticate proxy connections? When I passed https.proxyHost and https.proxyPort (i.e. -Dhttps.proxyHost=abcd ... to jvm command line), I do see difference in the logs. Now it fails with message below. [WrapperSimpleAppMain]

Using Selenium RemoteWebDriver behind corporate proxy (Java)

纵然是瞬间 提交于 2019-12-01 18:57:03
问题 I'm trying to run Selenium tests on a few remote automation services (Sauce Labs, Browserstack, etc) and run into issues hitting their API through my corporate firewall. Just a note, the app I'm trying to test is not behind this firewall, it is publicly accessible. DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); caps.setCapability("platform", "Windows 7"); caps.setCapability("version", "9.0"); caps.setCapability("idleTimeout", "300"); caps.setCapability("name", "Invitation