Package io.fathom.http

Examples of io.fathom.http.HttpResponse


        URI uri = metadataUri.resolve(metadata.image);

        HttpRequest request = getHttpClient().buildRequest(HttpMethod.GET, uri);
        addHeaders(request);

        HttpResponse response = executeRawRequest(request);

        try {
            try (InputStream is = response.getInputStream()) {
                if (is == null) {
                    return null;
                }

                TempFile tempFile = TempFile.create();
View Full Code Here


        request.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
        setRequestContent(request, ByteSource.wrap(json.getBytes(Charsets.UTF_8)));
    }

    protected String doStringRequest(HttpRequest request) throws RestClientException {
        HttpResponse response = executeRawRequest(request);

        try {
            String json = null;
            try (InputStream is = response.getInputStream()) {
                if (is != null) {
                    try (InputStreamReader reader = new InputStreamReader(is, Charsets.UTF_8)) {
                        json = CharStreams.toString(reader);
                    }
                }
View Full Code Here

            closeQuietly(response);
        }
    }

    protected byte[] doByteArrayRequest(HttpRequest request) throws RestClientException {
        HttpResponse response = executeRawRequest(request);

        try {
            byte[] data = null;
            try (InputStream is = response.getInputStream()) {
                if (is != null) {
                    data = ByteStreams.toByteArray(is);
                }
            } catch (IOException e) {
                throw new RestClientException("Error reading response", e);
View Full Code Here

        int attempt = 0;
        while (true) {
            attempt++;
            log.debug("Doing HTTP {} {}", request.getMethod(), request.getUrl());

            HttpResponse response;
            int statusCode;

            try {
                response = request.doRequest();
                statusCode = response.getHttpResponseCode();
            } catch (IOException e) {
                throw new RestClientException("Error during call", e);
            }

            if (!isSuccess(request, statusCode)) {
View Full Code Here

        super(httpClient, uri, tokenProvider);
    }

    public StorageObjectInfo findStorageObjectInfo(String path) throws RestClientException {
        HttpRequest request = buildHead(path);
        HttpResponse response = null;
        try {
            response = executeRawRequest(request);

            StorageObjectInfo info = new StorageObjectInfo();

            {
                String header = response.getFirstHeader(HttpHeaders.CONTENT_LENGTH);
                if (header != null) {
                    info.length = Long.valueOf(header);
                }
            }

            {
                String header = response.getFirstHeader(HttpHeaders.LAST_MODIFIED);
                if (header != null) {
                    info.lastModified = new Date(header);
                }
            }
View Full Code Here

        for (GetFileOption option : options) {
            option.modifyRequest(request);
        }

        HttpResponse response = null;
        try {
            response = executeRawRequest(request);

            InputStream is;
            try {
                is = response.getInputStream();
            } catch (IOException e) {
                throw new RestClientException("Error reading response", e);
            }
            if (is == null) {
                throw new IllegalStateException();
View Full Code Here

TOP

Related Classes of io.fathom.http.HttpResponse

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.