Solved

the CGI for IIS (PWS) servers

Posted on 2000-03-14
14
193 Views
Last Modified: 2013-11-18
Hello, Experts.
I have problems with making CGI. So, I have D4 with internet components. So, I am loking for information about building CGI applications. All kind.. from counters till shoping things.

Thank you for your help.
Sandis Viksna.
0
Comment
Question by:sviksna
  • 5
  • 3
  • 3
  • +2
14 Comments
 
LVL 3

Expert Comment

by:ckaneta
Comment Utility
create a Delphi console application, replace the typical source code with something like this:

program cgi;
{$apptype console}

uses Sysutils;

begin
 writeln('HTTP/1.0 200 OK');
 writeln('CONTENT-TYPE: TEXT/HTML');
 writeln('<html><head>');
 writeln('<title>blah blah</title>');
 writeln('</head><body>');
 writeln('</body></html>');
end.
basically from Cantu's book.
I can try to dig up a sample and send it if you like
0
 
LVL 13

Expert Comment

by:Epsylon
Comment Utility
0
 

Expert Comment

by:mike_tipping
Comment Utility
remember to enable CGI on the website in IIS (well it caught me out for a while)
0
 
LVL 1

Author Comment

by:sviksna
Comment Utility
ckaneta,
it would be nice. thank you.

Sandis.
0
 
LVL 3

Expert Comment

by:ckaneta
Comment Utility
okay, either write to me at ckan1010@aol.com and I'll send it in a reply or get it from here

members.xoom.com/kaneta/dwnld/cgistuff.zip

~ or ~

members.xoom.com/kaneta
and go to the 'stuff' page

0
 
LVL 1

Author Comment

by:sviksna
Comment Utility

the code
program response;
{$apptype console}

uses Sysutils;

begin
 writeln('HTTP/1.0 200 OK');
 writeln('CONTENT-TYPE: TEXT/HTML');
 writeln('<html><head>');
 writeln('<title>blah blah</title>');
 writeln('</head><body> here it is dude');
 writeln('</body></html>');
end.

----------------------
the result
-----------------------
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:


HTTP/1.0 200 OK
CONTENT-TYPE: TEXT/HTML


here it is dude
-------------------------

can u help me?
0
 
LVL 13

Expert Comment

by:Epsylon
Comment Utility
The second writeln is not right. Change or remove it and try again.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 17

Expert Comment

by:geobul
Comment Utility
Hi,

Select 'File-New-Web Server Application' from Delphi main menu and then 'CGI Stand-alone Executable'. This way you have created new CGI project with WebModule. In WebModule you can add Action Items for different HTTP methods like GET and POST and for different 'commands' after the name of your CGI script, defined in the calling HTML page like
....
<FORM METHOD=POST ACTION="/scripts/MyScript.exe/login">
.....
where 'MyScript.exe' is the name of the script and '/login' is the 'command', corresponding with Action Item with PathInfo property = /login.
  There are Request object containing all information about the client's browser request and Response object which Content property your program has to fill with HTML page and send back using SendResponse method.

  You have to build the exe and copy to the scripts directory of the Web server.

It's not so hard stuff as it sounds.

Regards, Geo
0
 
LVL 1

Author Comment

by:sviksna
Comment Utility
The advice one step up is ok. But how to do with thing like session() in ASP. How i can pass the data in novisual mode, i meant with this, that data isn't visible into the location bar, like
some.exe?name=john&regnum=32434234

couse, these params are constants for current user in all pages, but i don't wana write them in the HTML code as Hiden object (<input type="hiden"..) security for...

so, is there any solution for this?

Sandis.
0
 
LVL 13

Expert Comment

by:Epsylon
Comment Utility
Use cookies. This is how asp sessions work...
0
 
LVL 17

Accepted Solution

by:
geobul earned 50 total points
Comment Utility
Hi,

Setting cookies :

procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  slCookies : TStringList;
  login, passw : string;
begin
  slCookies := TStringList.Create;
  ...
  { reading values from somewhere - from Request here }
  login:=Request.ContentFields.Values['login'];
  passw:=Request.ContentFields.Values['passw'];
  .....
  { adding cookies to string list }
  slCookies.Add('login='+login);
  slCookies.Add('passw='+passw);
  { set cookies in Response }
  Response.SetCookieField(slCookies,'','',Request.Date-1,False);
  .......
  slCookies.Free;
end;


Reading cookies:

procedure TWebModule1.WebModule1WebActionItem2Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  login, passw : String;
begin
  ...
  login := Request.CookieFields.Values['login'];
  passw := Request.CookieFields.Values['passw'];
  ...
end;

Regards, Geo
0
 
LVL 1

Author Comment

by:sviksna
Comment Utility
hi, geo, again

{ reading values from somewhere - from Request here }
  login:=Request.ContentFields.Values['login'];
  passw:=Request.ContentFields.Values['passw'];


is that like value
cgi-bin/myapp.exe/login=loginame&passw=somepass


am i right?
0
 
LVL 17

Expert Comment

by:geobul
Comment Utility
Hi,

  I'm using POST method in my example and login and pass values are in the content property of the request (INPUT text/password html tags and a button).
  You are using GET method in your example and the info is in the query property of the request. So the code will be:

login:=Request.QueryFields.Values['login'];
  passw:=Request.QueryFields.Values['passw'];

Regards, Geo
0
 
LVL 1

Author Comment

by:sviksna
Comment Utility
This was one of moust useable anwers.
Thank You.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ColdFusion Rereplace 3 61
AngularJS directive issue 6 53
Swiper slider stops between pages 11 30
Create a path if not exists 7 41
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now