C# 0 The Complete Reference


PART II C h a p t e r   2 5



Download 4,07 Mb.
Pdf ko'rish
bet1035/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   1031   1032   1033   1034   1035   1036   1037   1038   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART II

C h a p t e r   2 5 :  

N e t w o r k i n g   T h r o u g h   t h e   I n t e r n e t   U s i n g   S y s t e m . N e t    

835


The following program displays headers associated with McGraw-Hill.com:

// Examine the headers.

using System;

using System.Net;

Property

Description

public string CharacterSet { get; }

Obtains the name of the character set being used.

public string ContentEncoding { get; }

Obtains the name of the encoding scheme.

public long ContentLength { get; }

Obtains the length of the content being received. This 

will be –1 if the content length is not available.

public string ContentType { get; }

Obtains a description of the content.

public CookieCollection

     Cookies { get; set; } 

Obtains or sets a list of the cookies attached to the 

response.

public WebHeaderCollection

    Headers{ get; }

Obtains a collection of the headers attached to the 

response.

public bool IsFromCache { get; }

If the response came from the cache, this proper ty is 

true. It is false if the response was delivered over the 

network.

public bool

    IsMutuallyAuthenticated { get; }

If the client and ser ver are both authenticated, then 

this proper ty is true. It is false other wise. 

public DateTime LastModified { get; }

Obtains the time at which the resource was last 

changed.


public string Method { get; }

Obtains a string that specifies the response method.

public Version ProtocolVersion { get; }

Obtains a 

Version

 object that describes the version of 

HTTP used in the transaction.

public Uri ReponseUri { get; }

Obtains the URI that generated the response. This 

may differ from the one requested if the response 

was redirected to another URI.

public string Ser ver { get; }

Obtains a string that represents the name of the 

ser ver.


public HttpStatusCode StatusCode { get; }

Obtains an 

HttpStatusCode

 object that describes the 

status of the transaction.

public string StatusDescription { get; }

Obtains a string that represents the status of the 

transaction in a human-readable form.

T

ABLE


 25-5 

The Proper ties Defi ned by 

HttpWebResponse

www.freepdf-books.com




836

 

P a r t   I I :  



E x p l o r i n g   t h e   C #   L i b r a r y

class HeaderDemo {

  static void Main() {

    // Create a WebRequest to a URI.

    HttpWebRequest req = (HttpWebRequest)

           WebRequest.Create("http://www.McGraw-Hill.com");

    // Send that request and return the response.

    HttpWebResponse resp = (HttpWebResponse)

           req.GetResponse();

    // Obtain a list of the names.

    string[] names = resp.Headers.AllKeys;

    // Display the header name/value pairs.

    Console.WriteLine("{0,-20}{1}\n", "Name", "Value");

    foreach(string n in names) {

      Console.Write("{0,-20}", n);

      foreach(string v in resp.Headers.GetValues(n))

        Console.WriteLine(v);

    }


    // Close the response.

    resp.Close();

  }

}

Here is the output that was produced. (Remember, all header information is subject to 



change, so the precise output that you see may differ.)

Name                Value

Transfer-encoding   chunked

Content-Type        text/html

Date                Fri, 27 Jun 2008 20:32:06 GMT

Server              Sun-ONE-Web-Server/6.1




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   1031   1032   1033   1034   1035   1036   1037   1038   ...   1096




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish