Hi Kenny, I think you're in for a world of hurt. :) The main reason I say this is because Java doesn't provide any method to determine if a connection is still open (even the 1.4 method isOpen doesn't work if the remote server closes the connection due to time out). The isAlive() method in HttpConnection suffers the same problem.
Now, if apache requests that the connection is closed immediately, it will return a "Connection: close" header which you can retrieve via the getResponseHeader method on the HttpMethod you executed. You might also run into a Proxy-Connection: close header. Take a look at the source for the HttpMethodBase.shouldCloseConnection() method to be sure you get all the possible conditions (I'd be tempted to either just copy the method and tweak it a little or extend whichever actual HttpMethod implementation your using to make it public). The above solution is rather hackish, but should get you going anyway. Regards, Adrian Sutton, Software Engineer Ephox Corporation www.ephox.com -----Original Message----- From: Kenny Smith [mailto:[EMAIL PROTECTED] Sent: Tuesday, 25 March 2003 5:13 AM To: [EMAIL PROTECTED] Subject: [httpclient] How to determine if connection is alive? Hello, I'm currently using 2.0a1 (I can't upgrade to the current release yet for production reasons) and I'm using Keep-Alive connections. I would like to find out if my connection is still alive, but I can't find any way to determine that. I've found the isAlive() method in HttpConnection object, but I can't find anyway to get an instance of the HttpConnection object. My overall goal: We are testing an application where apache will have Keep-Alives turned off. My testing app will use HttpClient to try to create a Keep-Alive connection and hold it open as long as possible. In the previous version, the thread making the request would just sleep for x number of seconds, but I want the code to move ahead and make the next request if apache forces the connection closed (i.e. correctly stops the Keep-Alive) so simply sleeping x number of seconds blindly doesn't work for me. Any help is appreciated, thanks! Kenny Smith --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
