Examples of HttpUriRequest


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

   /**
    * Return the current full URL.
    */
   public String getCurrentURL()
   {
      HttpUriRequest currentReq = (HttpUriRequest) context.getAttribute(
               ExecutionContext.HTTP_REQUEST);
      HttpHost currentHost = (HttpHost) context.getAttribute(
               ExecutionContext.HTTP_TARGET_HOST);
      String currentUrl = currentHost.toURI() + currentReq.getURI();

      if (currentUrl.startsWith(baseUrl))
      {
         currentUrl = currentUrl.substring(baseUrl.length());
      }
View Full Code Here

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

        assert url.startsWith("http");


        try {
            client = createClient();
            HttpUriRequest httpMethod = null;
           
            switch (method) {
                case GET:
                    httpMethod = new HttpGet(url);
                    break;
                case DELETE:
                    httpMethod = new HttpDelete(url);
                    break;

                case POST:
                    httpMethod = new HttpPost(url);
                    ((HttpPost) httpMethod).setEntity(new StringEntity(this.requestBody));
                    break;
                case PUT:
                    httpMethod = new HttpPut(url);
                    ((HttpPut) httpMethod).setEntity(new StringEntity(this.requestBody));
                    break;
                default:
                    throw new IllegalStateException("Can't execute this method : " + method);
            }

            //Adding headers
            if (this.contentType == null){
                this.contentType = SynchronousRestClient.xmlContentType;
            }
            httpMethod.addHeader("Content-type", this.contentType);
            if (authorizationValue != null) {
                httpMethod.addHeader("Authorization", ApacheRestClient.authorizationValue);
            }

            //Executing
            HttpResponse httpResponse = client.execute(httpMethod);
View Full Code Here

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

    }

    private HttpActionResult processHttpClient(HttpActionDefinition definition,
        HttpClient httpClient, long scheduleExecutionId, String nodeAddress) throws Exception
    {
        HttpUriRequest request;

        switch (definition.getMethod()) {
            case GET:
                request = composeGetRequest(definition, scheduleExecutionId, nodeAddress);
                break;
View Full Code Here

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

            redirectCount++;

            // Virtual host cannot be used any longer
            virtualHost = null;

            HttpUriRequest redirect = redirectStrategy.getRedirect(request, response, context);
            HttpRequest orig = request.getOriginal();
            redirect.setHeaders(orig.getAllHeaders());

            URI uri = redirect.getURI();
            if (uri.getHost() == null) {
                throw new ProtocolException("Redirect URI does not specify a valid host name: " + uri);
            }

            HttpHost newTarget = new HttpHost(
View Full Code Here

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

    @Test
    public void testCallsSelfAndRunsHandlerOnExecuteUriRequestWithHandlerAndContext()
            throws Exception {

        final Counter c = new Counter();
        final HttpUriRequest theRequest = mockUriRequest;
        final HttpContext theContext = context;
        final HttpResponse theResponse = mockBackendResponse;
        final Object theValue = new Object();
        impl = new CachingHttpClient(
                mockBackend,
View Full Code Here

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

    }

    @Test
    public void testCallsSelfWithNullContextOnExecuteUriRequest() throws Exception {
        final Counter c = new Counter();
        final HttpUriRequest theRequest = mockUriRequest;
        final HttpResponse theResponse = mockBackendResponse;
        impl = new CachingHttpClient(
                mockBackend,
                mockValidityPolicy,
                mockResponsePolicy,
View Full Code Here

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

    }

    @Test
    public void testCallsSelfWithNullContextOnExecuteUriRequestWithHandler() throws Exception {
        final Counter c = new Counter();
        final HttpUriRequest theRequest = mockUriRequest;
        final HttpResponse theResponse = mockBackendResponse;
        final Object theValue = new Object();
        impl = new CachingHttpClient(
                mockBackend,
                mockValidityPolicy,
View Full Code Here

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

        }
    }
   
    @Test
    public void testPostBody() throws Exception {
        HttpUriRequest method = new HttpPost("http://localhost:" + portNum + "/users");

        List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
        urlParameters.add(new BasicNameValuePair("foo", "bar"));

        ((HttpEntityEnclosingRequestBase)method).setEntity(new UrlEncodedFormEntity(urlParameters));
View Full Code Here

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

        }
    }
   
    @Test
    public void testPostBody() throws Exception {
        HttpUriRequest method = new HttpPost("http://localhost:" + portNum + "/users");

        List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
        urlParameters.add(new BasicNameValuePair("foo", "bar"));

        ((HttpEntityEnclosingRequestBase)method).setEntity(new UrlEncodedFormEntity(urlParameters));
View Full Code Here

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

                throw new RedirectException("Maximum redirects ("
                        + maxRedirects + ") exceeded");
            }
            this.redirectCount++;

            HttpUriRequest redirect = this.redirectStrategy.getRedirect(
                    this.currentRequest, this.currentResponse, this.localContext);
            HttpRequest orig = request.getOriginal();
            redirect.setHeaders(orig.getAllHeaders());

            URI uri = redirect.getURI();
            if (uri.getHost() == null) {
                throw new ProtocolException("Redirect URI does not specify a valid host name: " + uri);
            }
            HttpHost newTarget = new HttpHost(uri.getHost(), uri.getPort(), uri.getScheme());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.