Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

We have the following code to talk to our website, and we have timeout threshold set at the HttpClient level to make sure "we don't wait for long time for get response back.". Does the code good enough to satisfy the requirement above? Do we need additional timeout setting for the HttpHead method as well?

        HttpClient httpclient = new DefaultHttpClient();
        // the time it takes to open TCP connection.
        httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, this.timeout);

        // timeout when server does not send data.
        httpclient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, this.timeout);

        // the head method
        HttpHead httphead = new HttpHead(url);

        HttpResponse response = httpclient.execute(httphead);
share|improve this question
    
Have you read the JavaDoc for HttpClient, and the subsequent classes you mention? –  wulfgar.pro Dec 5 '12 at 2:08
    
yes, but I didn't get a clear clue. do u have any pointers that clearly answer the question? –  bcbishop Dec 5 '12 at 2:10
1  
I would think the timeout you provide to HttpClient is for the connection, and the timout you provide to HttpHead is for the request. You might need to test this in your Integration Tests. –  wulfgar.pro Dec 5 '12 at 2:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.