PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Im starting to drive sockets and http header, i was testing this but i have a problem and i dont know why/where
i took like url example to devnetwork (tested with other and too dont work)
visonardo wrote:how can i do to dont show that? it appear before html code, but suposedly it would not appear
What?
I'll guess that you mean "I don't want to show the headers." To which the response is, headers are denoted as the first paragraph of the returned information. So look for the first blank line. Once you find it, all before that is the headers. Everything afterward is the page content.
Connection: close SHOULD be specified but doesn't NEED to be. It just tells the server it's OK to hang up once it's all done. there's generally no reason you'd want them not to and 99% of the time they will do anyway.
Headers are separated from the content by <CRLF><CRLF> so as soon as you fgets() a line which is just \r\n you can start cacthing the content into a string.
Note that you'll want to check for things like chunked encoding since your data will look odd if not
EDIT | I just noticed you're using HTTP 1.0 so ignore my comment about chunked encoding.