January 29th, 2013, 08:05 AM
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 ....
January 29th, 2013, 02:17 PM
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?
January 29th, 2013, 06:54 PM
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 ..
Originally Posted by stdunbar