Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6769797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:14:09+00:00 2026-05-26T15:14:09+00:00

I run SAME code on my PC (windows 7 64 bit, Eclipse, Java) and

  • 0

I run SAME code on my PC (windows 7 64 bit, Eclipse, Java) and on a Android Virtual Machine and I get different results.

Its a small programm that shoult print me the HttpResponse fully as String.

Results on PC:

HTTP/1.1 405 Method Not Allowed [Allow: GET, HEAD, Date: Thu, 03 Nov 2011 17:57:22 GMT, Content-Type: text/html; charset=UTF-8, Server: gws, Content-Length: 11816, X-XSS-Protection: 1; mode=block, X-Frame-Options: SAMEORIGIN]

Result on Android:

org.apache.http.message.BasicHttpResponse@44ec9da8

The code I ran on PC was:

HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(
            "http://www.google.com");

    try {
        HttpResponse response = httpclient.execute(httppost);
        System.out.println(response.toString());

And on Android:

HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(
            "http://www.google.com");

    try {
        HttpResponse response = httpclient.execute(httppost);
        return response.toString();

Im asking becasue I wrote a App that would work on PC – works with the HttpResponse content – but on android it seems that is has NO content at all…

Could anyone please explain me this? Or tell me how to get the response content (headers) as String on android?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:14:10+00:00Added an answer on May 26, 2026 at 3:14 pm

    You don’t actually run the same code.

    Android’s BasicHttpResponse currently has no toString() method at all and goes on to invoke java.lang.Object.toString() giving you fully.qualified.class.name@hashcode.

    Your desktop version of HttpClient most likely has a toString() similar to this one from HttpClient 4.1.3:

    public String toString() {
        return this.statusline + " " + this.headergroup;
    }
    

    Using toString() for any non-debugging/logging purposes isn’t good practice — you should extract the right information using actual get methods or just return the HttpResponse itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a problem with a bit of code on one windows machine
Can I run ASP.NET 2.0 and 3.5 code on the same website? ...or, do
I'm fairly new to java/eclipse development and I'm having a bit of a problem
Is there any way to run one same instance of JavaCcript(jQuery) on the server
What I'm trying to do is run the same SQL select on many Oracle
It appears m2eclipse is not recognizing my $M2_OPTS variable. I can run the same
I always run into the same problem when creating web pages. When I add
I've run into the same problem as found in this question . However, I
Is solr a web application that can run on the same instance as a
I have two scripts that often need to be run with the same parameter:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.