1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Threading.Tasks;
- namespace cuidian.OpenApi.Http
- {
- public class Response
- {
- public Response(HttpWebResponse resp)
- {
- this.HttpWebResponse = resp;
- }
- public HttpWebResponse HttpWebResponse { get; private set; }
-
-
-
-
- public string GetResponseAsString()
- {
- Encoding encoding = Encoding.GetEncoding(this.HttpWebResponse.CharacterSet);
- return this.GetResponseAsString(encoding);
- }
-
-
-
-
-
- public string GetResponseAsString(Encoding encoding)
- {
- System.IO.Stream stream = null;
- StreamReader reader = null;
- try
- {
-
- stream = this.HttpWebResponse.GetResponseStream();
- reader = new StreamReader(stream, encoding);
- return reader.ReadToEnd();
- }
- finally
- {
-
- if (reader != null) reader.Close();
- if (stream != null) stream.Close();
- if (this.HttpWebResponse != null) this.HttpWebResponse.Close();
- }
- }
- }
- }
|