Package org.apache.http.client.methods

Examples of org.apache.http.client.methods.HttpRequestBase


      long startTime = System.currentTimeMillis();
      long dataSize = 0L;
     
      try
      {
  HttpRequestBase executeMethod = getInitializedGetMethod(getGetDocInfoURL(documentIdentifier));
        ExecuteGetDocInfoThread t = new ExecuteGetDocInfoThread(httpClient,executeMethod,documentIdentifier);
        try
        {
          t.start();
          t.join();
View Full Code Here


        try {
          checkRequestAllowed(request);
          String smethod = request.getMethod();
          DefaultHttpClient client = getClient(request, getSocketReadTimeout());
          URI url = getRequestURI(request);
          HttpRequestBase method = createMethod(smethod, url, request);
          if (prepareForwardingMethod(method, request, client)) {
            HttpResponse clientResponse = executeMethod(client, method);
            prepareResponse(method, request, response, clientResponse, true);
          }
          response.flushBuffer();
View Full Code Here

    try {
      initProxy(request, response);
      String smethod = request.getMethod();
      DefaultHttpClient client = getClient(request, getSocketReadTimeout());
      URI url = getRequestURI(request);
      HttpRequestBase method = createMethod(smethod, url, request);
      if (prepareForwardingMethod(method, request, client)) {
        if (smethod.equalsIgnoreCase("POST") || (smethod.equalsIgnoreCase("PUT"))) {
          FileItemFactory factory = new DiskFileItemFactory();
          // Create a new file upload handler
          ServletFileUpload upload = new ServletFileUpload(factory);         
View Full Code Here

    args.setServiceUrl(serviceUrl);
    args.setHandler(format);
    args.setHeaders(headers);

    String smethod = request.getMethod();
    HttpRequestBase method = createMethod(smethod, new URI(composeRequestUrl(args, parameters)), request);
    DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
    if (endpoint.isForceTrustSSLCertificate()) {
      defaultHttpClient = SSLUtil.wrapHttpClient(defaultHttpClient);
    }
    if (endpoint.isForceDisableExpectedContinue()) {
      defaultHttpClient.getParams().setParameter(
          CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
    }
    endpoint.initialize(defaultHttpClient);

    for (Map.Entry<String, String> e : args.getHeaders().entrySet()) {
      String headerName = e.getKey();
      String headerValue = e.getValue();
      method.addHeader(headerName, headerValue);
    }
    if (content != null) {
      content.initRequestContent(defaultHttpClient, method, args);
    }
    endpoint.updateHeaders(defaultHttpClient, method);
View Full Code Here

   @SuppressWarnings("unchecked")
   public ClientResponse execute(ClientRequest request) throws Exception
   {
      String uri = request.getUri();
      final HttpRequestBase httpMethod = createHttpMethod(uri, request.getHttpMethod());
      loadHttpMethod(request, httpMethod);

      final HttpResponse res = httpClient.execute(httpMethod);

      BaseClientResponse response = new BaseClientResponse(new BaseClientResponseStreamFactory()
View Full Code Here

   @SuppressWarnings("unchecked")
   public ClientResponse execute(ClientRequest request) throws Exception
   {
      String uri = request.getUri();
      final HttpRequestBase httpMethod = createHttpMethod(uri, request.getHttpMethod());
      loadHttpMethod(request, httpMethod);

      final HttpResponse res = httpClient.execute(httpMethod);

      BaseClientResponse response = new BaseClientResponse(new BaseClientResponseStreamFactory()
View Full Code Here

            if ( retryCount > 0 ) {
                request.setParameters(originalParameters);
                request.setHeaders(originalHeaders);
            }

            HttpRequestBase httpRequest = null;
            org.apache.http.HttpResponse response = null;


            try {
                // Sign the request if a signer was provided
                if (executionContext.getSigner() != null && executionContext.getCredentials() != null) {
                    awsRequestMetrics.startEvent(Field.RequestSigningTime.name());
                    executionContext.getSigner().sign(request, executionContext.getCredentials());
                    awsRequestMetrics.endEvent(Field.RequestSigningTime.name());
                }

                 if (requestLog.isDebugEnabled()) {
                    requestLog.debug("Sending Request: " + request.toString());
                 }

                httpRequest = httpRequestFactory.createHttpRequest(request, config, entity, executionContext);

                if (httpRequest instanceof HttpEntityEnclosingRequest) {
                    entity = ((HttpEntityEnclosingRequest)httpRequest).getEntity();
                }

                if (redirectedURI != null) {
                    httpRequest.setURI(redirectedURI);
                }

                if ( retryCount > 0 ) {
                    awsRequestMetrics.startEvent(Field.RetryPauseTime.name());
                    pauseExponentially(retryCount, exception, executionContext.getCustomBackoffStrategy());
                    awsRequestMetrics.endEvent(Field.RetryPauseTime.name());
                }

                if ( entity != null ) {
                    InputStream content = entity.getContent();
                    if ( retryCount > 0 ) {
                        if ( content.markSupported() ) {
                            content.reset();
                            content.mark(-1);
                        }
                    } else {
                        if ( content.markSupported() ) {
                            content.mark(-1);
                        }
                    }
                }

                exception = null;

                awsRequestMetrics.startEvent(Field.HttpRequestTime.name());
                response = httpClient.execute(httpRequest);
                awsRequestMetrics.endEvent(Field.HttpRequestTime.name());


                if (isRequestSuccessful(response)) {

                    awsRequestMetrics.addProperty(Field.StatusCode.name(), response.getStatusLine().getStatusCode());

                    /*
                     * If we get back any 2xx status code, then we know we should
                     * treat the service call as successful.
                     */
                    leaveHttpConnectionOpen = responseHandler.needsConnectionLeftOpen();
                    return handleResponse(request, responseHandler, httpRequest, response, executionContext);
                } else if (isTemporaryRedirect(response)) {
                    /*
                     * S3 sends 307 Temporary Redirects if you try to delete an
                     * EU bucket from the US endpoint. If we get a 307, we'll
                     * point the HTTP method to the redirected location, and let
                     * the next retry deliver the request to the right location.
                     */
                    Header[] locationHeaders = response.getHeaders("location");
                    String redirectedLocation = locationHeaders[0].getValue();
                    log.debug("Redirecting to: " + redirectedLocation);
                    redirectedURI = URI.create(redirectedLocation);
                    httpRequest.setURI(redirectedURI);
                    awsRequestMetrics.addProperty(Field.StatusCode.name(), response.getStatusLine().getStatusCode());
                    awsRequestMetrics.addProperty(Field.RedirectLocation.name(), redirectedLocation);
                    awsRequestMetrics.addProperty(Field.AWSRequestID.name(), null);

                } else {
View Full Code Here

    // build request
    HttpParams httpParams = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParams, 6000);
    DefaultHttpClient httpClient = new DefaultHttpClient(httpParams);

    HttpRequestBase httpRequest;

    if(method == Http.GET)
    {
      httpRequest = new HttpGet(url);
    }
    else if(method == Http.POST)
    {
      httpRequest = new HttpPost(url);

      if(body != null && !body.isEmpty())
      {
        ((HttpPost) httpRequest).setEntity(new StringEntity(body));
      }
    }
    else
    {
      throw new Exception("Invalid request method");
    }


    // add headers
    if(header != null)
    {
      Set<String> keys = header.keySet();

      for(String k : keys)
      {
        httpRequest.addHeader(k, header.get(k));
      }
    }


    // sign request
    if(oauth != null && signed)
    {
      oauth.signRequest(httpRequest);
    }


    // execute request
    logger.info("Request: " + httpRequest.getRequestLine().toString());

    HttpResponse httpResponse = httpClient.execute(httpRequest);

    logger.info("Response: " + httpResponse.getStatusLine().toString());
View Full Code Here

    HttpParams httpParams = new BasicHttpParams();
    HttpConnectionParams.setConnectionTimeout(httpParams, 6000);
    DefaultHttpClient httpClient = new DefaultHttpClient(httpParams);


    HttpRequestBase request;

    if(method.equals("GET"))
    {
      request = new HttpGet(url);
    }
    else if(method.equals("POST"))
    {
      MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
      entity.addPart("text", new StringBody(body));

      request = new HttpPost(url);

      ((HttpPost) request).setEntity(entity);
    }
    else
    {
      throw new Exception("Invalid request method");
    }


    // header
    Set<String> keys = header.keySet();

    for(String key : keys)
    {
      request.setHeader(key, header.get(key));
    }


        // execute HTTP Get Request
    logger.info("Request: " + request.getRequestLine());

    HttpResponse httpResponse = httpClient.execute(request);

    HttpEntity entity = httpResponse.getEntity();
View Full Code Here

  public Object getValueAt(int rowIndex, int columnIndex)
  {
    if(rowIndex >= 0 && rowIndex < rows.size())
    {
      HttpRequestBase request = rows.get(rowIndex).getRequest();
      HttpResponse response = rows.get(rowIndex).getResponse();

      switch(columnIndex)
      {
        case 0: return request.getMethod();
        case 1: return response.getStatusLine();
        case 2: return request.getRequestLine().getUri();
      }
    }

    return null;
  }
View Full Code Here

TOP

Related Classes of org.apache.http.client.methods.HttpRequestBase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.