Using Intraweb-Thttprequest, thttpreply

Source: Internet
Author: User


The Request, Response (Thttprequest, thttpreply) familiar in other server scripting languages are behind the scenes in Intraweb, and users do not need to manipulate them directly.

The IW default Post value (WebApplication.Request.HttpMethod = hmpost, read-only), but like a form field, is read directly from the control name in the IW, without the need for trouble with the Request.
However, it can be read using webapplication.request.queryfields.values[' control name ' if needed.

To read a URL variable that is transmitted in a Get mode, it is found that webapplication.request.queryfields.values[' variable name ' is not useful in many cases; After trying, there is no way:
1, stupid method: own analytic WebApplication.Request.Referer;
2, Request in the form of parameters can often, for example, Tiwappform.onurlrequest event:
{Key code in UNIT1}procedure Tiwform1.iwbutton1click (sender:tobject); Begin  Webapplication.gotourl (' page2.html? Aaa=111&bbb=222 '); end; {Key code in Unit2}procedure tiwform2.iwappformurlrequest (asender:tiwappform; arequest:thttprequest); Uses IW is required. HTTP. Requestbegin  IWMemo1.Lines.Add (webapplication.request.queryfields.values[' BBB '); End;initialization  Tiwform2.seturl (', ' page2.html ');

I think, according to IW's idea, the parameters passed between pages should be the Session (under the next blog test).

In some cases, there are two ways to use the run parameters and enter the running parameters:
1. From the code (e.g.: WebApplication.RunParams.CommaText: = ' aaa=111,bbb=222 ');
2. From the Server console (e.g.);


Read the operating parameters, such as: mystr: = webapplication.runparams.values[' AAA '];
thttprequestUnit and succession chain:
IW. HTTP. Request.thttprequest < TObject

Key members (judging by test results):
Property useragent:string//test Result: mozilla/5.0 (Windows NT 6.1; trident/7.0; rv:11.0) like Geckoproperty referer:string//test Result: http://127.0.0.1:8888/$/?aaa=111&bbb=222;             Two run parameters were added to the test scriptname:string//property host:string//test result: 127.0.0.1property url:string Property pathinfo:string//test Result:/$/callbackproperty remoteaddr:string//test result: 127.0.0.1property S Erverport:integer//test Result: 8888property query:string//test Result: Callback=...property Httpmethod:thttpmethod/    /test Result: Hmpost (Other: Hmnone, Hmget, Hmput, Hmpost, Hmhead) property ifmodifiedsince:string//property forwardedfor:string Property httpclientip:string//property acceptlanguage:string//test Result: Zh-cnproperty httpsheader:string//pro Perty authorization:string//property authorizationheader:string//property authuser:string//property AuthPas S:string//property servervariables:tstrings//property Hascontent:boOlean//test Result: Trueproperty files:thttpfilelist//property querystring:string//test Result: callback=...functi On Getcookievalue (const aname:string): String;function getrawheadervalue (const aname:string): String;function Getservervariablevalue (const avariablename:string): String;function getcontentfieldvalue (const aContentFieldName:                               String): String;procedure setrewriteurl (const aurl:string);p Roperty rawheaders:tstrings//test Result:                              Accept: */*//content-type:application/x-www-form-urlencoded                              referer:http://127.0.0.1:8888/$///ACCEPT-LANGUAGE:ZH-CN Accept-encoding:gzip, deflate//user-agent:mozilla/5.0 (Windows NT 6.1; trident/7.0;                               rv:11.0) like Gecko//host:127.0.0.1:8888//content-length:205   Dnt:1                           Connection:keep-alive//cache-control:no-cache                                 Cookie:iw_myapp=rtdemtdbmuncnjhgndgwquewrkmwodk1otaxrue4mdu_2property contentfields:tstrings//test results:                                 Iwbutton2=//iw_action=iwbutton2 iw_actionparam=//iw_formname=iwform1//iw_formcla                                 Ss=tiwform1//iw_locationhash=//iw_trackid_=2 iw_width=1920//iw_height=985//iw_ Sessionid_=mkrbmdjendg0mzlgndgxoefbn0ywoefbmti2rjngode//callback=iwbutton2.                                 Doonasyncclick//x=48//y=10                          Which=0       Modifiers=property cookiefields:tstrings//test Result: Iw_myapp=ourdmeffmdhgmtk1ndiwodgzoungnkvfmtg5nkixmue_2property Queryfields:tstrings//test result://iwbutton2=//iw_action=iwbutt                               ON2//iw_actionparam=//iw_formname=iwform1 Iw_formclass=tiwform1//iw_locationhash=//iw_tr                               ackid_=2//iw_width=1920//iw_height=985 Iw_sessionid_=nzkxqtvcrjvbmtizndjfrke1nzm3numymta3ruixnzg//callback=iwbutton2. Doonasyncclick//x=52//y=18//w Hich=0//modifiers=function getparams:tstrings;                    Test Result://iwbutton2=          Iw_action=iwbutton2//iw_actionparam=//iw_formname=                              IWForm1//iw_formclass=tiwform1//iw_locationhash=                              iw_trackid_=2//iw_width=1920//iw_height=985 Iw_sessionid_=njdbrdvcrdaznzizndm0mjg0mem1ndnerdc1njawree//ca Llback=iwbutton2. Doonasyncclick//x=56//y=15//whic H=0//modifiers=//iwbutton2=//iw_                              Action=iwbutton2//iw_actionparam=//iw_formname=iwform1                              Iw_formclass=tiwform1//iw_locationhash= iw_trackid_=2//iw_width=1920//iw_height=985 Iw_sessionid_=njdbrdvcrdaznzizndm0mjg0mem1ndnerdc1njawree//callback=iwbutton2. Doonasyncclick//x=56//y=15//whic H=0//modifiers=


thttpreplyUnit and succession chain:
IW. HTTP. Reply.thttpreply < TObject

Main members:
Property Allowcaching:boolean//property authrealm:string//property cachettl:integer//property Code:word Property codetext:string//property contenttype:string//property cookies:tcookielist
  
   
    //property lastmodified:tdatetime//property headers:tstrings//property expires:tdatetime//prop Erty datatype:thttpreplytype//property serverport:integer//property sendingfile:boolean//property Cach Econtrolenabled:boolean//if FALSE, completely disable cache control header fields ("Expires", "last-modified", "Pragma: No-cache "and" Cache-control:no-cache "). Default = Trueconstructor Create (abuffer:pbyte; const Asize:integer) Procedure Commitprocedure writestring (const avalue : string) procedure Sendrenderstream (Astream:tiwrenderstream) procedure Sendstream (astream:tstream; const Adisablecachecontrol:boolean) Procedure Sendhsmstream (Astream:thsmstream) procedure SendFile (const apathname:string ; Adelete:boolean; Const Adisablecachecontrol:boolean) Procedure Sendcachefile (const apathname:string) procedure Sendredirect (const AURL : string) Procedure Resetreplytype
   
  

Learn other server scripts, are accustomed to the first with the Response output point what, the following test in the IW through the Response to do a simple output:
{Create a new Myindex unit, inherit from Tcontentbase to implement a Tmyindex class}unit myindex;interfaceuses Classes, IW. Content.base, Httpapp, Iwapplication, IW. HTTP. Request, IW. HTTP. Reply, Iwmimetypes;type Tmyindex = Class (Tcontentbase) protected function Execute (arequest:thttprequest; areply:tht tpreply; Const apathname:string; Asession:tiwapplication; aparams:tstrings): Boolean;  Override Public constructor Create;  Override  end;implementation{Tmyindex}constructor Tmyindex.create;begin inherited; Mfilemustexist: = False;end;function tmyindex.execute (arequest:thttprequest; areply:thttpreply; Const APathname: String Asession:tiwapplication;  aparams:tstrings): Boolean;begin areply.contenttype: = mime_html;  Areply.writestring (' <a href= "http://www.cnblogs.com/del//del.cnblogs.com" > in case of Delphi blog </a> '); Result: = True;end;end. Myindex.pas end{is designated as the first page in Iwservercontrollerbase.onconfig, and is named Index.htm}uses Iwinit, Iwglobal, IW. Content.handlers, Myindex;procedure tiwservercontroller.iWservercontrollerbaseconfig (sender:tobject); Begin Thandlers.addstarthandler (', ' index.htm ', TMyIndex.Create); end ;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.