0

I set the HttpParameters to a HttpClient.

Now i want to test whether they are set correctly. Actually i was doing it this way (based on this answer by kuester2000):

public class MyHttpClient extends DefaultHttpClient {

    public MyHttpClient(int tc, int ts) {

        HttpParams httpParameters = new BasicHttpParams();
        // Set the timeout in milliseconds until a connection is established.
        int timeoutConnection = tc;
        HttpConnectionParams.setConnectionTimeout(httpParameters, timeoutConnection);
        // Set the default socket timeout (SO_TIMEOUT) 
        // in milliseconds which is the timeout for waiting for data.
        int timeoutSocket = ts;
        HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
        ClientConnectionManager mgr = this.getConnectionManager();
        this.setParams(httpParameters);
    }
}

and creating an instance of it like this:

public static MyHttpClient httpclient = new MyHttpClient(5000, 5000);

How to know if this actually worked.

I tried this :

httpclient.getParams().toString();

and i got this as an output:

org.apache.http.params.BasicHttpParams@40520f20

seems like its the Default Params but not the one i set.

Ryan M
  • 18,333
  • 31
  • 67
  • 74
Archie.bpgc
  • 23,812
  • 38
  • 150
  • 226

2 Answers2

1

Use these line of code

HttpParams httpParameters = new BasicHttpParams();
    int timeoutConnection = 120000;
            HttpConnectionParams.getConnectionTimeout(httpParameters));
Naveen Kumar
  • 3,738
  • 4
  • 29
  • 50
  • I have already set the params. I just want to get the values i set. Something like "httpclient.getParams().getConnectionTimeout". – Archie.bpgc Sep 28 '12 at 07:37
1

I Used:

HttpParams params = new BasicHttpParams();
params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, false);
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, CONNECTION_TIMEOUT);
params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, CONNECTION_TIMEOUT);
params.setLongParameter(ConnManagerPNames.TIMEOUT, CONNECTION_TIMEOUT);
HttpClient httpClient = new DefaultHttpClient(params);
Casabian
  • 308
  • 2
  • 8
  • I have already set the params. I just want to get the values i set. Something like "httpclient.getParams().getConnectionTimeout". – Archie.bpgc Sep 28 '12 at 07:38
  • try httpClient.getParams().getIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, CONNECTION_TIMEOUT); – Casabian Sep 28 '12 at 08:53