Attempt an API call. This method executes the API call asynchronously
on an internal thread pool. If the call is rate limited, the thread
will retry up to the maximum configured time.
@param request the API request.
779685
public void attempt(Request request) {
    this.attempt(request, new APICallback() {
      @Override
      public void error(Exception ex) {
      }

      public void response(Response r) {
      }
    });
  }
166656
private <T extends OperationRequest, U extends OperationResponse> void invoke(OperationAttempt<T, U> attempt) {
    if (state.getState() == PrimitiveState.CLOSED) {
      attempt.fail(new PrimitiveException.ClosedSession("session closed"));
    } else {
      attempts.put(attempt.sequence, attempt);
      attempt.send();
      attempt.future.whenComplete((r, e) -> attempts.remove(attempt.sequence));
    }
  }
269556
private HttpResponse execute(HttpClient client, HttpUriRequest request) throws IOException {
        if (localContext != null) {
            return client.execute(request, localContext);
        } else {
            return client.execute(request);
        }
    }
473680
private void finalizeRequest(Request request) {
        // Check, one last time, if the request was finalized. Better fail it with an AssertionError rather than leave it
        // hanging forever.
        if (!request.isDone()) {
            request.fail(new AssertionError("Request finalized but not yet completed."));
        }

        // Unregister the request.
        synchronized (this.lock) {
            this.pendingRequests.remove(request.getOffset());
        }

        log.debug("{}: StorageRead.Finalize {}, Success = {}", this.traceObjectId, request, !request.resultFuture.isCompletedExceptionally());
    }
1231609
public synchronized void setRequest(HttpServletRequest request) {

        if (perThreadRequest == null) {
            perThreadRequest = new ThreadLocal<HttpServletRequest>();
        }
        perThreadRequest.set(request);
    }
354569
def invoke(self, request):
        
        url = '{0}/{1}'.format(self.base_url, request.remote_path)
        r = self.httpclient.get(url, params=request.params, headers=self.get_headers())
        if 200 <= r.status_code < 300:
            return self.resource_factory.from_json(r.json())
        else:
            if r.status_code in ErrorMapping.mapping:
                raise ErrorMapping.mapping[r.status_code](r)
            else:
                raise ApiError(r)
1292341
protected <T> Response<T> dispatchByMethod(Request<T> request) {
		HttpMethod method = HttpMethodUtil.retrieveMethod(request);

		switch (method) {
			case GET:
				return doGet(request);
			case POST:
				return doPost(request);
			case PUT:
				return doPut(request);
			case DELETE:
				return doDelete(request);
			default:
				throw new CommunicationErrorException(HttpStatus.Not_Implemented);
		}
	}
192541
void setRequest(HttpUriRequest request) {
    requestLock.lock();
    try {
      if (this.request != null) {
        throw new SparqlException("Command is already executing a request.");
      }
      this.request = request;
    } finally {
      requestLock.unlock();
    }
  }
844834
def retry_request(self, method, action, body=None,
                      headers=None, params=None):
        
        max_attempts = self.retries + 1
        for i in range(max_attempts):
            try:
                return self.do_request(method, action, body=body,
                                       headers=headers, params=params)
            except exceptions.ConnectionFailed:
                # Exception has already been logged by do_request()
                if i < self.retries:
                    _logger.debug('Retrying connection to Neutron service')
                    time.sleep(self.retry_interval)
                elif self.raise_errors:
                    raise

        if self.retries:
            msg = (_("Failed to connect to Neutron server after %d attempts")
                   % max_attempts)
        else:
            msg = _("Failed to connect Neutron server")

        raise exceptions.ConnectionFailed(reason=msg)
593441
@Override
	public void execute(HttpGet httpGet, FutureCallback<HttpResponse> futureCallback) {

		try {
			if (httpGet == null) {
				throw new RuntimeException("Cannot issue GET request with HttpGet object");
			}
			log.info("Executing GET request to " + httpGet.getURI().toString());
			thread = new GetThread(client, httpGet, futureCallback);
			thread.start();
		} catch (Exception e) {
			log.error(e.getMessage());
			futureCallback.failed(e);
		}
	}
