c# - HttpWebResponse difference between Headers and GetResponseHeader -


when i've got httpwebresponse object, there 2 ways access response headers:

string dateheader = webresponse.headers["date"]; string dateheader = webresponse.getresponseheader("date"); 

they both return same value, why there 2 ways obtain header information? looking @ .net sources, if found implementation both in httpwebreponse:

    // retreives response header object      /// <devdoc>     ///    <para>      ///       gets      ///       headers associated response server.     ///    </para>      /// </devdoc>     public override webheadercollection headers {         {             checkdisposed();              return m_httpresponseheaders;         }      }       /// <devdoc>     ///    <para>      ///       gets specified header value returned response.     ///    </para>      /// </devdoc>      public string getresponseheader( string headername ) {         checkdisposed();           string headervalue = m_httpresponseheaders[headername];          return ( (headervalue==null) ? string.empty : headervalue );      } 

only thing can see is, headers property can enumerate through availiable headers. ideas?

thanks!

according msdn library, headers property webheadercollection of headers. since collection, useful accessing multiple headers' names, values, or both. can access single header's value indicating name in header[<name>] format.

getresponseheader() on other hand, method returns value of single value only.

in summary, differences are:

  1. property vs method
  2. multiple header name and/or value access vs single header value access

Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -