>Been looking at the scripting in the version of the server I've got. Can't
>quite see how it is implementiung the CGI stuff:
Sorry, we only have spaghetti...;-)
Next lines determine if the file the client wants exists at all. If not the
server answers 404 error else
(getSuffix) the server decides according to the suffix what to do with the
file: execute it as cgi or just serve it as is.
get lineOffset(pFile,aList)##pFile is the name of the file, aList is the
list of availabe files
if it is not "0" then
getSuffix
close socket x
else
##the file doesn't exist
answerError404
>
>on getSuffix
> set wholeMatches to true
> set itemDel to "."
> put "."& last item of pFile into suffix
> set itemDel to ","
##Next line checks the file suffix against the list of accepted sufixes for cgi
##if the suffix is a cgi suffix then the file is executed
> get itemOffset(suffix,cgiSuffix)
> if it is not 0 then
> open process pFile
> read from process pFile until eof
> # write it to stdout
> write it to socket w
> put cr & "200 OK" & " "& the date & " " & the long time & " " & z
>after fld "read" of cd 1
> if the label of btn "log" of cd 2 is "Save log" then put cr & "200 OK"
>& " "& \
> the date & " " & the long time & " " & z after url logFile
> end if
##Next line deals with the html and image files
> get itemOffset(suffix,fileSuffix)
> if it is not 0 then
> put "binfile:"& pFile into xFile
> write url xFile to socket w
> # write xFile to stdout
> put cr & "200 OK" & " "& the date & " " & the long time & " " & z
>after fld "read" of cd 1
> if the label of btn "log" of cd 2 is "Save log" then put cr & "200 OK"
>& " "& \
> the date & " " & the long time & " " & z after url logFile
> end if
>end getSuffix
>
>What happens when the CGI suffix is not there?
As expected you should get an error - 404 for now.
> Also if Mac's won't run .mt
>scripts the same way as Unix, and following on from Scott's comments on
>Windows NT servers, wouldn't it be good to implement CGI's in a platform
>independent way?
Who stops you? You just have to build the server to do scripts instead of
executing a file. That means the client has to send to the server the name
of a handler instead of of a file in which case you have(in a generic way):
get itemOffset(handlerName,listOfAvailableHandlers)
if it is not 0 then
handlerName
write the_result_from_handler to socket X
and it's probably faster too.
Regards, Andu