Package com.belladati.httpclientandroidlib

Examples of com.belladati.httpclientandroidlib.HttpResponse


            // Download file
            InputStream is = null;
            FileOutputStream os = null;
            try {
                HttpResponse response = client.getStreamResponse(song);
                is = new BufferedInputStream(response.getEntity().getContent(), INPUT_BUFFER_LEN);
                os = new FileOutputStream(tempFile);

                bus.post(new DownloadSongProgressChangedEvent(this, song, 0, 1));

                byte[] buffer = new byte[INPUT_BUFFER_LEN];

                long len = response.getEntity().getContentLength();
                int read;
                int readTotal = 0;
                float lastReportedProgress = 0;

                while ((read = is.read(buffer)) != -1) {
View Full Code Here


    /**
     * Boilerplate to send the request and parse the response payload as JSON.
     */
    private JsonNode executeRequest(HttpPost request) throws IOException, GroovesharkException {

        HttpResponse response = httpClient.execute(request);

        if (debugLogging) {
            logRequest(request, response);
        }

        String responsePayload = CharStreams.toString(new InputStreamReader(response.getEntity()
                .getContent(), Charsets.UTF_8));

        // Parse response JSON
        try {
            return jsonMapper.readTree(new StringReader(responsePayload));
View Full Code Here

    }

    private void createSession() throws IOException, GroovesharkException {
        User userFromOldSession = (session == null) ? null : session.getUser();
        HttpGet request = new HttpGet("http://" + DOMAIN + "/preload.php?getCommunicationToken");
        HttpResponse response = httpClient.execute(request);

        if (debugLogging) {
            logRequest(request, response);
        }
View Full Code Here

    public HttpResponse getStreamResponse(final Song song) throws IOException, GroovesharkException {
        return getStreamResponse(song.getId());
    }

    public HttpResponse getStreamResponse(final long songId) throws IOException, GroovesharkException {
        HttpResponse response = httpClient.execute(new HttpGet(getStreamUrl(songId).toString()));
        int statusCode = response.getStatusLine().getStatusCode();
        if (statusCode != 200) {
            EntityUtils.consumeQuietly(response.getEntity());
            throw new IOException("API returned " + statusCode + " status code");
        }
        return response;
    }
View Full Code Here

        // Build and send request
        String url = "https://" + Client.DOMAIN + "/more.php#" + method;
        HttpPost httpRequest = new HttpPost(url);
        httpRequest.setEntity(new StringEntity(rootNode.toString()));
        HttpResponse httpResponse = client.getHttpClient().execute(httpRequest);
        String payload = CharStreams.toString(new InputStreamReader(httpResponse.getEntity()
                .getContent(), Charsets.UTF_8));

        // Parse response JSON
        JsonNode jsonNode;
        try {
View Full Code Here

            // Download file
            InputStream is = null;
            FileOutputStream os = null;
            try {
                HttpResponse response = client.getStreamResponse(song);
                is = new BufferedInputStream(response.getEntity().getContent(), INPUT_BUFFER_LEN);
                os = new FileOutputStream(tempFile);

                bus.post(new DownloadSongProgressChangedEvent(this, song, 0, 1));

                byte[] buffer = new byte[INPUT_BUFFER_LEN];

                long len = response.getEntity().getContentLength();
                int read;
                int readTotal = 0;
                float lastReportedProgress = 0;

                while ((read = is.read(buffer)) != -1) {
View Full Code Here

TOP

Related Classes of com.belladati.httpclientandroidlib.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.