Best code examples for Android HttpResponse class (org.apache.http.HttpResponse)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android HttpResponse class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Android HttpResponse examples from Open Source projects
This code example shows how to use the following methods: getEntity, getStatusLine
This code example shows how to use the following methods: getEntity, getStatusLine
 
    private Object handleResponse(HttpResponse response) throws HttpException, IOException {
        if (response == null) {
            throw new HttpException("response is null");
        } 
        StatusLine status = response.getStatusLine();
        int statusCode = status.getStatusCode();
        if (statusCode < 300) {
            HttpEntity entity = response.getEntity();
            Object responseBody = null;
            if (entity != null) {
                lastUpdateTime = SystemClock.uptimeMillis();
                if (isDownloadingFile) {
                    String responseFileName = autoRename ? OtherUtils.getFileNameFromHttpResponse(response) : null;
                    responseBody = mFileDownloadHandler.handleEntity(entity, this, fileSavePath, autoResume, responseFileName);
                } else { 
 
                    // Set charset from response header info if it's exist. 
                    String responseCharset = OtherUtils.getCharsetFromHttpResponse(response);
                    charset = TextUtils.isEmpty(responseCharset) ? charset : responseCharset;

8
CodeRank
This code example shows how to use the following methods: getEntity, getStatusLine
  @Test 
  public void testExecute() throws IOException { 
    AndroidHttpClient client = AndroidHttpClient.newInstance("foo");
    Robolectric.addPendingHttpResponse(200, "foo"); 
    HttpResponse resp = client.execute(new HttpGet("/foo"));
    assertThat(resp.getStatusLine().getStatusCode()).isEqualTo(200);
    assertThat(Strings.fromStream(resp.getEntity().getContent())).isEqualTo("foo");
  } 
} 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getEntity
            HttpConnectionParams.setSoTimeout(httpParams, SOCKET_TIMEOUT);
            HttpConnectionParams.setConnectionTimeout(httpParams, CONNECTION_TIMEOUT);
            HttpClient httpClient = new DefaultHttpClient(httpParams);
            HttpGet httpget = new HttpGet(TIMER_URL);
            HttpResponse response = httpClient.execute(httpget);
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                time = Long.parseLong(EntityUtils.toString(entity),10);
                logger.debug("Got remote timestamp {}", time);
            } 
        } catch (IOException e) {
            logger.warn("Error obtaining the synchronized remote timestamp, defaulting to the local one",e);
        } 
         
        if (time == -1) {
            time = System.currentTimeMillis();
        } 
         
        return Long.toString(time / 1000L);
    } 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getEntity, getStatusLine
            req.addHeader(
                    "x-wap-profile", 
                    "http://www.openmobilealliance.org/tech/profiles/UAPROF/ccppschema-20021212#"); 
 
            HttpResponse response = client.execute(req);
            StatusLine status = response.getStatusLine();
            if (status.getStatusCode() != 200) { // HTTP 200 is success.
                if (DEBUG) Log.d(TAG, "HTTP error: " + status.getReasonPhrase());
                return null; 
            } 
 
            HttpEntity entity = response.getEntity();
            byte[] body = null;
            if (entity != null) {
                try { 
                    if (entity.getContentLength() > 0) {
                        body = new byte[(int) entity.getContentLength()];
                        DataInputStream dis = new DataInputStream(entity.getContent());
                        try { 
                            dis.readFully(body);
Full Snippet Info
8
CodeRank
Related Android HttpResponse Questions & Answers:
Other Android HttpResponse Examples
1:	try {
2:		HttpResponse response = httpClient.execute(httpPost);
3:	
4:		// writing response to log

Read More

6:				HttpPost httpPost = new HttpPost(url);
7:	
8:				HttpResponse httpResponse = httpClient.execute(httpPost);
9:				HttpEntity httpEntity = httpResponse.getEntity();
10:				xml = EntityUtils.toString(httpEntity);

Read More

47:			// Making HTTP Request
48:			try {
49:				HttpResponse response = httpClient.execute(httpPost);
50:	
51:				// writing response to log

Read More

See Code Examples for Android HttpResponse Methods: