Search in sources :

Example 1 with TimeoutException

use of com.codeborne.selenide.ex.TimeoutException in project selenide by selenide.

the class DownloadFileWithHttpRequest method executeHttpRequest.

@CheckReturnValue
@Nonnull
protected CloseableHttpResponse executeHttpRequest(Driver driver, String fileToDownloadLocation, long timeout) throws IOException {
    CloseableHttpClient httpClient = ignoreSelfSignedCerts ? createTrustingHttpClient() : createDefaultHttpClient();
    HttpGet httpGet = new HttpGet(fileToDownloadLocation);
    configureHttpGet(httpGet, timeout);
    addHttpHeaders(driver, httpGet);
    try {
        return httpClient.execute(httpGet, createHttpContext(driver));
    } catch (SocketTimeoutException timeoutException) {
        throw new TimeoutException("Failed to download " + fileToDownloadLocation + " in " + timeout + " ms.", timeoutException);
    }
}
Also used : CloseableHttpClient(org.apache.hc.client5.http.impl.classic.CloseableHttpClient) SocketTimeoutException(java.net.SocketTimeoutException) HttpGet(org.apache.hc.client5.http.classic.methods.HttpGet) SocketTimeoutException(java.net.SocketTimeoutException) TimeoutException(com.codeborne.selenide.ex.TimeoutException) CheckReturnValue(javax.annotation.CheckReturnValue) Nonnull(javax.annotation.Nonnull)

Aggregations

TimeoutException (com.codeborne.selenide.ex.TimeoutException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 CheckReturnValue (javax.annotation.CheckReturnValue)1 Nonnull (javax.annotation.Nonnull)1 HttpGet (org.apache.hc.client5.http.classic.methods.HttpGet)1 CloseableHttpClient (org.apache.hc.client5.http.impl.classic.CloseableHttpClient)1