Example usage for org.apache.http.params HttpProtocolParams setUseExpectContinue

List of usage examples for org.apache.http.params HttpProtocolParams setUseExpectContinue

Introduction

In this page you can find the example usage for org.apache.http.params HttpProtocolParams setUseExpectContinue.

Prototype

public static void setUseExpectContinue(HttpParams httpParams, boolean z) 

Source Link

Usage

From source file:com.devoteam.srit.xmlloader.http.test.HttpLoaderClient.java

public void run() {

    Long beginThreadResponse = System.currentTimeMillis(); // top chrono des reponses
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setHttpElementCharset(params, "UTF-8");
    HttpProtocolParams.setContentCharset(params, "text");
    HttpProtocolParams.setUserAgent(params, "XmlLoader");
    HttpProtocolParams.setUseExpectContinue(params, true);

    try {/*w  w  w . j a  va  2s  .  c  o  m*/
        http.receiveResponse("GET", "D:/XMLloader/testPileHttp/src/test/HttpLoader/", params, 5000000);
        Long endThreadResponse = System.currentTimeMillis();
        timeThreadResponse = endThreadResponse - beginThreadResponse; // calcul de la dure du processus de reception des msg
        Long totalTime = timeThreadRequest + timeThreadResponse; // calcul de la dure du programme
        System.out.println("transaction number : " + 5000000 * 2);
        System.out.println("All transaction time : " + (long) totalTime / 1000 + " s"
        /* + "trans/ms: "+(float)totalTime/50*/);
        System.out.println("number transaction /s: " + (float) (5000000 * 2) / (totalTime / 1000));
    } catch (IOException e) {
        System.out.println("connection error");
    } catch (HttpException e) {
    }
}

From source file:org.openiot.gsn.http.rest.RestRemoteWrapper.java

private HttpParams getHttpClientParams(int timeout) {
    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
    HttpProtocolParams.setUseExpectContinue(params, true);
    HttpConnectionParams.setTcpNoDelay(params, false);
    HttpConnectionParams.setSocketBufferSize(params, 8192);
    HttpConnectionParams.setStaleCheckingEnabled(params, true);
    HttpConnectionParams.setConnectionTimeout(params, 30 * 1000); // Set the connection time to 30s
    HttpConnectionParams.setSoTimeout(params, timeout);
    HttpProtocolParams.setUserAgent(params, "GSN-HTTP-CLIENT");
    return params;
}

From source file:com.cloudkick.CloudkickAPI.java

public CloudkickAPI(Context context) throws EmptyCredentialsException {
    prefs = PreferenceManager.getDefaultSharedPreferences(context);
    key = prefs.getString("editKey", "");
    secret = prefs.getString("editSecret", "");
    if (key == "" || secret == "") {
        throw new EmptyCredentialsException();
    }/*from   www  .  ja v a 2 s.  c o m*/

    HttpParams params = new BasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, HTTP.DEFAULT_CONTENT_CHARSET);
    HttpProtocolParams.setUseExpectContinue(params, true);

    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    registry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));

    ClientConnectionManager connman = new ThreadSafeClientConnManager(params, registry);
    client = new DefaultHttpClient(connman, params);
}

From source file:ch.cyberduck.core.dropbox.client.AbstractHttpDropboxClient.java

protected AbstractHttpDropboxClient(HttpClient client, String api_host, String content_host, String protocol,
        int port) {
    this.api_host = api_host;
    this.content_host = content_host;
    this.protocol = protocol;
    this.port = port;
    this.client = client;
    HttpParams params = this.client.getParams();
    HttpProtocolParams.setUseExpectContinue(params, false);
}

From source file:com.iia.giveastick.util.RestClient.java

/**
 * @param serviceName The serviceName should be the name of the Service
 *    you are going to be using.//from www. ja v  a  2 s  .c o  m
 */
public RestClient(String serviceName, int port, String scheme) {
    HttpParams myParams = new BasicHttpParams();

    // Set timeout
    myParams.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
    HttpConnectionParams.setConnectionTimeout(myParams, 30000);
    HttpConnectionParams.setSoTimeout(myParams, 20000);
    HttpProtocolParams.setUseExpectContinue(myParams, true);

    this.httpClient = new DefaultHttpClient(myParams);
    this.serviceName = serviceName;
    this.port = port;
    this.scheme = scheme;
}

From source file:com.prey.net.PreyRestHttpClient.java

