在WP8.1上,HttpWebRequest错误读取超过65536个字节

时间:2015-10-11 22:12:27

标签: c# windows-phone-8 windows-phone-8.1 httpwebrequest

以下代码从MJPEG视频流中读取字节。 它在Windows 8.1 Store应用程序上运行良好,但在Windows Phone 8.1应用程序中相同的代码失败。

读取65536字节方法"读取"不从流中读取更多字节。

On WP8.1 ONLY: cannot read more than 65536 bytes off an HTTP Stream

中的同样问题

有人告诉属性DefaultMaximumErrorResponseLength,但此属性仅在WPF中(不在Windows商店.net中)

WP8.1上的WebClient类也存在同样的问题。

(在On WP8.1 ONLY: cannot read more than 65536 bytes off an HTTP Stream中说WebClient没有这个问题,但它不是真的)

示例代码:

        var request = (HttpWebRequest)WebRequest.CreateHttp("http://webcam.st-malo.com/axis-cgi/mjpg/video.cgi?resolution=352x288");
        request.AllowReadStreamBuffering = false;
        request.BeginGetResponse(OnGetResponse, request);


    private void OnGetResponse(IAsyncResult asyncResult)
    {
        HttpWebRequest req = (HttpWebRequest)asyncResult.AsyncState;
            HttpWebResponse resp = (HttpWebResponse)req.EndGetResponse(asyncResult);
            Stream s = resp.GetResponseStream();
        byte[] buff = new byte[ChunkSize];
        int readed;
        do
        {
            readed = s.Read(buff, 0, ChunkSize);
        }
        while (readed > 0);
    }

0 个答案:

没有答案
相关问题