Discussion:
http cgi question
(too old to reply)
Angus
2007-05-05 19:53:03 UTC
Permalink
Hello

I am building a web server and I have worked out how to do basic GET. If a
http request is a GET then I find the file requested and write the contents
of the file to stdout.

But if the request is for a cgi file then I don't write out the contents of
the cgi file - instead I need to call the program and output the returned
text from the program. But how do I differentiate? Is it purely on the
filename requested. ie if the file is xyz.cgi or xyz.exe then I know it is
a cgi and output program output or if it is htm or html I output the file
contents? Or are cgi requests submitted in a different way to the http
server?

Angus
Arkady Frenkel
2007-05-06 05:24:37 UTC
Permalink
Each file type have it's header with specific format so you can analize it
before deciding what to do.
Arkady
Post by Angus
Hello
I am building a web server and I have worked out how to do basic GET. If a
http request is a GET then I find the file requested and write the contents
of the file to stdout.
But if the request is for a cgi file then I don't write out the contents of
the cgi file - instead I need to call the program and output the returned
text from the program. But how do I differentiate? Is it purely on the
filename requested. ie if the file is xyz.cgi or xyz.exe then I know it is
a cgi and output program output or if it is htm or html I output the file
contents? Or are cgi requests submitted in a different way to the http
server?
Angus
Angus
2007-05-06 17:22:57 UTC
Permalink
If I do a GET submit on a form, as in

GET
/pubcgi/formmail162.pl?name=Angus+Comber&company=Itel+Office&address=5+enmor
e+gardens%0D%0ALondon&postcode=SW14+8RF&comment=Itel+Office+request&recipien
t=download%40iteloffice.com HTTP/1.1
Host: www.userarea.co.uk
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3)
Gecko/20070309 Firefox/2.0.0.3
Accept:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.iteloffice.com/howtobuyget.htm

Does the http server look at the GET string and if eg htm or html extension
display file contents but if pl extension get returned value from calling
program? The real question I am asking is how does the http server
differentiate between a request for the contents of a file or the output of
calling a program?
Post by Arkady Frenkel
Each file type have it's header with specific format so you can analize it
before deciding what to do.
Arkady
Post by Angus
Hello
I am building a web server and I have worked out how to do basic GET.
If
Post by Arkady Frenkel
Post by Angus
a
http request is a GET then I find the file requested and write the contents
of the file to stdout.
But if the request is for a cgi file then I don't write out the contents of
the cgi file - instead I need to call the program and output the returned
text from the program. But how do I differentiate? Is it purely on the
filename requested. ie if the file is xyz.cgi or xyz.exe then I know it is
a cgi and output program output or if it is htm or html I output the file
contents? Or are cgi requests submitted in a different way to the http
server?
Angus
Arkady Frenkel
2007-05-07 06:36:21 UTC
Permalink
Yes, it look on extention but when try to open can receive the error so try
to behave in advance. BTW you can learn behavior of the simple server in
MSFT webster example ( server ) on
http://www.microsoft.com/msj/archive/S25F.aspx

Arkady
Post by Angus
If I do a GET submit on a form, as in
GET
/pubcgi/formmail162.pl?name=Angus+Comber&company=Itel+Office&address=5+enmor
e+gardens%0D%0ALondon&postcode=SW14+8RF&comment=Itel+Office+request&recipien
t=download%40iteloffice.com HTTP/1.1
Host: www.userarea.co.uk
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3)
Gecko/20070309 Firefox/2.0.0.3
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=
0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://www.iteloffice.com/howtobuyget.htm
Does the http server look at the GET string and if eg htm or html extension
display file contents but if pl extension get returned value from calling
program? The real question I am asking is how does the http server
differentiate between a request for the contents of a file or the output of
calling a program?
Post by Arkady Frenkel
Each file type have it's header with specific format so you can analize it
before deciding what to do.
Arkady
Post by Angus
Hello
I am building a web server and I have worked out how to do basic GET.
If
Post by Arkady Frenkel
Post by Angus
a
http request is a GET then I find the file requested and write the contents
of the file to stdout.
But if the request is for a cgi file then I don't write out the
contents
of
the cgi file - instead I need to call the program and output the
returned
Post by Arkady Frenkel
Post by Angus
text from the program. But how do I differentiate? Is it purely on the
filename requested. ie if the file is xyz.cgi or xyz.exe then I know
it
is
a cgi and output program output or if it is htm or html I output the
file
Post by Arkady Frenkel
Post by Angus
contents? Or are cgi requests submitted in a different way to the http
server?
Angus
Loading...