699280
@Override
  public boolean execute(HttpRequestBase request) {
    DataSenderThread senderThread = new DataSenderThread(HTTP_CLIENT_INSTANCE, request);
    senderThread.run();
    return true;
  }
519173
protected void postOperation(AipRequest request) {
        if (isBceKey.get()) {
            // add aipSdk param
            request.addParam("aipSdk", "java");

            String bodyStr = request.getBodyStr();

            try {
                int len = bodyStr.getBytes(request.getContentEncoding()).length;
                request.addHeader(Headers.CONTENT_LENGTH, Integer.toString(len));
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }

            request.addHeader(Headers.CONTENT_MD5, SignUtil.md5(bodyStr, request.getContentEncoding()));

            String timestamp = Util.getCanonicalTime();
            request.addHeader(Headers.HOST, request.getUri().getHost());
            request.addHeader(Headers.BCE_DATE, timestamp);
            request.addHeader(Headers.AUTHORIZATION, CloudAuth.sign(request, this.aipKey, this.aipToken, timestamp));
        }
        else {
            request.addParam("aipSdk", "java");
            request.addParam("access_token", accessToken);
        }
    }
943014
protected static void fetchAnonymousAccessTokenAndRunRequest(final Request request) {
        fetchAnonymousAccessToken(request.getUserId(), new ResponseHandler() {
            @Override
            public void onSuccess(Response response) {
                requestAuthenticated(request);
            }

            @Override
            public void onFailure(Throwable e, Response errorResponse) {
            }
        });
    }
529674
public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
		LOG.debug("In retry request");
		if (exception == null) {
			throw new IllegalArgumentException("Exception parameter may not be null");
		} else  if (context == null) {
			throw new IllegalArgumentException("HTTP context may not be null");
		}

		if (executionCount > this.retryCount) {
			return checkPolicy(executionCount);
		} else if (exception instanceof NoHttpResponseException) {
			// Retry if the server dropped connection on us
			return checkPolicy(executionCount);
		} else if (exception instanceof InterruptedIOException) {
			// Timeout
			return false;
		} else if (exception instanceof UnknownHostException) {
			// Unknown host
			return false;
		} else if (exception instanceof ConnectException) {
			// Connection refused
			return false;
		} else if (exception instanceof SSLException) {
			// SSL handshake exception
			return false;
		} else if (exception instanceof ProtocolException) {
			// protocol exception
			return false;
		} else if (exception instanceof SaslException) {
			// Sasl exception
			return false;
		}

		HttpRequest request = (HttpRequest) context.getAttribute(HttpCoreContext.HTTP_REQUEST);
		boolean idempotent = !(request instanceof HttpEntityEnclosingRequest);
		if (idempotent) {
			// Retry if the request is considered idempotent
			return checkPolicy(executionCount);
		}

		Boolean b = (Boolean) context.getAttribute(HttpCoreContext.HTTP_REQ_SENT);
		boolean sent = (b != null && b.booleanValue());

		// if (!sent || this.requestSentRetryEnabled) {
		// Retry if the request has not been sent fully or
		// if it's OK to retry methods that have been sent
		if (!sent) {
			return checkPolicy(executionCount);
		}
		// otherwise do not retry
		return false;
	}
446994
private void fireRequestSent(final AbstractBody request) {
        assertUnlocked();

        BOSHMessageEvent event = null;
        for (BOSHClientRequestListener listener : requestListeners) {
            if (event == null) {
                event = BOSHMessageEvent.createRequestSentEvent(this, request);
            }
            try {
                listener.requestSent(event);
            } catch (Exception ex) {
                LOG.log(Level.WARNING, UNHANDLED, ex);
            }
        }
    }
732708
@Override
	public void handleRequest(final Request request) {
		// Clear pressed
		clearPressed();

		String requestValue = request.getParameter(getId());
		boolean pressed = "x".equals(requestValue);

		// Only process on a POST
		if (pressed && !"POST".equals(request.getMethod())) {
			LOG.warn("Button pressed on a request that is not a POST. Will be ignored.");
			return;
		}

		setPressed(pressed, request);
	}
543769
void dispatchRequest(final HttpRequest request) {
		networkQueue.dispatchAsync(new DispatchTask() {
			@Override
			protected void execute() {
				request.dispatchSync(networkQueue);
			}
		});
	}