c 如何获取服务器信息,C++ CHttpFile这个类如何获取服务器类型

C++ CHttpFile这个类怎么获取服务器类型

C++ CHttpFile这个类怎么获取服务器类型

如:

19154463.jpg

如:

19154464.jpg

各位帮帮忙啊...对于这个读取没有什么经验

我想获取他这个的类型,有没有什么好方法吗

------解决思路----------------------

CString GetServerInfo(LPCTSTR tszUrl)

{

CString strServer;

CInternetSession session;

CHttpFile *pHttpFile;

TRY

{

pHttpFile = (CHttpFile*)session.OpenURL(tszUrl);

pHttpFile->SendRequest();

pHttpFile->QueryInfo(HTTP_QUERY_SERVER, strServer);

pHttpFile->Close();

delete pHttpFile;

session.Close();

return strServer;

}

CATCH (CInternetException, e)

{

if (pHttpFile)

{

pHttpFile->Close();

delete pHttpFile;

}

session.Close();

return _T("");

}

END_CATCH

}

用法:

CString strServer = GetServerInfo(_T("http://www.csdn.net"));

MessageBox(NULL,  strServer,  L"Server",  MB_OK);

------解决思路----------------------

C:\Program Files\Microsoft Visual Studio\VC98\Include\WININET.H:

1852: //

1853: // HTTP

1854: //

1855:

1856: //

1857: // manifests

1858: //

1859:

1860: //

1861: // the default major/minor HTTP version numbers

1862: //

1863:

1864: #define HTTP_MAJOR_VERSION      1

1865: #define HTTP_MINOR_VERSION      0

1866:

1867: #define HTTP_VERSION            TEXT("HTTP/1.0")

1868:

1869: //

1870: // HttpQueryInfo info levels. Generally, there is one info level

1871: // for each potential RFC822/HTTP/MIME header that an HTTP server

1872: // may send as part of a request response.

1873: //

1874: // The HTTP_QUERY_RAW_HEADERS info level is provided for clients

1875: // that choose to perform their own header parsing.

1876: //

1877:

1878: #define HTTP_QUERY_MIME_VERSION                 0

1879: #define HTTP_QUERY_CONTENT_TYPE                 1

1880: #define HTTP_QUERY_CONTENT_TRANSFER_ENCODING    2

1881: #define HTTP_QUERY_CONTENT_ID                   3

1882: #define HTTP_QUERY_CONTENT_DESCRIPTION          4

1883: #define HTTP_QUERY_CONTENT_LENGTH               5

1884: #define HTTP_QUERY_CONTENT_LANGUAGE             6

1885: #define HTTP_QUERY_ALLOW                        7

1886: #define HTTP_QUERY_PUBLIC                       8

1887: #define HTTP_QUERY_DATE                         9

1888: #define HTTP_QUERY_EXPIRES                      10

1889: #define HTTP_QUERY_LAST_MODIFIED                11

1890: #define HTTP_QUERY_MESSAGE_ID                   12

1891: #define HTTP_QUERY_URI                          13

1892: #define HTTP_QUERY_DERIVED_FROM                 14

1893: #define HTTP_QUERY_COST                         15

1894: #define HTTP_QUERY_LINK                         16

1895: #define HTTP_QUERY_PRAGMA                       17

1896: #define HTTP_QUERY_VERSION                      18  // special: part of status line

1897: #define HTTP_QUERY_STATUS_CODE                  19  // special: part of status line

1898: #define HTTP_QUERY_STATUS_TEXT                  20  // special: part of status line

1899: #define HTTP_QUERY_RAW_HEADERS                  21  // special: all headers as ASCIIZ

1900: #define HTTP_QUERY_RAW_HEADERS_CRLF             22  // special: all headers

1901: #define HTTP_QUERY_CONNECTION                   23

1902: #define HTTP_QUERY_ACCEPT                       24

1903: #define HTTP_QUERY_ACCEPT_CHARSET               25

1904: #define HTTP_QUERY_ACCEPT_ENCODING              26

1905: #define HTTP_QUERY_ACCEPT_LANGUAGE              27

1906: #define HTTP_QUERY_AUTHORIZATION                28

1907: #define HTTP_QUERY_CONTENT_ENCODING             29

1908: #define HTTP_QUERY_FORWARDED                    30

1909: #define HTTP_QUERY_FROM                         31

1910: #define HTTP_QUERY_IF_MODIFIED_SINCE            32

1911: #define HTTP_QUERY_LOCATION                     33

1912: #define HTTP_QUERY_ORIG_URI                     34

1913: #define HTTP_QUERY_REFERER                      35

1914: #define HTTP_QUERY_RETRY_AFTER                  36

