commons-httpclient

Apache HttpClient CoreConnectionPNames.CONNECTION_TIMEOUT does nothing ?

Hi, I get strange behavior from HttpClient with parameter CoreConnectionPNames.CONNECTION_TIMEOUT set to 1. I would expect that HttpGet request would fail, throwing connection timeout exception and yet they are successful. This seems irrational as it actually means that TCP handshake finished in less then 1 millisecond. The httpclient ...

HttpClient - setting a "global" socket timeout, and a separate timeout per request

With HttpClient, I am setting the default socket/connection timeout with the following: HttpParams params = new BasicHttpParams(); HttpConnectionParams.setSoTimeout(params, 30000); HttpConnectionParams.setConnectionTimeout(params, 30000); mClient = new DefaultHttpClient(connectionManager, params); I'm wondering if I can override the...

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

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 issu...

apache commons http client efficiency

I use apache commons http client to send data via post every second, is there a way to make the following code more efficient? I know http is stateless, but is there anything I can do to improve since the base url is always the same in this case(only the parameter value change. private void sendData(String s){ try { ...

Apache Http Client Problem?

Hello Friends, I am using apace http common for sending a request.When sending an http request a connection timeout occurs, the HttpClient.execute method throws a java.net.SocketException instead of a org.apache.http.conn.ConnectionTimeoutException. ava.net.ConnectException: Connection timed out: connect at java.net.PlainSocket...

Java problem using commons-httpclient-3.X.jar

Hi, I need to pass from commons-httpclient-3.0.jar to commons-httpclient-3.1.jar but changing the jar my code doesn't work any more. The problem is that the new library encode automatically the passed uri. Is there a way to avoid this? I must interact with Yahoo API and I mustn't encode the URI otherwise I can't access to the se...

Apache httpclient makes lots of connections

I'm using apache httpclient 4.0 to connect to a video stream (motion jpeg) over http. Here's my code: DefaultHttpClient client; HttpParams params = new BasicHttpParams(); List<String> authpref = new ArrayList<String>(); authpref.add(AuthPolicy.DIGEST); authpref.add(AuthPolicy.BASIC); params.setParameter("http.auth.proxy-scheme-pref",...

Why switch from HttpClient version 3 to 4

My Java application is developed using HttpClient 3. Is there any advantages of switching to version 4? Is there a changelog. article, blog entry or something that describes what's new? ...

unable to get response headers using apache httpclient 3.0.1

Hello, I have created a sample application in Java with sending POST request to a asp.net web page "mypage.aspx". This apsx page sending back some response and 1 headers to check its valid or not. Aspx page set headers like Response.AddHeader("my-source", "lmenaria.com"); In my Java program: Header[] headers = method.getResponseHe...

Help. Getting exception executing PostMethod.getStatusCode()!

Couldn't figure out why I'm getting Null pointer here : System.out.println(method.getStatusCode()); !? method initialized and successfully executed! Any ideas? Sample code here. I'm using commons-httpclient-3.1.jar PostMethod = new PostMethod(url); LogInHelper.logRequest(httpClient, method); try { ...

How to enable logging for apache commons HttpClient on Android

To enable logging for apache commons HttpClient in normal Java application I used: System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog"); System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true"); System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wir...

Producing entity content in Apache HttpClient 4

What is the difference between EntityTemplate and StringEntity Below is the code from the HttpClient Tutorial. Not sure I understand why you would do this verses using a StringEntity ContentProducer cp = new ContentProducer() { public void writeTo(OutputStream outstream) throws IOException { Writer writer = new OutputStrea...

Java HTTP Post Raw Data

Hi All, I'm looking to make an HTTP post request given the raw data that I have. I've spent a while looking for the solution, made a handful of attempts and I'm looking for a little bit of help. The PHP code for what I'm looking to do looks like this: <? $url="http://localhost:3000"; $postdata="<?xml version=\"1.0\" encoding=\"UTF-8\"?...

Using Java NIO for pipelined Http

Researching the web, I've found that pipelined Http is much faster and more power efficient (specially for mobile devices) than queued or parallel connections. The support from general libraries however seams to be small. Just recently has the widespread Apache HttpCore project gained support through its NIO module. At least it says so ...

Highest Performance for Apache HTTPClient HEAD Requests?

hi all, I'm using the apache commons 4.x HTTPClient to make HEAD requests to URIs only to get the final post 302 URL location of that link. E.g: http://bit.ly/test1231 really points to cnn.com or something. What would be the best and most efficient way using HttpClient to achieve this in a server that could run for months with out leaki...

HttpClient unable to 302 this link?

I found a URL that httpclient doesn't seem to be handling redirects on: http://news.google.com/news/url?sa=t&amp;fd=R&amp;usg=AFQjCNGrJk-F7Dmshmtze2yhifxRsv8sRg&amp;url=http://www.mtv.com/news/articles/1647243/20100907/story.jhtml should 302 to: http://www.mtv.com/news/articles/1647243/20100907/story.jhtml when I look at the headers i...

Display html page from another domain

Hi everyone, I have to display an html from another domain in my company's website. My company's website is behind a proxy and it is a secured site (https). The html page I want to display is not https. I tried iframe, but it is giving 'non-secure items' message. What is the best method to display an html page from another domain ...

Apache Commons Http Client - Registering a client specific Protocol

I'm working on a library that is meant to be integrated in other applications. I have to communicate with a https server, and I'm using apache commons HttpClient 3.1. I have my own keystore and need to register a Protocol via: Protocol.registerProtocol. I was wondering if there was a way to register this for my specific instance of th...

Configuring HttpClient in Spring using Basic Authentication

Hi all, I'm implementing a SOLR server in our application. We use the CommonsHttpSolrServer in the SolrJ package to connect to our solr server which uses the commons-httpclient. We also use Spring. Now our sysadmin secured the solr server (with good reason) and used Basic Auth. How can I instantiate a HttpClient with Basic Auth to be ...