In .NetCF, upon trying to access the following URL:
via the following code:
WebRequest webReq = WebRequest.Crea te(url);
WebResponse webResp = webReq.GetRespo nse();
StreamReader sr = new StreamReader(we bResp.GetRespon seStream(),
Encoding.GetEnc oding("utf-8"));
char [] buffer = new char[1024];
int count = 0;
while ((count = sr.Read(buffer, 0, buffer.Length)) > 0)
{
// do something
}
I get an exception when I try to sr.Read() - chunk size is invalid. I think
I traced it down to this: the ContentLength of the webResp object is -1. If
I try this with other web sites that return a Content-Length header, it
works fine.
Is there a way to have the Reading of the stream not depend on this ? I'd
figure that the library would be forgiving about this, since not every web
application knows the length of the content before sending it out.
Any responses appreciated.
Thanks,
Jay
via the following code:
WebRequest webReq = WebRequest.Crea te(url);
WebResponse webResp = webReq.GetRespo nse();
StreamReader sr = new StreamReader(we bResp.GetRespon seStream(),
Encoding.GetEnc oding("utf-8"));
char [] buffer = new char[1024];
int count = 0;
while ((count = sr.Read(buffer, 0, buffer.Length)) > 0)
{
// do something
}
I get an exception when I try to sr.Read() - chunk size is invalid. I think
I traced it down to this: the ContentLength of the webResp object is -1. If
I try this with other web sites that return a Content-Length header, it
works fine.
Is there a way to have the Reading of the stream not depend on this ? I'd
figure that the library would be forgiving about this, since not every web
application knows the length of the content before sending it out.
Any responses appreciated.
Thanks,
Jay
Comment