0

I am using HTTPClient on my client app to send a GET request to my Jersey RESTful web service. what is the best way to track how many bytes have been received on the server side? should I make a web service call within my while loop below to notify the server after a certain certain number of bytes have been received up until it's finished?

InputStream inputStream = resp.getEntity().getContent();

byte data[] = new byte[8096];
int count;
int total = 0;

while ((count = inputStream.read(data, 0, 8096)) != -1) {
               //best way to notify server of received bytes?
}
Cœur
  • 37,241
  • 25
  • 195
  • 267
user1518485
  • 65
  • 3
  • 8

1 Answers1

0

Yes, that would be the way. But you should do it asynchronously (i.e. by notifying the server on a separate thread) so that you don't slow down the file reading by waiting for server's response to the progress notification.

Martin Matula
  • 7,969
  • 1
  • 31
  • 35