1915: #define HTTP_QUERY_SERVER                       37

1916: #define HTTP_QUERY_TITLE                        38

1917: #define HTTP_QUERY_USER_AGENT                   39

1918: #define HTTP_QUERY_WWW_AUTHENTICATE             40

1919: #define HTTP_QUERY_PROXY_AUTHENTICATE           41

1920: #define HTTP_QUERY_ACCEPT_RANGES                42

1921: #define HTTP_QUERY_SET_COOKIE                   43

1922: #define HTTP_QUERY_COOKIE                       44

1923: #define HTTP_QUERY_REQUEST_METHOD               45  // special: GET/POST etc.

1924: #define HTTP_QUERY_REFRESH                      46

1925: #define HTTP_QUERY_CONTENT_DISPOSITION          47

1926:

1927: //

1928: // HTTP 1.1 defined headers

1929: //

1930:

1931: #define HTTP_QUERY_AGE                          48

1932: #define HTTP_QUERY_CACHE_CONTROL                49

1933: #define HTTP_QUERY_CONTENT_BASE                 50

1934: #define HTTP_QUERY_CONTENT_LOCATION             51

1935: #define HTTP_QUERY_CONTENT_MD5                  52

1936: #define HTTP_QUERY_CONTENT_RANGE                53

1937: #define HTTP_QUERY_ETAG                         54

1938: #define HTTP_QUERY_HOST                         55

1939: #define HTTP_QUERY_IF_MATCH                     56

1940: #define HTTP_QUERY_IF_NONE_MATCH                57

1941: #define HTTP_QUERY_IF_RANGE                     58

1942: #define HTTP_QUERY_IF_UNMODIFIED_SINCE          59

1943: #define HTTP_QUERY_MAX_FORWARDS                 60

1944: #define HTTP_QUERY_PROXY_AUTHORIZATION          61

1945: #define HTTP_QUERY_RANGE                        62

1946: #define HTTP_QUERY_TRANSFER_ENCODING            63

1947: #define HTTP_QUERY_UPGRADE                      64

1948: #define HTTP_QUERY_VARY                         65

1949: #define HTTP_QUERY_VIA                          66

1950: #define HTTP_QUERY_WARNING                      67

1951:

1952: #define HTTP_QUERY_MAX                          67

1953:

1954: //

1955: // HTTP_QUERY_CUSTOM - if this special value is supplied as the dwInfoLevel

1956: // parameter of HttpQueryInfo() then the lpBuffer parameter contains the name

1957: // of the header we are to query

1958: //

1959:

1960: #define HTTP_QUERY_CUSTOM                       65535

1961:

1962: //

1963: // HTTP_QUERY_FLAG_REQUEST_HEADERS - if this bit is set in the dwInfoLevel

1964: // parameter of HttpQueryInfo() then the request headers will be queried for the

1965: // request information

1966: //

1967:

1968: #define HTTP_QUERY_FLAG_REQUEST_HEADERS         0x80000000

1969:

1970: //

1971: // HTTP_QUERY_FLAG_SYSTEMTIME - if this bit is set in the dwInfoLevel parameter

1972: // of HttpQueryInfo() AND the header being queried contains date information,

1973: // e.g. the "Expires:" header then lpBuffer will contain a SYSTEMTIME structure

1974: // containing the date and time information converted from the header string

1975: //

1976:

1977: #define HTTP_QUERY_FLAG_SYSTEMTIME              0x40000000

1978:

1979: //

1980: // HTTP_QUERY_FLAG_NUMBER - if this bit is set in the dwInfoLevel parameter of

1981: // HttpQueryInfo(), then the value of the header will be converted to a number

1982: // before being returned to the caller, if applicable

1983: //

1984:

1985: #define HTTP_QUERY_FLAG_NUMBER                  0x20000000

1986:

1987: //

1988: // HTTP_QUERY_FLAG_COALESCE - combine the values from several headers of the

1989: // same name into the output buffer

1990: //

1991:

1992: #define HTTP_QUERY_FLAG_COALESCE                0x10000000

1993:

1994:

1995: #define HTTP_QUERY_MODIFIER_FLAGS_MASK          (HTTP_QUERY_FLAG_REQUEST_HEADERS    \

1996:

------解决思路----------------------

HTTP_QUERY_FLAG_SYSTEMTIME        \

1997:

------解决思路----------------------

HTTP_QUERY_FLAG_NUMBER            \

1998:

------解决思路----------------------

HTTP_QUERY_FLAG_COALESCE          \

1999:                                                 )

2000:

2001: #define HTTP_QUERY_HEADER_MASK                  (~HTTP_QUERY_MODIFIER_FLAGS_MASK)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值