天天看點

對象化的Http和請求對象HttpRequest

在面向對象的語言中,有種“萬物皆對象”的說法。在上篇文章中介紹了httpruntime類,在該類收到請求之後,立即通過httpworkerrequest工作者對象對傳遞的參數進行分析和分解,建立友善網站應用程式處理的對象。與此相關的對象主要有,請求和響應兩個對象。即httprequest和httpresponse類型。

httprequest定義在命名空間system.web下

對于每一個請求參數,httpruntime将建立一個類型為httprequest的對象。

這個類定義了大量的屬性,用于表示關于http請求的參數。這些參數來源于工作者對象httpworkerrequest,但httprequest提供了更加簡便的方式。

http的請求消息包括三部分,分别是:請求行,請求頭,請求體。

下面看一下httprequest的常見屬性。

對象化的Http和請求對象HttpRequest
對象化的Http和請求對象HttpRequest

輸出結果

requesttype:get

httpmethod:get

rawurl:/test.aspx

url:http://192.168.1.105:8888/test.aspx

:

filepath:/test.aspx

currentexecutionfilepath:/test.aspx

path:/test.aspx

apprelativecurrentexecutionfilepath:~/test.aspx

physicalapplicationpath:d:\deeplearn\

physicalpath:d:\deeplearn\test.aspx

accepttypes:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

headers:name=cache-control,value=max-age=0

headers:name=connection,value=keep-alive

headers:name=accept,value=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

headers:name=accept-encoding,value=gzip, deflate, sdch

headers:name=accept-language,value=zh-cn,zh;q=0.8

headers:name=host,value=192.168.1.105:8888

headers:name=user-agent,value=mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, like gecko) chrome/47.0.2526.106 safari/537.36

headers:name=upgrade-insecure-requests,value=1

params:name=all_http,value=http_cache_control:max-age=0 http_connection:keep-alive http_accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 http_accept_encoding:gzip, deflate, sdch http_accept_language:zh-cn,zh;q=0.8 http_host:192.168.1.105:8888 http_user_agent:mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, like gecko) chrome/47.0.2526.106 safari/537.36 http_upgrade_insecure_requests:1 

params:name=all_raw,value=cache-control: max-age=0 connection: keep-alive accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 accept-encoding: gzip, deflate, sdch accept-language: zh-cn,zh;q=0.8 host: 192.168.1.105:8888 user-agent: mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, like gecko) chrome/47.0.2526.106 safari/537.36 upgrade-insecure-requests: 1 

params:name=appl_md_path,value=/lm/w3svc/4/root

params:name=appl_physical_path,value=d:\deeplearn\

params:name=auth_type,value=

params:name=auth_user,value=

params:name=auth_password,value=

params:name=logon_user,value=

params:name=remote_user,value=

params:name=cert_cookie,value=

params:name=cert_flags,value=

params:name=cert_issuer,value=

params:name=cert_keysize,value=

params:name=cert_secretkeysize,value=

params:name=cert_serialnumber,value=

params:name=cert_server_issuer,value=

params:name=cert_server_subject,value=

params:name=cert_subject,value=

params:name=content_length,value=0

params:name=content_type,value=

params:name=gateway_interface,value=cgi/1.1

params:name=https,value=off

params:name=https_keysize,value=

params:name=https_secretkeysize,value=

params:name=https_server_issuer,value=

params:name=https_server_subject,value=

params:name=instance_id,value=4

params:name=instance_meta_path,value=/lm/w3svc/4

params:name=local_addr,value=192.168.1.105

params:name=path_info,value=/test.aspx

params:name=path_translated,value=d:\deeplearn\test.aspx

params:name=query_string,value=

params:name=remote_addr,value=192.168.1.105

params:name=remote_host,value=192.168.1.105

params:name=remote_port,value=3445

params:name=request_method,value=get

params:name=script_name,value=/test.aspx

params:name=server_name,value=192.168.1.105

params:name=server_port,value=8888

params:name=server_port_secure,value=0

params:name=server_protocol,value=http/1.1

params:name=server_software,value=microsoft-iis/10.0

params:name=url,value=/test.aspx

params:name=http_cache_control,value=max-age=0

params:name=http_connection,value=keep-alive

params:name=http_accept,value=text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8

params:name=http_accept_encoding,value=gzip, deflate, sdch

params:name=http_accept_language,value=zh-cn,zh;q=0.8

params:name=http_host,value=192.168.1.105:8888

params:name=http_user_agent,value=mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, like gecko) chrome/47.0.2526.106 safari/537.36

params:name=http_upgrade_insecure_requests,value=1

contentencoding:system.text.utf8encoding

contentlength:0

contenttype:

browser:system.web.mobile.mobilecapabilities

useragent:mozilla/5.0 (windows nt 10.0; wow64) applewebkit/537.36 (khtml, like gecko) chrome/47.0.2526.106 safari/537.36

userhostaddress:192.168.1.105

userhostname:192.168.1.105

userlanguages:zh-cn,zh;q=0.8

部落格位址:

<a href="http://www.cnblogs.com/wolf-sun">http://www.cnblogs.com/wolf-sun/</a>

部落格版權:

本文以學習、研究和分享為主,歡迎轉載,但必須在文章頁面明顯位置給出原文連接配接。

如果文中有不妥或者錯誤的地方還望高手的你指出,以免誤人子弟。如果覺得本文對你有所幫助不如【推薦】一下!如果你有更好的建議,不如留言一起讨論,共同進步!

再次感謝您耐心的讀完本篇文章。http://www.cnblogs.com/wolf-sun/p/5204778.html