Success! (WAS Grabbing HTTP Headers)

Dan Shafer dan at danshafer.com
Tue May 6 14:40:01 EDT 2003


Thanks, Monte, and to all of the other members of this list who jumped 
in to help here. While I'm not yet 100% sure why this script worked and 
the others didn't, it is nonetheless true. I now have the CGI parsing 
stuff working. I just need to understand what it is I need to explain 
to my readers so they can do this with far more ease than I did!

Off to write some more scripts and chapters.

Thanks again.

On Monday, May 5, 2003, at 12:39 AM, Monte Goulding wrote:

>
>> OK, I give up. I've spent a few hours researching this and haven't
>> found an answer.
>>
>> Using RR's MetaCard engine as a CGI, how do I grab the HTTP header of
>> the incoming request so I can parse it and do meaningful work? There
>> has to be a function that does this, but I am stymied trying to find
>> it. I have found the libURLLastHTTPHeaders() function but it isn't
>> working. Perhaps it's not included in the MetaCard engine and 
>> therefore
>> not available to CGI processing, but that seems weird because CGI is
>> probably 90% of the reason you'd ever want to to get an HTTP header!
>>
>> Here's my script, set up to run on the MC CGI engine. I know the 
>> engine
>> works. It's just this script that gives me the usual server
>> configuration error garbage.
>>
>> #!mc
>> on startUp
>>    put libURLLastHTTPHeaders() into tResponse
>>    put "Content-Type: text/html" & crlf
>>    put "Content-Length:" & (the length of tResponse) & crlf & crlf
>>    put tResponse
>> end startUp
>>
>> Help!
>
> Hi Dan
>
> libURL isn't part of the engine. It's just a library stack (in Rev 
> it's a
> back script). Get your version of MC and do the following:
> clone stack "libURL"
> set the name of it to "myLibURL"
> save stack "myLibURL" as "myLibURL.mc"
>
> then put it next to your CGI file
>
> Then change your CGI script to read:
>
> #!mc
> on startUp
>    library "mylibURL"
>    put libURLLastHTTPHeaders() into tResponse
>    put "Content-Type: text/html" & crlf
>    put "Content-Length:" & (the length of tResponse) & crlf & crlf
>    put tResponse
> end startUp
>
> However having said that libURL isn't designed for what you think it 
> is.
> It's  used for the url put, get, load, delete etc commands not for 
> CGI. I
> have no idea what you will get from the above but probably not much.
>
> The following is a copy of the old echo.cgi script I cut my teeth on:
>
> #!mc
> # This MetaTalk script loops over all the environment variables
> # set by the server when it runs a CGI application printing out
> # its name and value.
> on startup
> # loop over all of the global variables, getting name and value
>   repeat for each item i in the globals
>    put i && "=" && value(i)& return after buffer
>   end repeat
> # write minimal set of HTTP headers to stdout
>   read from stdin until empty
>   put it after buffer
>   replace cr with "<P>" in buffer
>   put "Content-Type: text/plain" & cr
>   put "Content-Length:" && the length of buffer & cr & cr
>   put buffer
>  end startup
>
> Hope this helps
>
> Monte
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
================================================
Dan Shafer, Author, Consultant, Product Development Expert
http://www.shafermedia.com
You are nearly 3 times more likely to need a lawyer than a hospital:
http://www.prepaidlegal.com/info/danshafer




More information about the use-livecode mailing list