wppaste
WordPress

Fsockopen

Source
wp-includes/Requests/src/Transport/Fsockopen.php:25
fsockopen HTTP transport

Compatibility

WordPress
core
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 4

$headersstringpublic
Raw HTTP data
$infoarraypublic
Stream metadata
$max_bytesint|boolprivate
What's the maximum number of bytes we should keep?
$connect_errorstringprivate
Cache for received connection errors.

Methods · 7

Source code

final class Fsockopen implements Transport {	/**	 * Second to microsecond conversion	 *	 * @var integer	 */	const SECOND_IN_MICROSECONDS = 1000000; 	/**	 * Raw HTTP data	 *	 * @var string	 */	public $headers = ''; 	/**	 * Stream metadata	 *	 * @var array Associative array of properties, see {@link https://www.php.net/stream_get_meta_data}	 */	public $info; 	/**	 * What's the maximum number of bytes we should keep?	 *	 * @var int|bool Byte count, or false if no limit.	 */	private $max_bytes = false; 	/**	 * Cache for received connection errors.	 *	 * @var string	 */	private $connect_error = ''; 	/**	 * Perform a request	 *	 * @param string|Stringable $url URL to request	 * @param array $headers Associative array of request headers	 * @param string|array $data Data to send either as the POST body, or as parameters in the URL for a GET/HEAD	 * @param array $options Request options, see {@see \WpOrg\Requests\Requests::response()} for documentation	 * @return string Raw HTTP result	 *	 * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $url argument is not a string or Stringable.	 * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $headers argument is not an array.	 * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $data parameter is not an array or string.	 * @throws \WpOrg\Requests\Exception\InvalidArgument When the passed $options argument is not an array.	 * @throws \WpOrg\Requests\Exception       On failure to connect to socket (`fsockopenerror`)	 * @throws \WpOrg\Requests\Exception       On socket timeout (`timeout`)	 */	public function request($url, $headers = [], $data = [], $options = []) {		if (InputValidator::is_string_or_stringable($url) === false) {			throw InvalidArgument::create(1, '$url', 'string|Stringable', gettype($url));		} 		if (is_array($headers) === false) {			throw InvalidArgument::create(2, '$headers', 'array', gettype($headers));		} 		if (!is_array($data) && !is_string($data)) {			if ($data === null) {				$data = '';			} else {				throw InvalidArgument::create(3, '$data', 'array|string', gettype($data));			}		} 		if (is_array($options) === false) {			throw InvalidArgument::create(4, '$options', 'array', gettype($options));		} 		$options['hooks']->dispatch('fsockopen.before_request'); 		$url_parts = parse_url($url);		if (empty($url_parts)) {			throw new Exception('Invalid URL.', 'invalidurl', $url);		}

Changelog

Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/Requests/src/Transport/Fsockopen.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.