I'm trying to establish a SSL connection to a site and return its full response back. For some reason no matter what SSL site I go to when I step through the code it seems like the first read grabs a chunk of data and all subsequent calls return 0. I did some research and it appears there are two cases you would get back an int value of 0 from a read:
1. The server is busy ,lag with internet,etc - I do not think this is the issue because the loop calls read for a good 60 seconds during that time always returns 0.
2. The ByteBuffers passed into read are full and therefore cannot be written to - When looking at buffer I added a capacity of 100000. This is well below the possible response being added. I can tell by the position that the buffer has plenty of room in it? This appears to be a problem with a number of sites I have tried so I know its not an isolated server issue. I was hoping someone could glance at my securesocket class see if you can see any blatant issue that I'm overlooking that could be causing the problem:
Most importantly the read command. I believe the establishing of the connection is working because i'm getting data back from server. It's just never the full response.
A few things I'm seeing:
my request to https://encrypted.google.com/ on first read returns the headers as seen below. Then I pass that data to the response handler that checks the response notices its not complete goes back and calls SecureSocket.read() again. All subsequent calls get a result of 0 back but I know there is more content maybe the content of the response? I'm just perplexed as to what I'm doing wrong.
In other sites I get even more of the response but never seems to get everything. In most cases after initial read everything is 0.