?
Solved

Delphi 3 CGI Applications.

Posted on 1998-02-25
5
Medium Priority
?
251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:hamishd
ID: 1359810
Adjusted points to 200
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 800 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses
Course of the Month8 days, 16 hours left to enroll

764 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