WireHttp class

WireHttp enables you to send HTTP requests to URLs, download files, and more.

// Get an instance of WireHttp
$http = new WireHttp();
// Get the contents of a URL
$response = $http->get("http://domain.com/path/");
if($response !== false) {
  echo "Successful response: " . $sanitizer->entities($response);
} else {
  echo "HTTP request failed: " . $http->getError();

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the WireHttp class also inherits all the methods and properties of: Wire.

Show $var?             Show args?        


string arrayGet a string of the last error message 
(nothing)Send an HTTP status header 


$thisSet an array of data, or string of raw data to send with next GET/POST/etc. request (overwriting the existing data or rawData) 
arraySet options array given to $sanitizer->url() 

HTTP requests

Request headers

arrayGet all currently set request headers in an associative array 
stringGet the current user-agent header 
$http->setCookie(string $name, $value)
selfSet cookie(s) for http GET/POST/etc. request (currently used by curl option only) 
$http->setHeader(string $key, string $value)
$thisSend an individual request header to send with GET/POST/etc. request 
$http->setHeaders(array $headers)
$thisSet an array of request headers to send with GET/POST/etc. request 
$http->setUserAgent(string $userAgent)
(nothing)Set the current user-agent header 

Response headers

array string nullGet the last HTTP response headers (normal array). 
array string nullGet last HTTP response headers with multi-value headers as arrays 
array string nullGet the last HTTP response headers (associative array) 

HTTP codes

arrayReturn array of all possible HTTP error codes as (code => description) 
int stringGet last HTTP code 
arrayReturn array of all possible HTTP codes as (code => description) 
arrayReturn array of all possible HTTP success codes as (code => description) 


arrayReturn array of allowed schemes 
floatGet the number of seconds till connection times out 
$thisSet schemes WireHttp is allowed to access (default=[http, https]) 
$thisSet the number of seconds till connection times out 

Additional methods and properties

In addition to the methods and properties above, WireHttp also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.200

Twitter updates

  • Weekly update, July 29: Continuing upgrades to ProcessWire’s comments system and FormBuilder, along with a working example—More
    29 July 2022
  • Weekly update for July 22– Looking back at what web development was like in the year 2000. Plus some more discussion on the path from CKEditor 4 to CkEditor 5 in ProcessWire: More
    22 July 2022
  • ProcessWire 3.0.203 core updates: new support for custom fields on comments and more— More
    15 July 2022

Latest news

  • ProcessWire Weekly #429
    In the 429th issue of ProcessWire Weekly we'll check out the latest core updates, introduce a new third party module, and more. Read on!
    Weekly.pw / 30 July 2022
  • Debugging tools built into ProcessWire
    ProcessWire's core comes with a lot of helpful debugging tools and capabilities built-in. In this post we'll cover some of these useful tools and how to use them.
    Blog / 1 July 2022
  • Subscribe to weekly ProcessWire news

“ProcessWire is like a breath of fresh air. So powerful yet simple to build with and customise, and web editors love it too.” —Margaret Chatwin, Web developer