commons-httpclient

How to force disconnection in commons-httpclient ?

Hi, I use commons-httpclient to send queries to a Web server. The Web server never closes connections, but has a small memory leak associated to the connection context. I would therefore like to close the persistent connections from time to time (every X queries for example), but I did not find any way to do this. I use the MultiThread...

Is it possible to assign a proxy for each thread in Jakarta Common's HTTPClient?

I want to have multiple threads, each using a different proxy for Jakarta Common's HTTPClient. Last time I check, it was only possible to set one global/static proxy for this API. Does anyone how to accomplish the prior stated goal? ...

How can I reuse a HttpClient connection efficiently?

I am doing HTTP POSTs very frequently (>= 1/sec) to an API endpoint and I want to make sure I'm doing it efficiently. My goal is to succeed or fail as soon as possible, especially since I have separate code to retry failed POSTs. There is a nice page of HttpClient performance tips, but I'm not sure if exhaustively implementing them all w...

Apache HttpClient making multipart form post

I'm pretty green to HttpClient and I'm finding the lack of (and or blatantly incorrect) documentation extremely frustrating. I'm trying to implement the following post (listed below) with Apache Http Client, but have no idea how to actually do it. I'm going to bury myself in documentation for the next week, but perhaps more experienced...

apache HttpClient make connection for url1 ,if url1 failed connect url2

Hi using apache HttpClinet i have to connect to two different URLs based on conditions. we have given two urls URL1 and URl2. initially i have to connect to URL1 .if it fails due to communication errors retry for 3 times,then also it failed Now connect to URL2 and repeat the same process.finally if URL2 also fails.read from database....

posting nutch data into a BASIC auth secured Solr instance

Hi. I've secured a solr instance using BASIC auth, kind of how it is shown here: http://blog.comtaste.com/2009/02/securing_your_solr_server_on_t.html Now i'm trying to update my batch processes to push data into the authenticated instance. The ones using "curl" are easy, but i also have a Nutch crawl that uses the "solrindex" command to...

Writing HttpEntity to file

I'm trying to use the jakarta commons HttpClient library. I think I'm being dumb here, but I can't figure out how to write a complete HttpEntity to file. I'm trying: FileOutputStream os = new FileOutputStream(f); e.writeTo(os); while (e.isStreaming()) { e.writeTo(os); } Where e is my HttpEntity and f is my file. I only get the f...

Why do I get empty request from the Jakarta Commons HttpClient?

I have a problem with the Jakarta Commons HttpClient. Before my self-written HttpServer gets the real request there is one request which is completely empty. That's the first problem. The first problem is solved. It was caused by an unnecessary URLConnection! The second problem is, sometimes the request data ends after the third or fourt...

Apache commons HTTPClient and log4j.xml

I'm using Apache commons HTTPClient with Apache Axis 1.5 and I'm trying to log the messages exchanged when making Web Service calls by enabling org.apache.commons.httpclient to DEBUG and httpclient.wire to DEBUG. However, this doesn't work. Mentioned below is my log4j.xml - can someone help me? Thanks <?xml version="1.0" encoding="UTF-8...

Authenticating a single request with httpclient 4.x

I have an HttpClient instance that's shared by a number of threads. I would like to use it to make a single authenticated request. Because only the single request should be authenticated, I don't want to modify the HttpClient instance as described in the documentation. Here's what I've worked out instead, which isn't working. From what ...

How to get Cookies using HttpClient

Hello I am using HttpClient to get Cookies but I am unable find any cookies.My Code is given below public class LoginTab { private Cookie[] cookies; HttpClient httpClient; HttpState httpState; HashMap postData; public LoginTab() { httpClient = new HttpClient(); httpState = new HttpState(); httpClient.getHttpConnectionManage...

Escaping ampersands in URLs for HttpClient requests

So I've got some Java code that uses Jakarta HttpClient like this: URI aURI = new URI( "http://host/index.php?title=" + title + "&action=edit" ); GetMethod aRequest = new GetMethod( aURI.getEscapedPathQuery()); The problem is that if title includes any ampersands (&), they're considered parameter delimiters and the request goes screwy...

HttpClient commons-httpclient Digest Authentication.

I am getting this error from a PostMethod using commons-httpclient No credentials available for DIGEST 'realm'@localhost and a 401 back from the server. I followed the example from this post java client program to send digest authentication request using HttpClient API (2) However, it still seems to fail. I am trying to connect to ...

Using HttpClient with SSL and certificates

While I've been familiar with HTTPS and the concept of SSL, I have recently begun some development and found I am a little confused. The requirement was that I write a small Java application that runs on a machine attached to a scanner. When a document is scanned this is picked up and the file (usually PDF) sent over the internet to our...

HttpProtocolParams.setUseExpectContinue(params, false) - when to set true?

I am using org.apache.http.impl.client.DefaultHttpClient to retrieve xml from a webservice and am trying to determine whether to set HttpProtocolParams.setUseExpectContinue(params, true) or HttpProtocolParams.setUseExpectContinue(params, false) I am not clear on how to determine this. Can anyone offer a best practices guideline...

httpURLConnection vs apache commons http

Hi everyone! I just wanted to know if any of you had any problems using java default HttpURLConnection class. Some kind of bug that made you switch to apache commons. Or is it just the (ugly) interface that class exposes that justifies the birth of 3rd party http lib? Disclosure: I heard some arguments against java.net having some ser...

Reading chunked data from HttpEntity

I have the following code: HttpClient FETCHER HttpResponse response = FETCHER.execute(host, httpMethod); Im trying to read its contents to a string like this: HttpEntity entity = response.getEntity(); InputStream st = entity.getContent(); StringWriter writer = new StringWriter(); IOUtils.copy(st, writer); String content = writer.toSt...

httponly cookie support in Apache HttpClient

Can anyone confirm if the latest release of Apache httpClient 4.0.1 or 4.1 alpha2 supports httpOnly cookie. (Did not find anything in the release notes but the source code validation for cookies does not raise exception when value is not existing?) Since the previous versions raise an exception on trying to parse HttpOnly stating that ...

BindException/Too many file open while using HttpClient under load

I have got 1000 dedicated Java threads where each thread polls a corresponding url every one second. public class Poller { public static Node poll(Node node) { GetMethod method = null; try { HttpClient client = new HttpClient(new SimpleHttpConnectionManager(true)); ...... } catc...

For a HttpGet method what are getParams()?

org.apache.http.client.methods.HttpGet; HttpGet method = new HttpGet(url.toExternalForm()); method.getParams() Whare are these params? Are they the query string? there seems to be no easy way to add a query string with org.apache.http.client.methods.HttpGet ...