Kevin 0 wrote: It's 'because I implemented HTTP1.1 wrong', even though it works for every site I tried, bar two.
I said that, and it's true. Read the RFC for HTTP 1.1 and you'll understand why it's wrong.
Get a network analyser on the job. Your script does not correctly handle chunked responses, which the HTTP 1.1 RFC says it is REQUIRED to do so. If your application cannot handle correct HTTP 1.1 responses, it should not send HTTP 1.1 requests.
Most web servers don't send chunked responses all of the time (after all, they're not required to) but some do.
READ THE RFC.
He offers no advice of how to do it right then says that implementing HTTP in PHP should ring alarm bells, for whatever reason. He then suggests using cURL or some sort of PEAR package (which would more than likely be written in PHP anyway!).
I give you three options:
- Use PHP's built-in http client (see the fopen wrappers section of the manual for more information) which is functional enough for most applications, and far more correct than yours.
- Use curl, which is more complicated to use and not always available, but provides greater functionality. Personally I haven't performance tested them so I'm not going to comment on runtime performance.
- Use a third party module, e.g. from PEAR which implements HTTP. There are several of these, I have never used any of them.
The first option involves no external modules or nonstandard parts of PHP, and should be your first choice (in my opinion)
So I explain curl/PEAR is not an option.... Next few posts: Use curl.
Is there anyone here who actually writes proper scripts? Not just using other peoples?
I write all my own scripts and never use other peoples'. I find them inferior. In the cases where I have used third party stuff (e.g. Wordpress) I've found them horrendous and unmaintainable.
Mark