I’m running /usr/bin/perl or /usr/bin/php via an NSTask and want to retrieve the HTTP headers of the program. I’ve properly formatted the environment (Perl requires env vars to be prefixed with HTTP_), but neither of the task are returning anything other than raw output. I’ve been through the documentation on NSTask and the man pages for php and perl, and haven’t seen any way to force the output of HTTP headers.
Any ideas?
EDIT: I realize this is an ancient question, but I just rediscovered it and realized I should report back. The problem was that I should’ve been using php-cli, and not php. I had to download and compile php-cli from source to get this to work as I was expecting. Once I did, however, it worked like a charm. 🙂
You might have to prefix your output with the HTTP header, built by you based on the raw output from your perl or php script.
For example, you know that the raw output from a php script would be of content-type: text/html, and you can get the length from the output itself. At least I think that’s what I did when implementing a similar solution.