Re: POST without POSTing
| From: | Lars Torben Wilson | Date: | Thu, 01 Oct 2009 05:16:39 +0000 |
| Subject: | Re: POST without POSTing | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-298432@lists.php.net to get a copy of this message | ||
On Thu, 1 Oct 2009 00:24:41 -0400
Daniel Brown <danbrown@php.net> wrote:
> On Thu, Oct 1, 2009 at 00:16, Paul M Foster <paulf@quillandmouse.com>
> wrote:
> >
> > However, assuming it *wasn't*, I've found the following example
> > from a google search (thank goodness for google's "hinting" or I
> > couldn't have found it):
> >
> > $fp = fsockopen("www.site.com", 80);
> > fputs($fp, "POST /script.php HTTP/1.0
> > Host: www.site.com
> > Content-Length: 7
> >
> > q=proxy");
> >
> > I don't know much about doing things this way. It appears that when
> > done this way, the "body" must be separated by a newline, just like
> > email. And it appears that the content-length of 7 indicates the
> > length of the "q=proxy" string. Assuming I piled on a few other
> > passed variables the same way as "q", separated by newlines (and
> > adjusted the Content-Length accordingly), would the above work? Are
> > there liabilities to doing it this way?
>
> Yes. Hosts are more likely to have cURL installed and available
> than fsockopen() or URL-based fopen() calls, so portability is greater
> with cURL. It's also a bit faster. Still, as you know, there's
> always more than one way to skin a cute, furry, delicious little
> kitten.
>
I stand corrected on that point--in that way, yes, it would be a
liability. Happily it's been so long since I've had to use that kind of
host that I don't usually consider that a problem. But yes, if you're
using free or low-end hosting then you might have to contend with that.
Ugly, but true.
Torben