Connecting Tech Pros Worldwide Forums | Help | Site Map

httpwebresponse , how to kno if contents are received completely?

Member
 
Join Date: Oct 2008
Posts: 42
#1: Nov 7 '08
hi all..
can any one help me to kno whether i have received the response stream completely...

below are the code that i'm using... but i'm not able to receive data completely.. some datas are missing...
i'm not using thread here... is it the reason why i'm not able to..

Expand|Select|Wrap|Line Numbers
  1. HttpWebResponse response = (HttpWebResponse)oWebReq.GetResponse();
  2.  
  3.             byte[] resBytes = new byte[response.ContentLength];
  4.             Stream resstream = response.GetResponseStream();
  5.             resstream.Read(resBytes,0,resBytes.Length);
  6.  
  7.             response.Close();

Newbie
 
Join Date: Oct 2008
Posts: 8
#2: Nov 7 '08

re: httpwebresponse , how to kno if contents are received completely?


The only way is by checking the content-length response header at least the response is chunked. If the content-type is chunked the content-length is useless, you sould parse the body line by line, the first tell the lenght of the chunk, then cames the data and then another line telling you the next length until the length is 0.

Normally the response is not chunked but it will in many cellphones if you use the flush opeartion.

Regards:
Harold.
Reply