Exemplo n.º 1
0
Arquivo: Net.php Projeto: na1iu/tsugi
 public static function doBody($url, $method, $body, $header)
 {
     global $LastBODYURL;
     global $LastBODYMethod;
     global $LastBODYImpl;
     global $LastHeadersSent;
     global $last_http_response;
     global $LastHeadersReceived;
     global $LastBODYResponse;
     $LastBODYURL = $url;
     $LastBODYMethod = $method;
     $LastBODYImpl = false;
     $LastHeadersSent = false;
     $last_http_response = false;
     $LastHeadersReceived = false;
     $LastBODYResponse = false;
     // Prefer curl because it checks if it works before trying
     $LastBODYResponse = NET::bodyCurl($url, $method, $body, $header);
     $LastBODYImpl = "CURL";
     if ($LastBODYResponse !== false) {
         return $LastBODYResponse;
     }
     $LastBODYResponse = NET::bodySocket($url, $method, $body, $header);
     $LastBODYImpl = "Socket";
     if ($LastBODYResponse !== false) {
         return $LastBODYResponse;
     }
     $LastBODYResponse = NET::bodyStream($url, $method, $body, $header);
     $LastBODYImpl = "Stream";
     if ($LastBODYResponse !== false) {
         return $LastBODYResponse;
     }
     $LastBODYImpl = "Error";
     error_log("Unable to {$method} Url={$url}");
     error_log("Header: {$header}");
     error_log("Body: {$body}");
     throw new \Exception("Unable to {$method} {$url}");
 }