httpclient

How to handle IOException and HttpException in Apache HttpClient.execute(HttpMethod)

The documentation (copied below) doesn't say a lot about what IOException and HttpException means in its context. My question is: after an IOException occurs in a HttpClient.execute(HttpMethod) method, do I have to discard the object and create a new HttpClient in order to execute methods again? Or is it still usable (the HttpClient ob...

Intermittently incomplete response using Apache HttpClient 3.0.1

I am stumped about this, so I thought I'd ask in case any of you have come across it, since HttpClient development is a little bit of an art. The problem I am facing is this: An application is using the Apache HttpClient Java library to communicate to a server in the same company network. Most of the time it works without a problem, bu...

Connection to a URL from within an applet using Apache's HttpClient vs using the JDK's URLConnection

In the following code, I have verified that connecting to a URL from within an applet preserves the browser's session if JDK's URLConnection class is used. However, this is not the case if Apache's HttpClient library is used. Does anyone know why? Alternatively, is there a way for me to set the connection instance to be used by an Htt...

Best Practice to Use HttpClient in Multithreaded Environment

Hi all, All the while, I am using HttpClient in multithreaded environment. For every threads, when they initiate a connection, they will create a complete new HttpClient instance. Recently, I discover, by using this approach, it can cause the user is having too many port being opened, and most of the connections are in TIME_WAIT state....

HttpClient ThreadSafeClientConnManager throws "Connection reset"

I define HttpClient in 2 different ways: 1. Plain vanilla: client = new DefaultHttpClient(); 2. Thread safe: DefaultHttpClient getThreadSafeHttpClient() { HttpParams params = new BasicHttpParams(); params .setParameter( "http.useragent", "Mozilla/5.0 (Linux; U; Android 1.1; en...

Troubleshooting SSLHandshakeExceptions with HttpClient 3.1

I'm using HttpClient 3.1 to talk to a remote server through a proxy via HTTPS and client certificate authentication. This has been working just fine for a couple of weeks now, until I started experiencing SSLHandshakeExceptions recently. I assume the root cause lies with the remote server (since I haven't changed a damn thing), but I n...

How can I configure HTTPClient to authenticate against a SOCKS proxy?

I need to set up proxy authentication against a SOCKS proxy. I found out this post giving instructions that appear to work with common HTTP proxies. httpclient.getHostConfiguration().setProxy("proxyserver.example.com", 8080); HttpState state = new HttpState(); state.setProxyCredentials(new AuthScope("proxyserver...

Really weird HTTP client using TcpClient in C#

I am implementing a really simple HTTP Client that just connects to a web server and gets it's default homepage. Here it is and it works nice: using System; using System.Net.Sockets; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { TcpClient tc = new TcpClient(); ...

how to login to a website through java?

I have tried several ways to login to a website through java. I have used watij, HTMLunit etc. but due to not so familiar with any of these, I am not able to login successfully. Can anyone tell me in detail how to login through java To be more specific, I want to login to the ORKUT and want the pagesource of the page that comes after l...

Access to Facebook API using REST and HttpClient

Hello there, I am going to use RESTful Web Services and HttpClient to access Facebook API REST Server. Am somewhat of a newbie to REST and Facebook APIs... Question(s): Verification / Authorization (1) If I have a session key sent by a client app, how do I verify and authenticate that the user exists and then query for his / her fri...

Facebook: Getting Incorrect Signature (104) when Getting Session Key

Hello there, I am trying to use the HttpClient library (in order to call the Facebook API's REST end points) to obtain a session key and verify user... My code is here: RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath*:**/*applicationContext-test.xml" }) public class FacebookUserTest { final St...

How do I count the number of 100 Continues the server sent me?

I am using Apache Commons HttpClient 3.1, and I found that HttpURLConnection from Sun drops the 100 Continues from the stream. So therefore I don't seem able to get the 100 Continue as they are apparently dropped by Sun's code. I am unable to move forward to HttpClient 4.0 as that would require many changes to already existing code so ...

How to get html source of a webpage?

I am using org.apache.http.impl.client.DefaultHttpClient to login to websites through java. How can I get the html source of the webpage after having logged in to a website. ...

How to login to a website?

I want to login to the ORKUT through a java program. I am using the following program to do it. I have copied it from some website. Now I want to use it for ORKUT. But I have some questions regarding some lines. Q1. Where to give the URL of the login page (I think in the new HTTPGET("....."))? Am I right or not? Q2. What argument to pa...

HttpClient 4 - how to capture last redirect URL

I have rather simple HttpClient 4 code that calls HttpGet to get HTML output. The HTML returns with scripts and image locations all set to local (e.g. <img src="/images/foo.jpg"/>) so I need calling URL to make these into absolute (<img src="http://foo.com/images/foo.jpg"/&gt;) Now comes the problem - during the call there may be one or ...

Help using Facebook REST API - Notifications.send using HttpClient (Java)

Hello there, I am using the session proxy method to login to Facebook using Facebook Connect (via my iPhone simulator) and obtain my session key. Am using server side Java to send the notification, however. What I am trying to do is just send a user to user notification back to myself (that's why I set the to_uids as an empty string). I...

Java: Automatic cookie handling in HttpClient?

In Java HttpClient feature list it says: Automatic Cookie handling for reading Set-Cookie: headers from the server and sending them back out in a Cookie: header when appropriate. But I can't figure out how to use this feature. I just need to open a web page, let it set all the cookies, then refresh the same page with received...

Connection to same URL in different threads using HttpClient

What is the correct method to get the content of an URL in multiple threads using HttpClient in java? For example loading a List with items, loading each item in a different thread at the same time and getting the information from the same URL with different parameters. In a application I am creating it gives me no element found except...

How to prevent apache http client from following a redirect

I'm connecting to a remote server with apache http client. the remote server sends a redirect, and i want to achieve that my client isn't following the redirect automatically so that i can extract the propper header and do whatever i want with the target. i'm looking for a simple working code sample (copy paste) that stops the automatic...

Cancel/abort a connection from the ThreadSafeClientConnManager connection pool

I'm using ThreadSafeClientConnManager to manage a pool of client connections, because my application has several threads, which are simultaneously connecting to a webserver. Abstract sample code: HttpClient httpClient; ClientConnectionManager conMgr = new ThreadSafeClientConnManager(parameters,schReg); httpclient = new DefaultHttpClie...