Net
class Net
This general purpose library for HTTP communications.
This class attempts to solve the problem that lots of PHP environments have different approaches to doing GET and POST requests. Some use CURL and others use context streams. This code tries one way or another to figure out the best way to handle these and make these calls work using whatever library code that is available.
The best way for things work is for CURL to be avaialable. If CURL is available, it is used for everything and forks well.
Properties
static | $VERIFY_PEER |
Methods
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
Extract a set of header lines into an array
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
Send a 403 header
Send a 400 (Malformed request) header
Get the actual IP address of the incoming request.
No description
No description
Return true if the http code is 2xx (success)
Put as much oomph into setting a cookie as we can
Details
at line 30
static
getLastGETURL()
at line 34
static
getLastGETImpl()
at line 38
static
getLastHeadersSent()
at line 42
static
getLastHttpResponse()
at line 46
static
getLastCurlError()
at line 50
static
getLastHeadersReceived()
at line 54
static
getLastBODYURL()
at line 58
static
getLastBODYMethod()
at line 62
static
getLastBODYImpl()
at line 66
static
getLastBODYContent()
at line 71
static
getLastBODYDebug()
at line 96
static
parseHeaders($headerstr = false)
Extract a set of header lines into an array
Takes a newline separated header sting and returns a key/value array
at line 112
static
doGet($url, $header = false)
at line 139
static
getStream($url, $header = false)
at line 155
static
getCurl($url, $header = false)
at line 202
static
getBodySentDebug()
at line 214
static
getBodyReceivedDebug()
at line 230
static
getGetSentDebug()
at line 241
static
getGetReceivedDebug()
at line 260
static
doBody($url, $method, $body, $header)
at line 296
static
bodySocket($endpoint, $method, $data, $moreheaders = false)
at line 352
static
bodyStream($url, $method, $body, $header)
at line 370
static
bodyCurl($url, $method, $body, $header)
at line 438
static
send403($msg = null, $detail = null)
Send a 403 header
at line 454
static
send400($msg = 'Malformed request', $detail = null)
Send a 400 (Malformed request) header
at line 477
static string
getIP()
Get the actual IP address of the incoming request.
Handle being behind a load balancer or a proxy like Cloudflare. This will often return NULL when talking to localhost to make sure to test code using this on a real IP address.
Adapted from: https://www.chriswiegman.com/2014/05/getting-correct-ip-address-php/ With some additional explode goodness via: http://stackoverflow.com/a/25193833/1994792
at line 539
static
serverIP()
at line 547
static
isRoutable($ipaddr)
at line 558
static
httpSuccess($httpcode)
Return true if the http code is 2xx (success)
at line 565
static
setCookieStrong($name, $value, $domain, $expires)
Put as much oomph into setting a cookie as we can