Grabbing HTTP Header

Dan Shafer dan at eclecticity.com
Mon May 5 12:52:01 EDT 2003


>At 6:23 pm -0700 4/5/03, Dan Shafer wrote:
>>OK, I give up. What's the function/method/magic incantation to grab
>>the incoming HTTP header in the MC CGI?
>>
>>I know what to do with this info once I have it but I'm darned if I
>>can find any reference to anything resembling HTTP headers.
>
Dave Cragg answered in part:

>I don't think there is a way to get all the headers at one time. But 
>the headers are exported to environment variables by the http server. 
>You can access these directly. I assume this is done according to the 
>CGI standard.

There *is* a function in libURL called "libURLLastHTTPHeaders()" that at least *sounded* like it would do what I want. I saw a reference somewhere to grabbing the headers and then doing a line-parse on them.

But that function doesn't seem to work in the mc CGI engine. At least I'm speculating that's the problem. Here's my simple-dimple script:

#!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

I figured I'd just spit the header back and at least confirm this was working. But I get the ubiquitous and completely unhelpful "server configuration" error. My current theory is that libURL isn't included in the MC engine (which would make no sense to me but if it's reality, I'll deal with it).

So now I'll be off trying to figure out how to communicate directly with the environment and hunt down these environment variables from inside the CGI engine. This is fun; I hope it also turns out to be rewarding!




More information about the metacard mailing list