private PreyRestHttpClient(Context ctx) {
    this.ctx = ctx;
    httpclient = new PreyDefaultHttpClient((DefaultHttpClient) HttpUtils.getNewHttpClient());
    httpclientDefault = new PreyDefaultHttpClient((DefaultHttpClient) HttpUtils.getNewHttpClient());

    HttpParams params = new BasicHttpParams();

    // Set the timeout in milliseconds until a connection is established.
    int timeoutConnection = 30000;
    HttpConnectionParams.setConnectionTimeout(params, timeoutConnection);

    // Set the default socket timeout (SO_TIMEOUT)
    // in milliseconds which is the timeout for waiting for data.
    int timeoutSocket = 50000;
    HttpConnectionParams.setSoTimeout(params, timeoutSocket);

    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, "UTF_8");
    HttpProtocolParams.setUseExpectContinue(params, false);
    HttpParams paramsDefault = params;//w  ww .j av a 2  s .  c  om
    httpclientDefault.setParams(paramsDefault);
    HttpProtocolParams.setUserAgent(params, getUserAgent());
    httpclient.setParams(params);
}

From source file:org.jupnp.transport.impl.apache.StreamClientImpl.java

public StreamClientImpl(StreamClientConfigurationImpl configuration) throws InitializationException {
    this.configuration = configuration;

    HttpProtocolParams.setContentCharset(globalParams, getConfiguration().getContentCharset());
    HttpProtocolParams.setUseExpectContinue(globalParams, false);

    // These are some safety settings, we should never run into these timeouts as we
    // do our own expiration checking
    HttpConnectionParams.setConnectionTimeout(globalParams,
            (getConfiguration().getTimeoutSeconds() + 5) * 1000);
    HttpConnectionParams.setSoTimeout(globalParams, (getConfiguration().getTimeoutSeconds() + 5) * 1000);

    HttpConnectionParams.setStaleCheckingEnabled(globalParams, getConfiguration().getStaleCheckingEnabled());
    if (getConfiguration().getSocketBufferSize() != -1)
        HttpConnectionParams.setSocketBufferSize(globalParams, getConfiguration().getSocketBufferSize());

    // Only register 80, not 443 and SSL
    SchemeRegistry registry = new SchemeRegistry();
    registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));

    clientConnectionManager = new PoolingClientConnectionManager(registry);
    clientConnectionManager.setMaxTotal(getConfiguration().getMaxTotalConnections());
    clientConnectionManager.setDefaultMaxPerRoute(getConfiguration().getMaxTotalPerRoute());

    httpClient = new DefaultHttpClient(clientConnectionManager, globalParams);
    if (getConfiguration().getRequestRetryCount() != -1) {
        httpClient.setHttpRequestRetryHandler(
                new DefaultHttpRequestRetryHandler(getConfiguration().getRequestRetryCount(), false));
    }//from   www .j  av a2 s . c o  m
}

From source file:com.k42b3.aletheia.protocol.http.HttpProtocol.java

public HttpProtocol() {
    // http settings
    params = new SyncBasicHttpParams();
    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, "UTF-8");
    HttpProtocolParams.setUseExpectContinue(params, true);

    HttpRequestInterceptor[] interceptors = { new RequestContent(true), new RequestTargetHost(),
            new RequestConnControl(), new RequestExpectContinue() };

    httpproc = new ImmutableHttpProcessor(interceptors);
    httpexecutor = new HttpRequestExecutor();
}

From source file:edu.htl3r.schoolplanner.backend.network.Network.java

public Network() {
    initSSLSocketFactories();//from w  w  w .  j  a  va  2  s. c  o m

    HttpParams params = new BasicHttpParams();

    // TODO: Timeouts sind statisch
    HttpConnectionParams.setConnectionTimeout(params, 20000);
    HttpConnectionParams.setSoTimeout(params, 10000);

    HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
    HttpProtocolParams.setUseExpectContinue(params, false);

    SchemeRegistry registry = new SchemeRegistry();

    ClientConnectionManager connman = new ThreadSafeClientConnManager(params, registry);

    client = new DefaultHttpClient(connman, params);
}

From source file:com.xorcode.andtweet.net.ConnectionOAuth.java

public ConnectionOAuth(SharedPreferences sp) {
    super(sp);/*from  w  w w.  j  a va2  s . co m*/

    HttpParams parameters = new BasicHttpParams();
    HttpProtocolParams.setVersion(parameters, HttpVersion.HTTP_1_1);
    HttpProtocolParams.setContentCharset(parameters, HTTP.DEFAULT_CONTENT_CHARSET);
    HttpProtocolParams.setUseExpectContinue(parameters, false);
    HttpConnectionParams.setTcpNoDelay(parameters, true);
    HttpConnectionParams.setSocketBufferSize(parameters, 8192);

    SchemeRegistry schReg = new SchemeRegistry();
    schReg.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
    ClientConnectionManager tsccm = new ThreadSafeClientConnManager(parameters, schReg);
    mClient = new DefaultHttpClient(tsccm, parameters);

    mConsumer = new CommonsHttpOAuthConsumer(OAuthKeys.TWITTER_CONSUMER_KEY, OAuthKeys.TWITTER_CONSUMER_SECRET);
    loadSavedKeys(sp);
}