note 84599 deleted from function.fsockopen by cmb

From: Date: Sun, 07 Jul 2019 07:41:30 +0000
Subject: note 84599 deleted from function.fsockopen by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211488@lists.php.net to get a copy of this message
Note Submitter: admin at lab-9 dot com ---- 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. :-)

« previous php.notes (#211488) next »