Solved

Delphi 3 CGI Applications.

Posted on 1998-02-25
5
243 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
ID: 1359810
Adjusted points to 200
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 200 total points
ID: 1359811
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
ID: 1359812
0
 

Author Comment

by:hamishd
ID: 1359813
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
ID: 1359814
Glad I could help.

Regards, zif.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

773 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