So true...

> On Wed, 24 Nov 1999, David Bovill wrote:
> 
>>> This is a pretty important design decision and so I think we should
>>> consider it carefully.  While it's true that using environment
>>> variables would make it easy to replace a built-in handler with an
>>> external CGI program on UNIX, there are problems with this approach.
>>> The most obvious one being that it won't work on Mac or Windows.  It
>>> probably could be made to work on Windows, but can never work on Mac
>>> and indeed wouldn't make any sense to a Mac-based developer.
>> 
>> The bit that makes sense to a Mac developer is the following sort of code
>> that I could program in a custom metacard CGI that I want o add to the
>> mchttpd server (having the option to use it also for .mt scripts on UNIX
>> servers):
>> 
>> if  $USER_AGENT contains "MSIE" then
>> doSomething
>> else
>> dosomethingelse
>> end if
> 
> From: Scott Raney <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> Date: Wed, 24 Nov 1999 13:22:54 -0700 (MST)
> To: [EMAIL PROTECTED]
> Subject: Re: More questions about mchttpd server
> 
> Maybe.  Assuming the $ stuff doesn't throw them.  You don't do this
> kind of thing in any other context (least of all in Mac CGIs).

Yes, your suggestion below is the best. I wrongly assumed that the $ in perl
was for environmental variables not simply scalar variables.

>> This is exactly the sort of thing I'd need to do if I were to write a perl
>> cgi (and it should work for .mt script exports). So I figure the mchttpd
>> server should set these automatically on all platforms (even if they are
>> only available to external processes on Unix).
> 
> Can you write CGIs on Mac with Perl?

Course you can -:)

...

>> This true for global variables?
> 
> Nope, just for environment variables (those globals with names that
> start with $).
> 

So your suggestion:

> Another method to consider is to pass all of the "environment
> variables" as a parameter array....

> cgiParams["REQUEST_METHOD"]

In perl (at least on the Mac -:) environmental variable are stored in a
"associative array" / "hash" in perl parlance. This array is the "special
%ENV hash, and you extract it's various components with a statement like
 
    print $ENV{'REQUEST_METHOD'}

How about doing this in mc as:

    put $ENV['REQUEST_METHOD']

where $ENV is an environmental variable (already used?) set by the server
containing an associative array with all the usual cgi stuff in.

or

    put ENV["REQUEST_METHOD"]

if it is decided to use a global. We could use a longer more explicit global
to avoid conflicts (ie mchttpdENV or dollarENV).

>>>> I like this idea. The problem I am having with it at the moment is that
>>>> according to a recent post adding a new cgi will only be possible in the
>>>> full development environment. If I am right this is because setting the
>>>> script length to greater than 10 lines will not be possible in the starter
>>>> kit. The only solution is to "do" 1 line at a time, or limit cgi's to 10
>>>> lines!
>>> 
>>> *Adding* a new CGI of any size would no problem.  Developing one of
>>> non-trivial complexity without a license could be difficult, though.
>>> Regards,
>>> Scott
>> 
>> How can I set the script of a Metacard stack to greater than 10 lines in the
>> starter kit. Didn't think this was possible from a script.
> 
> It isn't, nor would it typically be in a running mchttpd session
> (which shouldn't need to ever do this).  But if you've got a CGI that
> someone with the full license wrote, you could plug it in to your
> mchttpd server by just adding the name of that stack to a list of
> files that the server "starts using" when you start it up.  Each of
> those stacks would have one handler (or at least one main handler
> callable from mchttpd) that the browser would ask for a result from.
> Regards,
> Scott

Aha, go you. Start using my brain a bit more maybe -:) Now I'll have a look
at how to get at things like CONTENT_LEGNTH when the server recieves a
"POST" from a form. Is it the legnth of stdin, cos I couldn't see it in "the
params". If so what happens if the server receives more stuff by the time
the script gets to processing this?

Reply via email to