Re: Ramsus: Post Vars?
| From: | Rasmus Lerdorf | Date: | Mon, 24 Jul 2000 01:04:36 +0000 |
| Subject: | Re: Ramsus: Post Vars? | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-25632@lists.php.net to get a copy of this message | ||
> I don't know if you've been following this thread in the general list, but
> it's a concern that has been rasied that I was wondering if you could shed
> some light on. Is there any way to provide $HTTP_RAW_POST_VARS and the
> parsed, $HTTP_POST_VARS versions at the same time? It would seem to me that
> the Raw data probably is freed up once it has been parsed, but as you can
> see here it still has use for non form posted data. Is there any way to
> enable them as you would POST_VARS?
HTTP_RAW_POST_DATA is only set if PHP encounters an unrecognized encoding
type. Setting it for the regular form-urlencoded type would be a waste of
memory as you would then have two copies in memory. And it is trivial to
get the raw data from the decoded data. Something like:
$first=1;
while(list($k,$v)=each($HTTP_POST_VARS)) {
if($first) $data = urlencode($k) . '=' . urlencode($v);
else $data .= '&' . urlencode($k) . '=' . urlencode($v);
}
Now $data would contain the original posted data string. There are some
broken applications out there that do not send POST data in
application/x-www-form-urlencoded nor multipart/form-data (which is a file
upload). For these apps PHP gives up trying to parse the data and just
makes the raw data available in $HTTP_RAW_POST_DATA.
I believe this is the correct and efficient way to treat posted data and
have yet to see a decent argument counter to that.
-Rasmus