当前位置: 首页>>代码示例>>C#>>正文


C# WebResponse.GetResponseStream方法代码示例

本文整理汇总了C#中System.Net.WebResponse.GetResponseStream方法的典型用法代码示例。如果您正苦于以下问题:C# WebResponse.GetResponseStream方法的具体用法?C# WebResponse.GetResponseStream怎么用?C# WebResponse.GetResponseStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Net.WebResponse的用法示例。


在下文中一共展示了WebResponse.GetResponseStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Creat

 public Stream Creat()
 {
     WebRequest inquiry = WebRequest.Create("http://api.lod-misis.ru/testassignment");
     Answer = inquiry.GetResponse();
     Stream stream = Answer.GetResponseStream();
     return stream;
 }
开发者ID:Aren97,项目名称:MISIS,代码行数:7,代码来源:Program.cs

示例2: GetResponseStream

        /// <summary>
        /// Determines whether response is gzipped and invokes platform specific decompression if necessary
        /// </summary>
        /// <param name="response">The web response</param>
        /// <returns>The response stream</returns>
        public Stream GetResponseStream(WebResponse response)
        {
            bool gzipped = false;
            if (response.Headers != null && response.Headers.Count > 0)
            {
                var headerEncoding = response.Headers["Content-Encoding"];
                gzipped = headerEncoding != null && headerEncoding.IndexOf("gzip", StringComparison.OrdinalIgnoreCase) > -1;
            }

            return gzipped ?
                new GZipStream(response.GetResponseStream(), CompressionMode.Decompress)
                : response.GetResponseStream();
        }
开发者ID:NaveenSelvaraj,项目名称:wp-api-client,代码行数:18,代码来源:GzipHandlerWin8.cs

示例3: GetResponse

 public GetResponse(WebResponse response)
     : base(response)
 {
     SortedList metadata = extractMetadata( response );
     byte [] data = Utils.slurpInputStream( response.GetResponseStream() );
     this.obj = new S3Object( data, metadata );
 }
开发者ID:davelondon,项目名称:dontstayin,代码行数:7,代码来源:GetResponse.cs

示例4: ConvertWebResponseToByteArray

        public static byte[] ConvertWebResponseToByteArray(WebResponse res)
        {
            BinaryReader br = new BinaryReader(res.GetResponseStream());

            // Download and buffer the binary stream into a memory stream
            MemoryStream stm = new MemoryStream();
            int pos = 0;
            int maxread = BufferSize;
            while (true)
            {
                byte[] content = br.ReadBytes(maxread);
                if (content.Length <= 0)
                    break;

                if (content.Length < maxread)
                    maxread = maxread - content.Length;

                stm.Write(content, 0, content.Length);
                pos += content.Length;
            }

            br.Close();
            stm.Position = 0;
            byte[] final = new byte[(int)stm.Length];
            stm.Read(final, 0, final.Length);
            stm.Close();
            return final;
        }
开发者ID:nothingmn,项目名称:robchartier-classlibrary,代码行数:28,代码来源:Web.cs

示例5: ReadResponse

		private static string ReadResponse(WebResponse response) {
			using(var readStream = new StreamReader(response.GetResponseStream(),System.Text.Encoding.UTF8)) {
				var output = readStream.ReadToEnd();

				return output;
			}
		}
开发者ID:santosh-mnrec,项目名称:AzurePlot,代码行数:7,代码来源:AzureManagementRestClient.cs

示例6: ParseToRows

 public virtual ParsedCSVFile ParseToRows(WebResponse response)
 {
     using (var reader = new CsvReader(new StreamReader(response.GetResponseStream()), true))
     {
         return new ParsedCSVFile(GetRows(reader).ToArray(), reader.GetFieldHeaders().Select(StringExtensions.RemoveWhitespace).ToArray());
     }
 }
