Package org.apache.http

Examples of org.apache.http.HttpHost.toURI()


                HttpHost target = (HttpHost) localContext.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
                URI redirectURI = req.getURI();
                if (redirectURI.isAbsolute()){
                    res.setURL(redirectURI.toURL());
                } else {
                    res.setURL(new URL(new URL(target.toURI()),redirectURI.toString()));
                }
            }

            // Store any cookies received in the cookie manager:
            saveConnectionCookies(httpResponse, res.getURL(), getCookieManager());
View Full Code Here


        // This was triggered by HttpClient with the redirect count was exceeded.
        HttpHost host = (HttpHost)localContext.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
        HttpUriRequest finalRequest = (HttpUriRequest)localContext.getAttribute(ExecutionContext.HTTP_REQUEST);

        try {
            URL hostUrl = new URI(host.toURI()).toURL();
            return new URL(hostUrl, finalRequest.getURI().toString()).toExternalForm();
        } catch (MalformedURLException e) {
            LOGGER.warn("Invalid host/uri specified in final fetch: " + host + finalRequest.getURI());
            return url;
        } catch (URISyntaxException e) {
View Full Code Here

   {
      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

   public String getHost()
   {
      HttpHost currentHost = (HttpHost) context.getAttribute(
               ExecutionContext.HTTP_TARGET_HOST);

      return currentHost.toURI();
   }

   public HttpClient getClient()
   {
      return client;
View Full Code Here

        registry.register("*", new BufferingAsyncRequestHandler(new TestHandler(false)));
        HttpHost target = start(registry, null);

        File tmpdir = FileUtils.getTempDirectory();
        this.tmpfile = new File(tmpdir, "dst.test");
        TestZeroCopyPost httppost = new TestZeroCopyPost(target.toURI() + "/bounce", false);
        TestZeroCopyConsumer consumer = new TestZeroCopyConsumer(this.tmpfile);
        Future<Integer> future = this.httpclient.execute(httppost, consumer, null);
        Integer status = future.get();
        Assert.assertNotNull(status);
        Assert.assertEquals(HttpStatus.SC_OK, status.intValue());
View Full Code Here

        HttpAsyncRequestHandlerRegistry registry = new HttpAsyncRequestHandlerRegistry();
        registry.register("*", new BufferingAsyncRequestHandler(new TestHandler(true)));
        HttpHost target = start(registry, null);
        File tmpdir = FileUtils.getTempDirectory();
        this.tmpfile = new File(tmpdir, "dst.test");
        TestZeroCopyPost httppost = new TestZeroCopyPost(target.toURI() + "/bounce", true);
        TestZeroCopyConsumer consumer = new TestZeroCopyConsumer(this.tmpfile);
        Future<Integer> future = this.httpclient.execute(httppost, consumer, null);
        Integer status = future.get();
        Assert.assertNotNull(status);
        Assert.assertEquals(HttpStatus.SC_OK, status.intValue());
View Full Code Here

    @Test
    public void testByteConsumer() throws Exception {
        HttpHost target = start();
        for (int i = 0; i < 5; i++) {
            HttpAsyncRequestProducer httpget = HttpAsyncMethods.createGet(target.toURI() + "/random/20480");
            AsyncByteConsumer<Long> consumer = new ByteCountingConsumer();
            Future<Long> future = this.httpclient.execute(httpget, consumer, null);
            Long count = future.get();
            Assert.assertEquals(20480, count.longValue());
        }
View Full Code Here

    @Test
    public void testByteConsumerSmallBufffer() throws Exception {
        HttpHost target = start();
        for (int i = 0; i < 5; i++) {
            HttpAsyncRequestProducer httpget = HttpAsyncMethods.createGet(target.toURI() + "/random/20480");
            AsyncByteConsumer<Long> consumer = new ByteCountingConsumer(512);
            Future<Long> future = this.httpclient.execute(httpget, consumer, null);
            Long count = future.get();
            Assert.assertEquals(20480, count.longValue());
        }
View Full Code Here

        }
        String s = sb.toString();

        for (int i = 0; i < 5; i++) {
            HttpAsyncRequestProducer httppost = HttpAsyncMethods.createPost(
                    target.toURI() + "/echo/stuff", s,
                    ContentType.create("text/plain", HTTP.ASCII));
            AsyncCharConsumer<String> consumer = new BufferingCharConsumer();
            Future<String> future = this.httpclient.execute(httppost, consumer, null);
            String result = future.get();
            Assert.assertEquals(s, result);
View Full Code Here

        }
        String s = sb.toString();

        for (int i = 0; i < 5; i++) {
            HttpAsyncRequestProducer httppost = HttpAsyncMethods.createPost(
                    target.toURI() + "/echo/stuff", s,
                    ContentType.create("text/plain", HTTP.ASCII));
            AsyncCharConsumer<String> consumer = new BufferingCharConsumer(512);
            Future<String> future = this.httpclient.execute(httppost, consumer, null);
            String result = future.get();
            Assert.assertEquals(s, result);
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.