Solved

Delphi 3 CGI Applications.

Posted on 1998-02-25
5
240 Views
Last Modified: 2010-04-06
I'm after some demos with source for simple CGI programs...Just to get me started....
0
Comment
Question by:hamishd
  • 3
  • 2
5 Comments
 

Author Comment

by:hamishd
Comment Utility
Adjusted points to 200
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 200 total points
Comment Utility
Hi,

some components with source :

http://torry.rimini.com/vcl/internet/delphcgi.zip

and a little demo :

Not made by me!

L> I don't understand though how to send the output from the CGI to the web
RL> server.

Yeah, I spend a whole weekend before I got it right. Here's a sample program
I wrote for developing 32bit Delphi console GCI apps. It still needs work,
like return variable values and so on. But it is at least a start.

regards,
Billy
program test;

{$APPTYPE CONSOLE}

uses WinProcs, WinTypes, SysUtils;

type
  TCGIData = class
    public
      {following variables are set by the Web Server as o/s environmental
      variables}
      RequestMethod : String;  {from html FORM METHOD=??}
      PathInfo      : String;
      QueryString   : String;  {query string from server}
      RemoteHost    : String;  {ip address of client browser}
      ContentType   : String;
      ContentLength : LongInt;
      HttpUserAgent : String;  {client's browser signature}
      constructor Create;
  end;


constructor TCGIData.Create;
{reads the environmental variables}
var
  lpsz : Pchar;
begin
  lpsz := StrAlloc(1024*10);

  if GetEnvironmentVariable( 'Request_Method', lpsz, 1024*10 ) > 0 then
    RequestMethod := StrPas(lpsz)
  else
    RequestMethod := '';

  if GetEnvironmentVariable( 'Path_Info', lpsz, 1024*10 ) > 0 then
    PathInfo := StrPas(lpsz)
  else
    PathInfo := '';

  if GetEnvironmentVariable( 'Query_String', lpsz, 1024*10 ) > 0 then
    QueryString := StrPas(lpsz)
  else
    QueryString := '';

  if GetEnvironmentVariable( 'Remote_Host', lpsz, 1024*10 ) > 0 then
    RemoteHost := StrPas(lpsz)
  else
    RemoteHost := '';

  if GetEnvironmentVariable( 'HTTP_User_Agent', lpsz, 1024*10 ) > 0 then
    HttpUserAgent := StrPas(lpsz)
  else
    HttpUserAgent := '';

  if GetEnvironmentVariable( 'Content_Type', lpsz, 1024*10 ) > 0 then
    ContentType := StrPas(lpsz)
  else
    ContentType := '';

  if GetEnvironmentVariable( 'Content_Length', lpsz, 1024*10 ) > 0 then
    ContentLength := StrToInt(lpsz)
  else
    ContentLength := 0;

  StrDispose(lpsz);
end;

var
  CGI : TCGIData;

begin
  CGI := TCGIData.Create;
  WriteLn('MIME-version: 1.0');
  WriteLn('Content-type: text/html');
  WriteLn;
  WriteLn('');
  WriteLn('');
  WriteLn('');
  WriteLn('');
  WriteLn('

');
  WriteLn('');
  WriteLn('This CGI is written in Delphi II. The following information ');
  WriteLn('is available to this CGI from the Web Server:
');
  WriteLn('');
  WriteLn('
   Request method for this CGI : '+CGI.RequestMethod);
  WriteLn('
   Path : '+CGI.PathInfo);
  WriteLn('
   Parameters : '+CGI.QueryString);
  WriteLn('
   Content Type : '+CGI.ContentType);
  WriteLn('
   Your IP address : '+CGI.RemoteHost);
  WriteLn('
   Your Browser''s signature : '+CGI.HttpUserAgent);
  WriteLn('
');
  WriteLn('

');
  WriteLn('');
  WriteLn('
Coyright © Whoever 1996
');
  WriteLn('');

  CGI.Free
end.

regards,Zif.
0
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
0
 

Author Comment

by:hamishd
Comment Utility
Dear Time Saver,

Thank you. I'm sure you know how hard it is to find source on the internet for delphi CGI programming. You have made my life easier....


0
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
Glad I could help.

Regards, zif.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 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

15 Experts available now in Live!

Get 1:1 Help Now