开发者ID:haithemaraissia,项目名称:yahoo_stock_quotes,代码行数:7,代码来源:CsvResponseParser.cs

示例7: strtBtn_Click

 private void strtBtn_Click(object sender, EventArgs e)
 {
     requestPicStreet = WebRequest.Create("http://maps.googleapis.com/maps/api/streetview?location=" + address + "&heading=" + heading.ToString() + "&zoom=12&size=453x267&sensor=false");
     repsonsePicStreet = requestPicStreet.GetResponse();
     mapStreet = Image.FromStream(repsonsePicStreet.GetResponseStream());
     pictureBox2.Image = mapStreet;
 }
开发者ID:ZenunVee,项目名称:GoogleMap,代码行数:7,代码来源:Form1.cs

示例8: DownloadFile

 /// <summary>
 /// 下载Response的文件流数据
 /// </summary>
 /// <param name="response">response</param>
 private void DownloadFile(WebResponse response)
 {
     if (response == null) return;
     try
     {
         var context = HttpContext.Current;
         using (var iStream = response.GetResponseStream())
         {
             byte[] buffer = new byte[AppConst.ChunkSize];
             int readDataLen = 0;
             context.Response.ContentType = response.ContentType;
             context.Response.AddHeader("Content-Disposition", response.Headers["Content-Disposition"]);
             readDataLen = iStream.Read(buffer, 0, AppConst.ChunkSize);
             while (readDataLen > 0 && context.Response.IsClientConnected)
             {
                 context.Response.OutputStream.Write(buffer, 0, readDataLen);
                 context.Response.Flush();
                 try
                 {
                     readDataLen = iStream.Read(buffer, 0, AppConst.ChunkSize);
                 }
                 catch
                 {
                     break;
                 }
             }
             context.Response.Close();
         }
     }
     finally
     {
         response.Close();
     }
 }
开发者ID:felix-tien,项目名称:TechLab,代码行数:38,代码来源:NetAccess.cs

示例9: Post

 private static Stream Post(string url, string postData, out WebResponse response)
 {
     // Create a request using a URL that can receive a post.
     WebRequest request = WebRequest.Create(url);
     // Set the Method property of the request to POST.
     request.Method = "POST";
     // Create POST data and convert it to a byte array.
     byte[] byteArray = Encoding.UTF8.GetBytes(postData);
     // Set the ContentType property of the WebRequest.
     request.ContentType = "application/json";
     // Set the ContentLength property of the WebRequest.
     request.ContentLength = byteArray.Length;
     // Get the request stream.
     Stream dataStream = request.GetRequestStream();
     // Write the data to the request stream.
     dataStream.Write(byteArray, 0, byteArray.Length);
     // Close the Stream object.
     dataStream.Close();
     // Get the response.
     response = request.GetResponse();
     // Display the status.
     //Console.WriteLine(((HttpWebResponse)response).StatusDescription);
     // Get the stream containing content returned by the server.
     dataStream = response.GetResponseStream();
     return dataStream;
 }
开发者ID:torero-vlg,项目名称:market-3d,代码行数:26,代码来源:HttpTools.cs

示例10: staticBtn_Click

 private void staticBtn_Click(object sender, EventArgs e)
 {
     requestPicStatic = WebRequest.Create("http://maps.googleapis.com/maps/api/staticmap?center=" + address + "&zoom=" + zoom + "&size=353x267&sensor=false");
     repsonsePicStatic = requestPicStatic.GetResponse();
     mapStatic = Image.FromStream(repsonsePicStatic.GetResponseStream());
     pictureBox1.Image = mapStatic;
 }
开发者ID:ZenunVee,项目名称:GoogleMap,代码行数:7,代码来源:Form1.cs

