Code example for HttpUriRequest

Methods: abort, setHeader

0
    private static boolean authenticationRequired(int statusCode) {
        return statusCode == HTTP_SC_AUTH_REQUIRED;
    } 
     
    private HttpResponse executeWithAuth(HttpUriRequest request) throws IOException {
        request.setHeader("Cookie", "SACSID=" + authenticationCookie);
        return safelyExecute(delegate, request);
    } 
     
    /** 
     * Execute a request. If there is an error, the connection is closed. 
     */ 
    private static HttpResponse safelyExecute(HttpClient client, HttpUriRequest request)
            throws IOException { 
        HttpResponse resp = null;
        try { 
            resp = client.execute(request);
        } catch (IOException e) {
            closeResources(request, resp);
            throw e;
        } 
         
        return resp;
    } 
     
    private static void closeResources(HttpUriRequest req, HttpResponse resp) {
        try { 
            req.abort();
        } catch (UnsupportedOperationException ignore) {
        } 
        final HttpEntity entity = resp != null ? resp.getEntity() : null;
        if (entity != null) {
            try {