note 84599 added to function.fsockopen
| From: | admin at lab-9 dot com | Date: | Mon, 21 Jul 2008 12:32:01 +0000 |
| Subject: | note 84599 added to function.fsockopen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-142418@lists.php.net to get a copy of this message | ||
When you try to POST/GET requests via HTTPS over SSL/TLS you should notice this:
<?php
// preconditions
$port = 80 | 443
$host = "www.example.com";
$method = "POST" | "GET";
$contenttype = "text/html" | "text/plain" | "text/xml" | ...;
$data = "<something>";
// script
if($port == 443)
$sslhost = "ssl://".$host;
else
$sslhost = $host;
$fp = fsockopen($sslhost, $port);
fputs($fp, "$method $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Content-type: $contenttype\r\n");
fputs($fp, "Content-length: ".strlen($data)."\r\n");
fputs($fp, "Connection: close\r\n");
fputs($fp, "\r\n");
?>
The server usually does not understand the HTTP-header "Host: XXX" if you provide it with
the trailing "ssl://" used by fsockopen(); If you do it anyway you probably get a HTTP 400
back as response. :-)
----
Server IP: 69.147.83.197
Probable Submitter: 81.223.54.114
----
Manual Page -- http://www.php.net/manual/en/function.fsockopen.php
Edit -- https://master.php.net/note/edit/84599
Del: integrated -- https://master.php.net/note/delete/84599/integrated
Del: useless -- https://master.php.net/note/delete/84599/useless
Del: bad code -- https://master.php.net/note/delete/84599/bad+code
Del: spam -- https://master.php.net/note/delete/84599/spam
Del: non-english -- https://master.php.net/note/delete/84599/non-english
Del: in docs -- https://master.php.net/note/delete/84599/in+docs
Del: other reasons-- https://master.php.net/note/delete/84599
Reject -- https://master.php.net/note/reject/84599
Search -- https://master.php.net/manage/user-notes.php