示例11: OAuthTokenResponse

        public OAuthTokenResponse(WebResponse httpWebResponse)
        {
            using (var stream = httpWebResponse.GetResponseStream())
            {
                var reader = new StreamReader(stream);
                ResponseBody = reader.ReadToEnd();
                reader.Close();
            }

            if (string.IsNullOrEmpty(ResponseBody))
            {
                return;
            }

            Items = new NameValueCollection();

            foreach (string item in ResponseBody.Split('&'))
            {
                if (item.IndexOf('=') > -1)
                {
                    string[] temp = item.Split('=');
                    Items.Add(temp[0], temp[1]);
                }
                else
                {
                    Items.Add(item, string.Empty);
                }
            }

            Token = new OAuthToken() { Token = Items["oauth_token"], TokenSecret = Items["oauth_token_secret"] };
        }
开发者ID:JhonatanSteven,项目名称:oauth-mvc.net,代码行数:31,代码来源:OAuthTokenResponse.cs

示例12: ReadData

        private static string ReadData(WebResponse response)
        {
            Stream resStream = response.GetResponseStream();

            var buf = new byte[8192];
            var sb = new StringBuilder();
            string tempString = null;
            int count = 0;

            do
            {
                // fill the buffer with data
                count = resStream.Read(buf, 0, buf.Length);

                // make sure we read some data
                if (count != 0)
                {
                    // translate from bytes to ASCII text
                    tempString = Encoding.ASCII.GetString(buf, 0, count);

                    // continue building the string
                    sb.Append(tempString);
                }
            } while (count > 0); // any more data to read?
            return sb.ToString();
        }
开发者ID:rslijp,项目名称:sharptiles,代码行数:26,代码来源:Import.cs

示例13: ListAllMyBucketsResponse

        public ListAllMyBucketsResponse( WebResponse response )
            : base(response)
        {
            buckets = new ArrayList();
            string rawBucketXML = Utils.slurpInputStreamAsString( response.GetResponseStream() );

            XmlDocument doc = new XmlDocument();
            doc.LoadXml( rawBucketXML );
            foreach (XmlNode node in doc.ChildNodes)
            {
                if (node.Name.Equals("ListAllMyBucketsResult"))
                {
                    foreach (XmlNode child in node.ChildNodes)
                    {
                        if (child.Name.Equals("Owner"))
                        {
                            owner = new Owner(child);
                        }
                        else if (child.Name.Equals("Buckets"))
                        {
                            foreach (XmlNode bucket in child.ChildNodes)
                            {
                                if (bucket.Name.Equals("Bucket"))
                                {
                                    buckets.Add(new Bucket(bucket));
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:davelondon,项目名称:dontstayin,代码行数:32,代码来源:ListAllMyBucketsResponse.cs

示例14: saveBinaryFile

 private static bool saveBinaryFile(WebResponse response, string savePath)
 {
     bool value = false;
     byte[] buffer = new byte[1024];
     Stream outStream = null;
     Stream inStream = null;
     try
     {
         if (File.Exists(savePath)) File.Delete(savePath);
         outStream = System.IO.File.Create(savePath);
         inStream = response.GetResponseStream();
         int l;
         do
         {
             l = inStream.Read(buffer, 0, buffer.Length);
             if (l > 0) outStream.Write(buffer, 0, l);
         } while (l > 0);
         value = true;
     }
     finally
     {
         if (outStream != null) outStream.Close();
         if (inStream != null) inStream.Close();
     }
     return value;
 }
开发者ID:carriercomm,项目名称:ZeusMud,代码行数:26,代码来源:HttpPictureDownloader.cs

示例15: GravatarProfile

 internal GravatarProfile(WebResponse webResponse)
 {
     using (var responseStream = webResponse.GetResponseStream())
         if (responseStream != null)
             using (var reader = new StreamReader(responseStream))
                 LoadFromXml(reader.ReadToEnd());
 }
开发者ID:RogerioCaroco,项目名称:Gravatar-Outlook-Adapter,代码行数:7,代码来源:GravatarProfile.cs


注:本文中的System.Net.WebResponse.GetResponseStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。