apache-commons-httpclient

commons http client - kerberos token while negotiating has \r\n (carriage return line feed) characters

柔情痞子 提交于 2020-01-04 11:09:04
问题 I am trying to use jakarta commons http client. Doing kerberos authentication to communicate with a server. Authentication always fails. On digging deeper I found out that the kerberos token header has carriage return line feed characters in it which is the root cause of the issue. Why does it have \r\n characters and why is that an issue? 回答1: \r\n characters in the kerberos token is an issue because \r is an HTTP control characters. That essentially means that the server only sees first

Apache HttpClient random delays under high requests/second

夙愿已清 提交于 2020-01-02 06:41:33
问题 I'm using Apache HttpClient to query HTTP/1.0 (without keep alive) server on localhost with around 20 POST requests/second. I have a TCP_NODELAY enabled like this: val httpParams = new BasicHttpParams() HttpConnectionParams.setTcpNoDelay(httpParams, true) val client = new DefaultHttpClient(connectionManager, httpParams) Despite that, several times per minute I see a random delay of 10-200 milliseconds for sending such request (measuring on the server shows, that delay is in sending). I

How do I upgrade from DefaultHttpClient() to HttpClientBuilder.create().build()?

烈酒焚心 提交于 2019-12-25 03:07:34
问题 I have a routine which checks if a record has been indexed by Solr. I have a deprecated method of creating a HTTPClient which I'm trying to remove: From DefaultHttpClient httpClient = new DefaultHttpClient(); To CloseableHttpClient httpClient = HttpClientBuilder.create().build(); The problem I now have is that after 2 call to the URL, the 3rd attempt seems to hang. I'm not quite sure what I'm missing if anyone can help please? This is my complete method which I've extracted out into a test:

AIX: IBM Java: java.net.SocketException: Connection timed out:could be due to invalid address

孤街醉人 提交于 2019-12-23 15:25:48
问题 We have seen the following exceptions very frequently on IBM AIX when attempting to make an SSL connection to our server: java.net.SocketException: Socket closed at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275(Compiled Code)) at com.sun.net.ssl.internal.ssl.AppOutputStream.write(DashoA6275(Compiled Code)) at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java(Inlined Compiled Code)) at java.io.BufferedOutputStream.flush(BufferedOutputStream.java(Compiled Code)) at

How to send XML POST request using Apache HttpClient?

我的梦境 提交于 2019-12-23 15:25:21
问题 I want to do a HTTP POST of the format as follows, <?xml version="1.0" encoding="UTF-8" ?> <authRequest> <username>someusernamehere</username> <password>somepasswordhere</password> </authRequest> I usually work with the following mechanism for any login based POST, HttpParams params = new BasicHttpParams(); params.setParameter( "http.useragent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6"); DefaultHttpClient httpclient = new DefaultHttpClient(params)

Cannot process url with vertical/pipe bar in Java/Apache HttpClient

最后都变了- 提交于 2019-12-23 07:39:15
问题 If I want to process this url for example: post = new HttpPost("http://testurl.com/lists/lprocess?action=LoadList|401814|1"); Java/Apache won't let me because it says that the vertical bar ("|") is illegal. escaping it with double slashes doesn't work as well: post = new HttpPost("http://testurl.com/lists/lprocess?action=LoadList\\|401814\\|1"); ^ that doesn't work as well. Any suggestions how to make this work? 回答1: try with URLEncoder.encode() Note: you should encode string which is after

JAVA: How to create http url connection selecting the ip address to use

旧城冷巷雨未停 提交于 2019-12-22 17:28:22
问题 I have a pool of public ip addresses configured on my multiple NICs. In my JAVA project, which runs on a LINUX machine, I need to select a specific ip address from the pool and create an HttpURLConnecion using that ip. Further, I will cycle on the pool, using each time a different ip. At the current stage, I was not able to find a solution using the java.net library. I have rather looked at the HttpClient from Apache. At the following link, http://hc.apache.org/httpcomponents-client-ga

HttpClient 4.2, Basic Authentication, and AuthScope

人盡茶涼 提交于 2019-12-22 05:17:35
问题 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

Fixing HttpClient warning “Invalid expires attribute” using fluent API

て烟熏妆下的殇ゞ 提交于 2019-12-20 10:17:54
问题 I'm using the fluent API of HttpClient to make a GET request: String jsonResult = Request.Get(requestUrl) .connectTimeout(2000) .socketTimeout(2000) .execute().returnContent().asString(); But for each request I get the following warning: apr 07, 2016 12:26:46 PM org.apache.http.client.protocol.ResponseProcessCookies processCookies WARNING: Invalid cookie header: "Set-Cookie: WMF-Last-Access=07-Apr-2016;Path=/;HttpOnly;Expires=Mon, 09 May 2016 00:00:00 GMT". Invalid 'expires' attribute: Mon,

Set response encoding with HttpClient 3.1

穿精又带淫゛_ 提交于 2019-12-19 09:47:06
问题 I'm using org.apache.commons.httpclient.HttpClient and need to setup response encoding (for some reason server returns incorrect encoding in Content-Type). My way is to get response as raw bytes and convert to String with desired encoding. I'm wondering if there is some better way to do this (eg. setup HttpClient). Thanks for suggestions. 回答1: I don't think there's a better answer using HttpClient 3.x APIs. The HTTP 1.1 spec says clearly that a client "must" respect the character set