ChobiQ.DoubanFMAPICodePack.ConnectionManager.GetResponseStream C# (CSharp) Method

GetResponseStream() public static method

public static GetResponseStream ( string requestUri, FormData data ) : Stream
requestUri string
data FormData
return Stream
        public static Stream GetResponseStream(string requestUri,
            FormData data)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
                "http://www.douban.com" + requestUri
                + "?" + data.GetFormString());
            request.Method = "GET";
            request.ProtocolVersion = HttpVersion.Version11;

            request.UserAgent = "Mozilla/5.0 (Windows NT 6.1) "
                + "AppleWebKit/535.19 "
                + "(KHTML, like Gecko) Chrome/18.0.1025.151 Safari/535.19";

            request.ContentType = "application/x-www-form-urlencoded";
            request.Accept = "application/json, text/javascript, */*; q=0.01";
            request.KeepAlive = true;

            request.CookieContainer = s_cookies;

            return request.GetResponse().GetResponseStream();
        }

Usage Example

        public PlaylistResponse GetResponse()
        {
            PlaylistRequestForm form = new PlaylistRequestForm(this);

            if (Operation == PlayOperation.PlaysToEnd ||
                Operation == PlayOperation.Like ||
                Operation == PlayOperation.Unlike)
            {
                ConnectionManager.GetResponseStream(
                    ConnectionManager.PlaylistUri, form);

                return(null);
            }

            var jResp = ConnectionManager.GetResponse(
                ConnectionManager.PlaylistUri, form);

            return(new PlaylistResponse(jResp));
        }