Examples of BasicResponseHandler


Examples of org.apache.http.impl.client.BasicResponseHandler

        return _httpClient;
    }

    private ResponseHandler<String> getResponseHandler() {
        if (_responseHandler == null) {
            _responseHandler = new BasicResponseHandler();
        }
        return _responseHandler;
    }
View Full Code Here

Examples of org.apache.http.impl.client.BasicResponseHandler

    synchronized private void doRegister(String service) {
        String url = registryURL;
        try {
            HttpPut method = new HttpPut(url);
            method.addHeader("service", service);
            ResponseHandler<String> handler = new BasicResponseHandler();
            String responseBody = httpClient.execute(method, handler);
            LOG.debug("PUT to " + url + " got a " + responseBody);
        } catch (Exception e) {
            LOG.debug("PUT to " + url + " failed with: " + e);
        }
View Full Code Here

Examples of org.apache.http.impl.client.BasicResponseHandler

    synchronized private void doUnRegister(String service) {
        String url = registryURL;
        try {
            HttpDelete method = new HttpDelete(url);
            method.addHeader("service", service);
            ResponseHandler<String> handler = new BasicResponseHandler();
            String responseBody = httpClient.execute(method, handler);
            LOG.debug("DELETE to " + url + " got a " + responseBody);
        } catch (Exception e) {
            LOG.debug("DELETE to " + url + " failed with: " + e);
        }
View Full Code Here

Examples of org.apache.http.impl.client.BasicResponseHandler

    synchronized private Set<String> doLookup(long freshness) {
        String url = registryURL + "?freshness=" + freshness;
        try {
            HttpGet method = new HttpGet(url);
            ResponseHandler<String> handler = new BasicResponseHandler();
            String response = httpClient.execute(method, handler);
            LOG.debug("GET to " + url + " got a " + response);
            Set<String> rc = new HashSet<String>();
            Scanner scanner = new Scanner(response);
            while (scanner.hasNextLine()) {
View Full Code Here

Examples of org.apache.http.impl.client.BasicResponseHandler

        // Request the options from the server so we can find out if the broker we are
        // talking to supports GZip compressed content.  If so and useCompression is on
        // then we can compress our POST data, otherwise we must send it uncompressed to
        // ensure backwards compatibility.
        HttpOptions optionsMethod = new HttpOptions(remoteUrl.toString());
        ResponseHandler<String> handler = new BasicResponseHandler() {
            @Override
            public String handleResponse(HttpResponse response) throws HttpResponseException, IOException {

                for(Header header : response.getAllHeaders()) {
                    if (header.getName().equals("Accepts-Encoding") && header.getValue().contains("gzip")) {
                        LOG.info("Broker Servlet supports GZip compression.");
                        canSendCompressed = true;
                        break;
                    }
                }

                return super.handleResponse(response);
            }
        };


        try {
            httpClient.execute(httpMethod, new BasicResponseHandler());
            httpClient.execute(optionsMethod, handler);
        } catch(Exception e) {
            throw new IOException("Failed to perform GET on: " + remoteUrl + " as response was: " + e.getMessage());
        }
View Full Code Here

Examples of org.apache.http.impl.client.BasicResponseHandler

        HttpGet httpget = new HttpGet("http://www.google.com/");

        System.out.println("executing request " + httpget.getURI());

        // Create a response handler
        ResponseHandler<String> responseHandler = new BasicResponseHandler();
        String responseBody = httpclient.execute(httpget, responseHandler);
        System.out.println(responseBody);
       
        System.out.println("----------------------------------------");
    }
View Full Code Here

Examples of org.apache.http.impl.client.BasicResponseHandler

        for(String value : headers.get(key)) {
          get.addHeader(key, value);
        }
      }

      ResponseHandler<String> handler = new BasicResponseHandler();
      return client.execute(get, handler);

    } finally {
      client.getConnectionManager().shutdown();
    }
View Full Code Here

Examples of org.apache.http.impl.client.BasicResponseHandler

                HttpResponse response1 = httpclient.execute(httpGet);
                //System.out.println(response1.getStatusLine());
                // HttpEntity entity1 = response1.getEntity();
                // do something useful with the response body
                // and ensure it is fully consumed
                ResponseHandler<String> responseHandler = new BasicResponseHandler();
                String handleResponse = responseHandler.handleResponse(response1);
                StringReader sr = new StringReader(handleResponse);
                inputSource = new InputSource(sr);


            } finally {
View Full Code Here

Examples of org.apache.http.impl.client.BasicResponseHandler

        this.serverBootstrap.registerHandler("*", createGzipEncodingRequestHandler(entityText));

        final HttpHost target = start();

        final HttpGet request = new HttpGet("/some-resource");
        final String response = this.httpclient.execute(target, request, new BasicResponseHandler());
        Assert.assertEquals("The entity text is correctly transported", entityText, response);
    }
View Full Code Here

Examples of org.apache.http.impl.client.BasicResponseHandler

        this.serverBootstrap.registerHandler("*", createDeflateEncodingRequestHandler(entityText, false));

        final HttpHost target = start();

        final HttpGet request = new HttpGet("/some-resource");
        final String response = this.httpclient.execute(target, request, new BasicResponseHandler());
        Assert.assertEquals("The entity text is correctly transported", entityText, response);
    }
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.