Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem reading the HttpConection response in some devices

 
Hernan Nobile
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody,

I am having a strange problem when trying to read the response of an HTTPConnection object. The scenario is this:

1) App in the cellphone connects via HTTP to a webpage
2) The webpage adds some text to the response
3) The app in the cellphone tries to get all the text embedded in the HTTP Response.

If I try the code using emulators or some devices ( like motorola devices ) everything works perfect, but when trying with a live Sony Ericsson W200i I cannot read more than 57 bytes
of the response. Here is the sample code:



In the emulator the result is 70 bytes total, 40 bytes in the first read and 30 bytes in the second read.
In the real device the result is 70 bytes total too, but 40 bytes in the first read and only 17 bytes in the second read!!!
I've tried a dozen ways of reading the response buffer (in a loop, by chunks, in one step all togheter, etc.) and always read only 57 bytes.
Any idea???

Thanks!
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The logic makes sense, if it runs in the simulator but not in the device I think it is a matter for the vendor.
 
Rashid Mayes
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To make sure I understand every you tried;

You did try reading from the stream in a while loop, similar to the code below?



If not give it a try.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic