Search in sources :

Example 1 with SyncBasicHttpParams

use of org.apache.http.params.SyncBasicHttpParams in project camel by apache.

the class HttpTestServer method newDefaultParams.

/**
     * Obtains a set of reasonable default parameters for a server.
     *
     * @return  default parameters
     */
protected HttpParams newDefaultParams() {
    HttpParams params = new SyncBasicHttpParams();
    params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 60000).setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024).setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false).setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true).setParameter(CoreProtocolPNames.ORIGIN_SERVER, "LocalTestServer/1.1");
    return params;
}
Also used : HttpParams(org.apache.http.params.HttpParams) SyncBasicHttpParams(org.apache.http.params.SyncBasicHttpParams) SyncBasicHttpParams(org.apache.http.params.SyncBasicHttpParams)

Example 2 with SyncBasicHttpParams

use of org.apache.http.params.SyncBasicHttpParams in project undertow by undertow-io.

the class TestHttpClient method preventSocketTimeoutException.

private static HttpParams preventSocketTimeoutException(HttpParams params) {
    // in CI when running tests on proxy mode
    if (DefaultServer.isProxy()) {
        if (params == null) {
            params = new SyncBasicHttpParams();
            setDefaultHttpParams(params);
        }
        HttpConnectionParams.setSoTimeout(params, 300000);
        return params;
    }
    return params;
}
Also used : SyncBasicHttpParams(org.apache.http.params.SyncBasicHttpParams)

Example 3 with SyncBasicHttpParams

use of org.apache.http.params.SyncBasicHttpParams in project undertow by undertow-io.

the class FileHandlerSymlinksTestCase method testExplicitAccessSymlinkGrantedUsingSpecificFiltersWithDirectoryListingEnabled.

@Test
public void testExplicitAccessSymlinkGrantedUsingSpecificFiltersWithDirectoryListingEnabled() throws IOException, URISyntaxException {
    HttpParams params = new SyncBasicHttpParams();
    DefaultHttpClient.setDefaultHttpParams(params);
    HttpConnectionParams.setSoTimeout(params, 300000);
    TestHttpClient client = new TestHttpClient(params);
    Path rootPath = Paths.get(getClass().getResource("page.html").toURI()).getParent();
    Path newSymlink = rootPath.resolve("newSymlink");
    try {
        DefaultServer.setRootHandler(new PathHandler().addPrefixPath("/path", new ResourceHandler(new PathResourceManager(newSymlink, 10485760, true, rootPath.toAbsolutePath().toString().concat("/newDir"))).setDirectoryListingEnabled(false).addWelcomeFiles("page.html")));
        /**
         * This request should return a 200 code as rootPath + "/newDir" is used in the safePaths
         */
        HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/path/innerSymlink/.");
        HttpResponse result = client.execute(get);
        Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
        final String response = HttpClientUtils.readResponse(result);
        Header[] headers = result.getHeaders("Content-Type");
        Assert.assertEquals("text/html", headers[0].getValue());
        Assert.assertTrue(response, response.contains("A web page"));
    } finally {
        client.getConnectionManager().shutdown();
    }
}
Also used : Path(java.nio.file.Path) HttpParams(org.apache.http.params.HttpParams) SyncBasicHttpParams(org.apache.http.params.SyncBasicHttpParams) Header(org.apache.http.Header) HttpGet(org.apache.http.client.methods.HttpGet) SyncBasicHttpParams(org.apache.http.params.SyncBasicHttpParams) CanonicalPathHandler(io.undertow.server.handlers.CanonicalPathHandler) PathHandler(io.undertow.server.handlers.PathHandler) HttpResponse(org.apache.http.HttpResponse) ResourceHandler(io.undertow.server.handlers.resource.ResourceHandler) PathResourceManager(io.undertow.server.handlers.resource.PathResourceManager) TestHttpClient(io.undertow.testutils.TestHttpClient) Test(org.junit.Test)

Aggregations

SyncBasicHttpParams (org.apache.http.params.SyncBasicHttpParams)3 HttpParams (org.apache.http.params.HttpParams)2 CanonicalPathHandler (io.undertow.server.handlers.CanonicalPathHandler)1 PathHandler (io.undertow.server.handlers.PathHandler)1 PathResourceManager (io.undertow.server.handlers.resource.PathResourceManager)1 ResourceHandler (io.undertow.server.handlers.resource.ResourceHandler)1 TestHttpClient (io.undertow.testutils.TestHttpClient)1 Path (java.nio.file.Path)1 Header (org.apache.http.Header)1 HttpResponse (org.apache.http.HttpResponse)1 HttpGet (org.apache.http.client.methods.HttpGet)1 Test (org.junit.Test)1