The Labs \ Source Viewer \ SSCLI \ System.Net \ WebResponse

  1. //------------------------------------------------------------------------------
  2. // <copyright file="WebResponse.cs" company="Microsoft">
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. // </copyright>
  14. //------------------------------------------------------------------------------
  15. namespace System.Net
  16. {
  17.    
  18.     using System.Collections;
  19.     using System.IO;
  20.     using System.Runtime.Serialization;
  21.     using System.Security.Permissions;
  22.    
  23. /*++
  24.         WebResponse - The abstract base class for all WebResponse objects.
  25.     --*/   
  26.    
  27.     /// <devdoc>
  28.     /// <para>
  29.     /// A
  30.     /// response from a Uniform Resource Indentifier (Uri). This is an abstract class.
  31.     /// </para>
  32.     /// </devdoc>
  33.     [Serializable()]
  34.     public abstract class WebResponse : MarshalByRefObject, ISerializable, IDisposable
  35.     {
  36.         private bool m_IsCacheFresh;
  37.         private bool m_IsFromCache;
  38.        
  39.         /// <devdoc>
  40.         /// <para>Initializes a new
  41.         /// instance of the <see cref='System.Net.WebResponse'/>
  42.         /// class.</para>
  43.         /// </devdoc>
  44.         protected WebResponse()
  45.         {
  46.         }
  47.        
  48.         //
  49.         // ISerializable constructor
  50.         //
  51.         /// <devdoc>
  52.         /// <para>[To be supplied.]</para>
  53.         /// </devdoc>
  54.         protected WebResponse(SerializationInfo serializationInfo, StreamingContext streamingContext)
  55.         {
  56.         }
  57.        
  58.         //
  59.         // ISerializable method
  60.         //
  61.         /// <internalonly/>
  62.         [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter, SerializationFormatter = true)]
  63.         void ISerializable.GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
  64.         {
  65.             GetObjectData(serializationInfo, streamingContext);
  66.         }
  67.        
  68.         //
  69.         // FxCop: provide a way for derived classes to access this method even if they reimplement ISerializable.
  70.         //
  71.         [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)]
  72.         protected virtual void GetObjectData(SerializationInfo serializationInfo, StreamingContext streamingContext)
  73.         {
  74.         }
  75.        
  76.        
  77. /*++
  78.             Close - Closes the Response after the use.
  79.             This causes the read stream to be closed.
  80.         --*/       
  81.        
  82.         public virtual void Close()
  83.         {
  84.             throw ExceptionHelper.MethodNotImplementedException;
  85.         }
  86.        
  87.         /// <internalonly/>
  88.         void IDisposable.Dispose()
  89.         {
  90.             try {
  91.                 Close();
  92.                 OnDispose();
  93.             }
  94.             catch {
  95.             }
  96.         }
  97.        
  98.         internal virtual void OnDispose()
  99.         {
  100.         }
  101.        
  102.         public virtual bool IsFromCache {
  103.             get { return m_IsFromCache; }
  104.         }
  105.         internal bool InternalSetFromCache {
  106.             set { m_IsFromCache = value; }
  107.         }
  108.        
  109.         internal virtual bool IsCacheFresh {
  110.             get { return m_IsCacheFresh; }
  111.         }
  112.         internal bool InternalSetIsCacheFresh {
  113.             set { m_IsCacheFresh = value; }
  114.         }
  115.        
  116.         public virtual bool IsMutuallyAuthenticated {
  117.             get { return false; }
  118.         }
  119.        
  120.        
  121. /*++
  122.             ContentLength - Content length of response.
  123.             This property returns the content length of the response.
  124.         --*/       
  125.        
  126.         /// <devdoc>
  127.         /// <para>When overridden in a derived class, gets or
  128.         /// sets
  129.         /// the content length of data being received.</para>
  130.         /// </devdoc>
  131.         public virtual long ContentLength {
  132.             get {
  133.                 throw ExceptionHelper.PropertyNotImplementedException;
  134.             }
  135.             set {
  136.                 throw ExceptionHelper.PropertyNotImplementedException;
  137.             }
  138.         }
  139.        
  140.        
  141. /*++
  142.             ContentType - Content type of response.
  143.             This property returns the content type of the response.
  144.         --*/       
  145.        
  146.         /// <devdoc>
  147.         /// <para>When overridden in a derived class,
  148.         /// gets
  149.         /// or sets the content type of the data being received.</para>
  150.         /// </devdoc>
  151.         public virtual string ContentType {
  152.             get {
  153.                 throw ExceptionHelper.PropertyNotImplementedException;
  154.             }
  155.             set {
  156.                 throw ExceptionHelper.PropertyNotImplementedException;
  157.             }
  158.         }
  159.        
  160. /*++
  161.             ResponseStream  - Get the response stream for this response.
  162.             This property returns the response stream for this WebResponse.
  163.             Input: Nothing.
  164.             Returns: Response stream for response.
  165.                     read-only
  166.         --*/       
  167.        
  168.         /// <devdoc>
  169.         /// <para>When overridden in a derived class, returns the <see cref='System.IO.Stream'/> object used
  170.         /// for reading data from the resource referenced in the <see cref='System.Net.WebRequest'/>
  171.         /// object.</para>
  172.         /// </devdoc>
  173.         public virtual Stream GetResponseStream()
  174.         {
  175.             throw ExceptionHelper.MethodNotImplementedException;
  176.         }
  177.        
  178.        
  179. /*++
  180.             ResponseUri  - Gets the final Response Uri, that includes any
  181.             changes that may have transpired from the orginal request
  182.             This property returns Uri for this WebResponse.
  183.             Input: Nothing.
  184.             Returns: Response Uri for response.
  185.                     read-only
  186.         --*/       
  187.        
  188.         /// <devdoc>
  189.         /// <para>When overridden in a derived class, gets the Uri that
  190.         /// actually responded to the request.</para>
  191.         /// </devdoc>
  192.         public virtual Uri ResponseUri {
  193.             // read-only
  194.             get {
  195.                 throw ExceptionHelper.PropertyNotImplementedException;
  196.             }
  197.         }
  198.        
  199. /*++
  200.             Headers  - Gets any request specific headers associated
  201.             with this request, this is simply a name/value pair collection
  202.             Input: Nothing.
  203.             Returns: This property returns WebHeaderCollection.
  204.                     read-only
  205.         --*/       
  206.        
  207.         /// <devdoc>
  208.         /// <para>When overridden in a derived class, gets
  209.         /// a collection of header name-value pairs associated with this
  210.         /// request.</para>
  211.         /// </devdoc>
  212.         public virtual WebHeaderCollection Headers {
  213.             // read-only
  214.             get {
  215.                 throw ExceptionHelper.PropertyNotImplementedException;
  216.             }
  217.         }
  218.        
  219.     }
  220.     // class WebResponse
  221.    
  222. }
  223. // namespace System.Net

Developer Fusion