Example usage for org.apache.http.protocol BasicHttpContext BasicHttpContext

List of usage examples for org.apache.http.protocol BasicHttpContext BasicHttpContext

Introduction

In this page you can find the example usage for org.apache.http.protocol BasicHttpContext BasicHttpContext.

Prototype

public BasicHttpContext() 

Source Link

Usage

From source file:com.navercorp.pinpoint.plugin.httpclient4.HttpClient4PluginTest.java

@Test
public void addDefaultHttpRequestRetryHandlerClass() {
    DefaultHttpRequestRetryHandler retryHandler = new DefaultHttpRequestRetryHandler();
    IOException iOException = new IOException();
    HttpContext context = new BasicHttpContext();

    assertTrue(retryHandler.retryRequest(iOException, 1, context));
    assertTrue(retryHandler.retryRequest(iOException, 2, context));
}

From source file:com.squeezeday.marknadskoll.HttpHelper.java

public static String get(String url) throws IOException, HttpException {
    HttpGet request = new HttpGet(url);
    return doRequest(request, url, new BasicHttpContext(), true);
}

From source file:com.jayway.restassured.internal.http.HttpContextDecorator.java

public HttpContextDecorator() {
    this.delegate = new BasicHttpContext();
}

From source file:com.baidu.oped.apm.profiler.modifier.connector.httpclient4.DefaultHttpRequestRetryHandlerModifierTest.java

@Test
public void test() {
    DefaultHttpRequestRetryHandler retryHandler = new DefaultHttpRequestRetryHandler();
    IOException iOException = new IOException();
    HttpContext context = new BasicHttpContext();

    assertTrue(retryHandler.retryRequest(iOException, 1, context));
    assertTrue(retryHandler.retryRequest(iOException, 2, context));
    assertEquals(2, getCurrentSpanEvents().size());
}

From source file:com.electronicpanopticon.spring.web.rest.StatefullRestTemplate.java

public StatefullRestTemplate() {
    super();/*from  w  w w .j  a  va2 s .  c  o  m*/
    httpClient = new DefaultHttpClient();
    cookieStore = new BasicCookieStore();
    httpContext = new BasicHttpContext();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, getCookieStore());
    statefullHttpComponentsClientHttpRequestFactory = new StatefullHttpComponentsClientHttpRequestFactory(
            httpClient, httpContext);
    super.setRequestFactory(statefullHttpComponentsClientHttpRequestFactory);
}

From source file:com.grinnellplans.plandroid.SessionService.java

public SessionService() {
    super();//from  w  w w. j a  v  a  2 s . com
    _httpContext = new BasicHttpContext();
    _httpContext.setAttribute(ClientContext.COOKIE_STORE, new BasicCookieStore());
    _loggedIn = false;
    _af = new AutofingerList();
    set_serverName("grinnellplans.com");
}

From source file:net.giovannicapuano.galax.util.Utils.java

/**
 * Perform a HTTP POST request./* w  w w .  j  a  va2 s  . c om*/
 */
public static HttpData postData(String path, List<NameValuePair> post, Context context) {
    HttpParams httpParameters = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParameters, 5000);
    HttpConnectionParams.setSoTimeout(httpParameters, 10000);

    int status = HttpStatus.SC_INTERNAL_SERVER_ERROR;
    String body = "";

    HttpClient httpClient = new DefaultHttpClient(httpParameters);
    HttpContext localContext = new BasicHttpContext();

    localContext.setAttribute(ClientContext.COOKIE_STORE, new PersistentCookieStore(context));
    StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build());

    try {
        HttpPost httpPost = new HttpPost(context.getString(R.string.server) + path);
        httpPost.setEntity(new UrlEncodedFormEntity(post));
        HttpResponse response = httpClient.execute(httpPost, localContext);

        status = response.getStatusLine().getStatusCode();
        body = EntityUtils.toString(response.getEntity());
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

    return new HttpData(status, body);
}

From source file:com.yanzhenjie.andserver.HandleRequestThread.java

@Override
public void run() {
    try {//from ww  w. j a va 2s.c  o  m
        while (mCore.isRunning() && mConnection.isOpen()) {
            mHttpService.handleRequest(mConnection, new BasicHttpContext());
        }
    } catch (Exception ignored) {
    } finally {
        try {
            mConnection.shutdown();
        } catch (IOException ignored) {
        }
    }
}

From source file:org.eclipse.lyo.testsuite.oslcv2.trs.TRSTest.java

@BeforeClass
public static void setupOnce() {
    try {//from   w ww.j a  v  a2 s. com
        prop = getConfigPropertiesInstance();

        String trsEndpoint = prop.getProperty("configTrsEndpoint");
        String acceptType = prop.getProperty("acceptType");

        httpClient = new EasySSLClient().getClient();

        httpContext = new DefaultedHttpContext(new BasicHttpContext(), new SyncBasicHttpContext(null));

        trsResource = getResource(trsEndpoint, httpClient, httpContext, acceptType);
    } catch (FileNotFoundException e) {
        terminateTest(Messages.getServerString("tests.general.config.properties.missing"), e);
    } catch (InterruptedException e) {
        terminateTest(null, e);
    } catch (IOException e) {
        terminateTest(Messages.getServerString("tests.general.config.properties.unreadable"), e);
    } catch (FetchException e) {
        terminateTest(Messages.getServerString("tests.general.trs.fetch.error"), e);
    } catch (Exception e) {
        terminateTest(null, e);
    }
}

From source file:com.putlocker.upload.http.filemanagement.PutlockerDeleteFile.java

public PutlockerDeleteFile(PutlockerNode node, AuthStorage storage, RequestCallback callback) {
    super(Constants.BASE_URL + Constants.DELETE_FILE + node.getNodeKey(), storage, callback);
    context = new BasicHttpContext();
}