Package com.ning.http.client

Examples of com.ning.http.client.Request


public class APIExceptionTest {

    @Test
    public void testGetMessage() throws Exception {
        final Request request = new RequestBuilder()
                .setUrl("http://user:password@localhost:1234/some/path?query=foo#fragment")
                .build();
        final APIException apiException = new APIException(request, (Response) null);

        final String message = apiException.getMessage();
View Full Code Here


    public List<InputSummaryResponse> getPersistedInputs() throws IOException {
        final UriBuilder uriBuilder = UriBuilder.fromUri(serverUrl);
        uriBuilder.path("/system/radios/" + serverStatus.getNodeId().toString() + "/inputs");

        final Request request = httpclient.prepareGet(uriBuilder.build().toString()).build();
        LOG.debug("API Request {} {}", request.getMethod(), request.getUrl());
        final Future<Response> f = httpclient.executeRequest(request);

        final Response r;
        try {
            r = f.get();
View Full Code Here

            ensureAuthentication();
            final URL url = prepareUrl(target);
            final AsyncHttpClient.BoundRequestBuilder requestBuilder = requestBuilderForUrl(url);
            requestBuilder.addHeader(Http.HeaderNames.ACCEPT, mediaType.toString());

            final Request request = requestBuilder.build();
            if (LOG.isDebugEnabled()) {
                LOG.debug("API Request: {}", request.toString());
            }

            // Set 200 OK as standard if not defined.
            if (expectedResponseCodes.isEmpty()) {
                expectedResponseCodes.add(Http.Status.OK);
View Full Code Here

    private Response processRequest(final ClientRequest cr, final HandlerContext context) throws IOException {
        AsyncHttpClient asyncHttpClient = openConnection(cr);
        NonCloseableOutputStream ncos = new NonCloseableOutputStream();
        OutputStream os = adaptOutputStream(ncos, cr, context.getOutputStreamAdapters());

        Request request = setupHttpRequest(cr, ncos, os);
        Response response;

        try {
            response = asyncHttpClient.executeRequest(request, new AsyncCompletionHandlerBase()
            {
View Full Code Here

        this.client = new AsyncHttpClient(config);

        Stats stats = new Stats(n, c);

        for (int i = 0; i < n; i++) {
            Request request;
            if (content == null) {
                request = this.client.prepareGet(targetURI.toASCIIString())
                    .build();
            } else {
                request = this.client.preparePost(targetURI.toASCIIString())
View Full Code Here

    }

    public ClientResponse handle(final ClientRequest cr)
            throws ClientHandlerException {

        final Request request = getRequest(cr);

        try {
            Future<Response> response;

            response = getHttpClient().executeRequest(request);
View Full Code Here

                builder = builder.setFollowRedirects(true);
            else
                builder = builder.setFollowRedirects(false);
        }

        Request request = builder.build();

//        /* extremely ugly, unnecessary and inefficient. Unfortunately it is needed
//           because client side providers which modifies header values when entity is
//           being written. Ning Client writes is too late, so header is ClientRequest is
//           not yet changed and not propagated into Nings Request.
View Full Code Here

        return new NonBlockingAsyncViewResource(this, getUriBuilder().path(path));
    }

    @Override
    public Future<ClientResponse> handle(ClientRequest request, final FutureListener<ClientResponse> l) {
        Request r = client.getRequest(request);

        try {
            final ListenableFuture<Response> listenableFuture = this.client.getClientHandlerNing().getHttpClient().executeRequest(r);
            final Future<ClientResponse> jerseyFuture = new Future<ClientResponse>() {
                @Override
View Full Code Here

    @Override
    @SuppressWarnings("unchecked")
    public boolean process(Exchange exchange, AsyncCallback callback) {
        try {
            // AHC supports async processing
            Request request = getEndpoint().getBinding().prepareRequest(getEndpoint(), exchange);
            log.debug("Executing request {} ", request);
            client.prepareRequest(request).execute(new AhcAsyncHandler(exchange, callback, request.getUrl()));
            return false;
        } catch (Exception e) {
            exchange.setException(e);
            callback.done(true);
            return true;
View Full Code Here

    @Override
    public boolean process(Exchange exchange, AsyncCallback callback) {
        try {
            // AHC supports async processing
            Request request = getEndpoint().getBinding().prepareRequest(getEndpoint(), exchange);
            log.debug("Executing request {} ", request);
            client.prepareRequest(request).execute(new AhcAsyncHandler(exchange, callback, request.getUrl(), getEndpoint().getBufferSize()));
            return false;
        } catch (Exception e) {
            exchange.setException(e);
            callback.done(true);
            return true;
View Full Code Here

TOP

Related Classes of com.ning.http.client.Request

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.