Link to home
Start Free TrialLog in
Avatar of lxwizard
lxwizard

asked on

A problem about ISAPI

I am a beginner of Delphi5.0, Now I am learning to write a ISAPI program, here is a problem about "POST" and "GET" method
I created a Web Server Application base on ISAPI, here is the code:

procedure TWebModule1.WebModuleWebActionItem1Action(Sender:TObject; Request:TWebRequest;
  Response:TWebResponse;Var Handled:Boolean);
Var
   Input:TString;
   areaname:String;
Begin
   Input:=Nil;
   Case request.methodtype of
       mtpost: Input:=request.ContentFields;
       mtget,mtput,mthead: Input:=request.QueryFields;
   end;
   areaname:=Input.Values['area']
   ......
   ......
End.

Now, the problem is:
I use "GET" method in Html I can get the value of 'area', if I use "POST" method in Html I can get Nothing, why? Please help me

here is the Html code:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#FFFFFF">
<form method="POST" action="/scripts/webquery.dll">
input:  <INPUT NAME="Area" VALUE="" SIZE=60>
  <p>
    <input type="submit" value="Submit">
    <input type="Reset" value="reset">
  </p>
</form>
</body>
</html>

OS: Win98, omnihttp web server
Avatar of inthe
inthe

Hi
do you want
Request.ContentFields.Values['area']

and the forms method = get
should be methoiod=Post shouldnt it.

Listening
btw:
i think you will like this website :

http://www.209software.com/books/wpid/
Avatar of lxwizard

ASKER

Edited text of question.
Thank you all, but I can not get a approving solution, who can help me.
if you can try it on your computer.
OS:Win98 + Omnihttp http server.
"GET" Method is OK
"POST Method do nothing????
Hi,

1.Check that WebActionItem1.MethodType is mtAny.

2. Input : TStringS;

Regards, Geo
My previous comment was not clear. Sorry!

Here it is:

Your WebActionItem1.MethodType have to be mtAny. Your program has to check Method property (string) is it equal to:
'GET'
'POST' etc.
instead of MethodType.

MethodType property is a mask of accepted methotds. Method property is the actual method in the request.

Regards, Geo
Hi lxwizard,

I passed by a similar trouble with a friend ( I dont have D5)
If you change the method after a uniqueness ISAPI DLL load you need restart the MTS to all back to work, I discovered this while debbuging a old code.
If you is debugging at this manner try make this.

T++, Radler.
HI,
ive tested this :

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, HTTPApp;

type
  TWebModule1 = class(TWebModule)
    procedure WebModule1WebActionItem1Action(Sender: TObject;
      Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  WebModule1: TWebModule1;

implementation

{$R *.DFM}

procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);

Var
   Input:tStrings;
   POSTareaname,GETareaname:String;
   Page:TStringList;
   Begin
 Input:=Nil;
   Case request.methodtype of
       mtpost: Input:=request.ContentFields;
       mtget,mtput,mthead: Input:=request.QueryFields;
   end;
   GETareaname:=Input.Values['areaget'];
   POSTareaname:=Input.Values['areapost'];
 Page := TStringList.Create;
try
  with Page do
 begin
Add('<HTML><BODY>Your request contains the following information:<BR><BR>');
Add('<BR>Your IP address is: ' + Request.RemoteAddr );
Add('<BR>Your POSTareaname is: ' + POSTareaname );
Add('<BR>Your GETareaname is: ' + GETareaname );
Add('<BR>You are using the following browser and operating system: ' + Request.UserAgent);
Add('<BR>You asked for the following URL: http://' + Request.Host + Request.URL + Request.PathInfo );
Add('</BODY></HTML>');
 end ;
   Response.Content := Page.Text ;
  finally
    Page.Free;
  end ;
    Handled := True ;
end;

end.




html file:

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>

<body bgcolor="#FF00EE">

<form method="post" action="/scripts/webquery.dll">
input using post :  <INPUT NAME="Areapost" VALUE="" SIZE=60>
  <p>
    <input type="submit" value="Submit">
    <input type="Reset" value="reset">
  </p>
</form>

<form method="get" action="/scripts/webquery.dll">
input using get:  <INPUT NAME="Areaget" VALUE="" SIZE=60>
  <p>
    <input type="submit" value="Submit">
    <input type="Reset" value="reset">
  </p>
</form>
</body>
</html>

the response will send back the inputtext now depending on which input box you submit
 
Regards Barry
Hi, dear My friends.
I have tried the program above. I type ¡°Hello World¡± into both of  textboxs in web page. But the problem is still here. Here is the result:

Use ¡°post¡± method:

Your request contains the following information:


Your IP address is: 127.0.0.1
Your POSTareaname is:
Your GETareaname is:
You are using the following browser and operating system: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)
You asked for the following URL: http://

Use ¡°get¡± method:

Your request contains the following information:


Your IP address is: 127.0.0.1
Your POSTareaname is:
Your GETareaname is: Hello World!
You are using the following browser and operating system: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)
You asked for the following URL: http://

¡°POST¡± method do nothing!

Maybe my softwares environment has some problem?

Win98 Second Edition (Simple Chinese)+Omnihttp HTTP Server+Delphi5.0+IE5.0
Nobody can make a solution.
The problem is still here.
Nobody can make a solution.
The problem is still here.
my answer is correct.

you can only get one method at a time.
in my example if you type in the POST box and press submit you get back:
Your POSTareaname is:Hello World!  
Your GETareaname is:

but if you type in the GET box and press submit you get back:

Your POSTareaname is:
Your GETareaname is: Hello World!

the result is depend on what box you submit or press enter in.

it does work please try it agin and only fill in one box at a time.



did you change something in the code?
I know your program has no problem as well as mine. now, I only type in post box, and press post submit, but I can get nothing, post method do nothing.
in fact, I am going to install PWS on my computer and try our programs again. I will tell you the result. thank you again.
hi
well that is strange :-(
for your info i am using samba web server but i didnt think it would make a difference ,url is:
http://www.sambar.com/
you install it and put your html file in the "docs" directory and the dll in the cgi-bin directory.the rest as normal it is quite asy to setup and use.i prefer it more than pws which i found can be a pain ;-)
let us know how it goes.
regards Barry
ps it is also free .
Hi, dear friends.

I have used Samber,  then the result is:

POST method
Your request contains the following information:


Your IP address is: 127.0.0.1
Your POSTareaname is: Hello World!
Your GETareaname is:
You are using the following browser and operating system: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)
You asked for the following URL: http://127.0.0.1/cgi-bin/webquery.dll

GET method:
Your request contains the following information:


Your IP address is: 127.0.0.1
Your POSTareaname is:
Your GETareaname is: Hello World!
You are using the following browser and operating system: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)
You asked for the following URL: http://127.0.0.1/cgi-bin/webquery.dll

Just like my supposing, everything is OK, it means that Omnihttp has bugs, doesn¡¯t it?
Thank u. Then I have to use Samber rather then Omnihttp.
yes it sure does :-)
you should tell the makers of Omnihttp about the problem,though ive just been reading newsgroups and other people have also found this bug so they probably know about it already.

ps
what do you think of sambar?
it quite good i think.
Thank u again, Samber is good, but its configuration is in HTML, I don't like this way. by the way, My ICQ number is :
15651977
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank u all, especially Inthe
yeh thanks for the d grade it makes for great motivation to help people .