#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    7
    Rep Power
    0

    Connection close response in HttpURLConnection


    I'm working on code using HttpURLConnection to a web server and one web page that logs off from the web server sends a POST to the web server and I get an http 200 back, but the header "Connection" says "close" and the Content-Length has a value > 0 .. but I don't get any data from trying to read from the HttpURLConnection.getInputStream() ... and I think thats becuase the connection is closed.

    When I watch this http request/response using HttpFox .. i see all the same values as above, except the Content tab in HttpFox shows basically the html web page I want to display to the end user.

    So I am trying to figure out what I need to access on the HttpURLConnection to get to that data that HttpFox is showing in the Content tab ..

    There is the inherited URLConnection.getContent() method but that returns an object of type sun.net.www.protocol.http.HttpURLConnection$HttpInputStream and I don;t seem to be able to import that correctly to get eclipse to recognize it .. and dunno if this is barking up the wrong tree ....
  2. #2
  3. Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    May 2004
    Location
    Superior, CO, USA
    Posts
    2,418
    Rep Power
    1712
    The "Connection: close" HTTP header indicates what is supposed to happen after you've read the data. If the Content-Length header is greater than zero then you should be getting data back.

    Can you post your code to see if we can figure out what's up?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    7
    Rep Power
    0
    Originally Posted by stdunbar
    The "Connection: close" HTTP header indicates what is supposed to happen after you've read the data. If the Content-Length header is greater than zero then you should be getting data back.

    Can you post your code to see if we can figure out what's up?
    Unfortunately I can't post the code unless just snippets are ok ... suffice to say there are lots of other GETS, POSTS, PUTS, and DELETES that are processed fine ... I temp put in code to try to read from the HttpURLConnection.getInputStream() right after sending the POST to the server, before even reading response headers .. no luck .. all the other page interactions work to get the data from the getInputStream() fine ..

IMN logo majestic logo threadwatch logo seochat tools logo