14 [global::__DynamicallyInvokable]
19 private KnownHttpVerb m_Verb;
23 private string m_StatusDescription;
25 private Stream m_ConnectStream;
27 private CoreResponseData m_CoreResponseData;
31 private long m_ContentLength;
33 private string m_MediaType;
35 private string m_CharacterSet;
37 private bool m_IsVersionHttp11;
43 private bool m_disposed;
45 private bool m_propertiesDisposed;
47 private bool m_UsesProxySemantics;
49 private bool m_IsMutuallyAuthenticated;
51 private bool m_IsWebSocketResponse;
53 private string m_ConnectionGroupName;
55 private Stream m_WebSocketConnectionStream;
57 internal bool IsWebSocketResponse
61 return m_IsWebSocketResponse;
65 m_IsWebSocketResponse = value;
69 internal string ConnectionGroupName
73 return m_ConnectionGroupName;
77 m_ConnectionGroupName = value;
81 internal Stream ResponseStream
85 return m_ConnectStream;
89 m_ConnectStream = value;
93 internal CoreResponseData CoreResponseData => m_CoreResponseData;
103 return m_IsMutuallyAuthenticated;
107 internal bool InternalSetIsMutuallyAuthenticated
111 m_IsMutuallyAuthenticated = value;
118 [global::__DynamicallyInvokable]
119 public virtual CookieCollection
Cookies 121 [global::__DynamicallyInvokable]
125 if (m_cookies ==
null)
141 [global::__DynamicallyInvokable]
144 [global::__DynamicallyInvokable]
148 return m_HttpResponseHeaders;
155 [global::__DynamicallyInvokable]
158 [global::__DynamicallyInvokable]
168 [global::__DynamicallyInvokable]
171 [global::__DynamicallyInvokable]
175 return m_ContentLength;
187 string text = m_HttpResponseHeaders[
"Content-Encoding"];
199 [global::__DynamicallyInvokable]
202 [global::__DynamicallyInvokable]
206 string contentType = m_HttpResponseHeaders.ContentType;
207 if (contentType !=
null)
223 string contentType = m_HttpResponseHeaders.ContentType;
224 if (m_CharacterSet ==
null && !ValidationHelper.IsBlankString(contentType))
226 m_CharacterSet =
string.Empty;
228 if (text.Trim().StartsWith(
"text/"))
230 m_CharacterSet =
"ISO-8859-1";
232 int i = text.IndexOf(
";");
235 while ((i = text.IndexOf(
"charset", i)) >= 0)
238 if (text[i - 8] !=
';' && text[i - 8] !=
' ')
242 for (; i < text.Length && text[i] ==
' '; i++)
245 if (i < text.Length - 1 && text[i] ==
'=')
248 int num = text.IndexOf(
';', i);
251 m_CharacterSet = contentType.Substring(i, num - i).Trim();
255 m_CharacterSet = contentType.Substring(i).Trim();
262 return m_CharacterSet;
274 string server = m_HttpResponseHeaders.Server;
291 string lastModified = m_HttpResponseHeaders.LastModified;
292 if (lastModified ==
null)
296 return HttpProtocolUtils.string2date(lastModified);
303 [global::__DynamicallyInvokable]
306 [global::__DynamicallyInvokable]
317 [global::__DynamicallyInvokable]
320 [global::__DynamicallyInvokable]
324 return m_StatusDescription;
336 if (!m_IsVersionHttp11)
344 internal bool KeepAlive
348 if (m_UsesProxySemantics)
350 string text =
Headers[
"Proxy-Connection"];
360 string text2 =
Headers[
"Connection"];
369 return text2.IndexOf(
"keep-alive") >= 0;
375 if (text2 !=
null && text2.IndexOf(
"close") >= 0)
377 return text2.IndexOf(
"keep-alive") >= 0;
388 [global::__DynamicallyInvokable]
391 [global::__DynamicallyInvokable]
402 [global::__DynamicallyInvokable]
403 public virtual string Method 405 [global::__DynamicallyInvokable]
417 [global::__DynamicallyInvokable]
422 Logging.Enter(Logging.Web,
this,
"GetResponseStream",
"");
427 Logging.PrintInfo(Logging.Web,
"ContentLength=" + m_ContentLength);
430 if (m_IsWebSocketResponse && m_StatusCode ==
HttpStatusCode.SwitchingProtocols)
432 if (m_WebSocketConnectionStream ==
null)
434 ConnectStream connectStream = m_ConnectStream as ConnectStream;
435 m_WebSocketConnectionStream =
new WebSocketConnectionStream(connectStream, ConnectionGroupName);
437 stream = m_WebSocketConnectionStream;
441 stream = m_ConnectStream;
445 Logging.Exit(Logging.Web,
this,
"GetResponseStream", stream);
455 Logging.Enter(Logging.Web,
this,
"Close",
"");
462 Stream connectStream = m_ConnectStream;
463 ICloseEx closeEx = connectStream as ICloseEx;
466 closeEx.CloseEx(CloseExState.Normal);
470 connectStream?.
Close();
475 if (IsWebSocketResponse)
477 ConnectStream connectStream2 = m_ConnectStream as ConnectStream;
478 if (connectStream2 !=
null && connectStream2.Connection !=
null)
480 connectStream2.Connection.ServicePoint.CloseConnectionGroup(ConnectionGroupName);
487 Logging.Exit(Logging.Web,
this,
"Close",
"");
491 internal void Abort()
493 Stream connectStream = m_ConnectStream;
494 ICloseEx closeEx = connectStream as ICloseEx;
499 closeEx.CloseEx(CloseExState.Abort);
503 connectStream?.
Close();
514 [global::__DynamicallyInvokable]
515 protected override void Dispose(
bool disposing)
519 base.Dispose(disposing:
true);
520 m_propertiesDisposed =
true;
525 [Obsolete(
"This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.",
true)]
531 internal HttpWebResponse(
Uri responseUri, KnownHttpVerb verb, CoreResponseData coreData,
string mediaType,
bool usesProxySemantics,
DecompressionMethods decompressionMethod,
bool isWebSocketResponse,
string connectionGroupName)
535 m_MediaType = mediaType;
536 m_UsesProxySemantics = usesProxySemantics;
537 m_CoreResponseData = coreData;
538 m_ConnectStream = coreData.m_ConnectStream;
539 m_HttpResponseHeaders = coreData.m_ResponseHeaders;
540 m_ContentLength = coreData.m_ContentLength;
541 m_StatusCode = coreData.m_StatusCode;
542 m_StatusDescription = coreData.m_StatusDescription;
543 m_IsVersionHttp11 = coreData.m_IsVersionHttp11;
544 m_IsWebSocketResponse = isWebSocketResponse;
545 m_ConnectionGroupName = connectionGroupName;
546 if (m_ContentLength == 0L && m_ConnectStream is ConnectStream)
548 ((ConnectStream)m_ConnectStream).CallDone();
550 string text = m_HttpResponseHeaders[
"Content-Location"];
555 m_Uri =
new Uri(m_Uri, text);
557 catch (UriFormatException)
565 string text2 = m_HttpResponseHeaders[
"Content-Encoding"];
570 m_ConnectStream =
new GZipWrapperStream(m_ConnectStream,
CompressionMode.Decompress);
571 m_ContentLength = -1
L;
572 m_HttpResponseHeaders[
"Content-Encoding"] =
null;
576 m_ConnectStream =
new DeflateWrapperStream(m_ConnectStream,
CompressionMode.Decompress);
577 m_ContentLength = -1
L;
578 m_HttpResponseHeaders[
"Content-Encoding"] =
null;
586 [Obsolete(
"Serialization is obsoleted for this type. http://go.microsoft.com/fwlink/?linkid=14202")]
588 : base(serializationInfo, streamingContext)
596 m_ContentLength = serializationInfo.
GetInt64(
"m_ContentLength");
597 m_Verb = KnownHttpVerb.Parse(serializationInfo.
GetString(
"m_Verb"));
598 m_StatusDescription = serializationInfo.
GetString(
"m_StatusDescription");
599 m_MediaType = serializationInfo.
GetString(
"m_MediaType");
608 GetObjectData(serializationInfo, streamingContext);
618 serializationInfo.
AddValue(
"m_Uri", m_Uri, typeof(
Uri));
621 serializationInfo.
AddValue(
"m_StatusCode", m_StatusCode);
622 serializationInfo.
AddValue(
"m_ContentLength", m_ContentLength);
623 serializationInfo.
AddValue(
"m_Verb", m_Verb.Name);
624 serializationInfo.
AddValue(
"m_StatusDescription", m_StatusDescription);
625 serializationInfo.
AddValue(
"m_MediaType", m_MediaType);
626 base.GetObjectData(serializationInfo, streamingContext);
636 string text = m_HttpResponseHeaders[headerName];
644 private void CheckDisposed()
646 if (m_propertiesDisposed)
override bool SupportsHeaders
Gets a value that indicates if headers are supported.
static CultureInfo InvariantCulture
Gets the T:System.Globalization.CultureInfo object that is culture-independent (invariant).
virtual string Method
Gets the method that is used to return the response.
override void Dispose(bool disposing)
Releases the unmanaged resources used by the T:System.Net.HttpWebResponse, and optionally disposes of...
Describes a set of security permissions applied to code. This class cannot be inherited.
static readonly Version Version11
Defines a T:System.Version instance for HTTP 1.1.
long GetInt64(string name)
Retrieves a 64-bit signed integer value from the T:System.Runtime.Serialization.SerializationInfo sto...
DecompressionMethods
Represents the file compression and decompression encoding format to be used to compress the data rec...
override Uri ResponseUri
Gets the URI of the Internet resource that responded to the request.
HttpWebResponse()
Initializes a new instance of the T:System.Net.HttpWebResponse class.
StringComparison
Specifies the culture, case, and sort rules to be used by certain overloads of the M:System....
string ContentEncoding
Gets the method that is used to encode the body of the response.
EditorBrowsableState
Specifies the browsable state of a property or method from within an editor.
Provides a collection container for instances of the T:System.Net.Cookie class.
override bool Equals(object obj)
Returns a value indicating whether the current T:System.Version object is equal to a specified object...
override void Close()
Closes the response stream.
CompressionMode
Specifies whether to compress or decompress the underlying stream.
Represents an instant in time, typically expressed as a date and time of day. To browse the ....
Defines the HTTP version numbers that are supported by the T:System.Net.HttpWebRequest and T:System....
HttpStatusCode
Contains the values of status codes defined for HTTP.
string CharacterSet
Gets the character set of the response.
Describes the source and destination of a given serialized stream, and provides an additional caller-...
DateTime LastModified
Gets the last date and time that the contents of the response were modified.
override long ContentLength
Gets the length of the content returned by the request.
The exception that is thrown when an operation is performed on a disposed object.
SecurityAction
Specifies the security actions that can be performed using declarative security.
virtual void Close()
Closes the current stream and releases any resources (such as sockets and file handles) associated wi...
Provides a response from a Uniform Resource Identifier (URI). This is an abstract class.
void AddValue(string name, object value, Type type)
Adds a value into the T:System.Runtime.Serialization.SerializationInfo store, where value is associa...
static readonly Version Version10
Defines a T:System.Version instance for HTTP 1.0.
Version ProtocolVersion
Gets the version of the HTTP protocol that is used in the response.
override WebHeaderCollection Headers
Gets the headers that are associated with this response from the server.
override void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
Populates a T:System.Runtime.Serialization.SerializationInfo with the data needed to serialize the ta...
override string ContentType
Gets the content type of the response.
string GetResponseHeader(string headerName)
Gets the contents of a header that was returned with the response.
Represents the version number of an assembly, operating system, or the common language runtime....
virtual HttpStatusCode StatusCode
Gets the status of the response.
Provides an HTTP-specific implementation of the T:System.Net.WebResponse class.
virtual string StatusDescription
Gets the status description returned with the response.
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
Allows an object to control its own serialization and deserialization.
string Server
Gets the name of the server that sent the response.
string GetString(string name)
Retrieves a T:System.String value from the T:System.Runtime.Serialization.SerializationInfo store.
object GetValue(string name, Type type)
Retrieves a value from the T:System.Runtime.Serialization.SerializationInfo store.
Specifies that the class can be serialized.
static DateTime Now
Gets a T:System.DateTime object that is set to the current date and time on this computer,...
int GetInt32(string name)
Retrieves a 32-bit signed integer value from the T:System.Runtime.Serialization.SerializationInfo sto...
virtual CookieCollection Cookies
Gets or sets the cookies that are associated with this response.
Provides information about a specific culture (called a locale for unmanaged code development)....
SecurityPermissionFlag
Specifies access flags for the security permission object.
Provides an object representation of a uniform resource identifier (URI) and easy access to the parts...
HttpWebResponse(SerializationInfo serializationInfo, StreamingContext streamingContext)
Initializes a new instance of the T:System.Net.HttpWebResponse class from the specified T:System....
override bool IsMutuallyAuthenticated
Gets a T:System.Boolean value that indicates whether both client and server were authenticated.
void GetObjectData(SerializationInfo info, StreamingContext context)
Populates a T:System.Runtime.Serialization.SerializationInfo with the data needed to serialize the ta...
Provides methods that help you use X.509 v.3 certificates.
override Stream GetResponseStream()
Gets the stream that is used to read the body of the response from the server.
Provides a generic view of a sequence of bytes. This is an abstract class.To browse the ....