send() публичный статический Метод

public static send ( $method, $hostname, $port, $url_path, $data = [], $headers = [] )
Пример #1
0
function paste_content()
{
    include 'lib/amy/simple_http.php';
    $url = parse_url($_REQUEST['frame_url']);
    $headers = array();
    $params = array();
    $query = explode('=', $url['query']);
    $n = sizeof($query);
    for ($i = 0; $i < $n; $i += 2) {
        $params[$query[$i]] = $query[$i + 1];
    }
    $response = SimpleHTTP::send('GET', $url['host'], 80, $url['path'], $params, $headers);
    echo $response['body'];
}
Пример #2
0
 public static function save_resource($project_url, $ticket, $path, $content)
 {
     $url = fix_parse_url($project_url);
     $response = SimpleHTTP::send('POST', $url['host'], $url['port'], $url['path'], array('a' => 'save_resource', 'ticket' => $ticket, 'path' => $path, 'content' => $content));
     if ('200' != $response['status_code']) {
         throw new Exception("Invalid status code `{$response['status_code']}' returned from server `{$url['host']}'.");
     }
     $content = trim($response['body']);
     if ('' === $content) {
         throw new Exception("Unable to save project resource, no content returned from `{$url['host']}{$url['path']}'.");
     }
     if ('#S#' != substr($content, 0, 3)) {
         throw new Exception("Error while saving resource: Message from {$url['host']}{$url['path']}: " . substr($content, 3));
     }
     return true;
 }
Пример #3
0
 public function save($path, $content)
 {
     $path = $this->get_encoded_path($path);
     $headers = array('Depth' => $depth, 'Authorization' => 'Basic ' . base64_encode($this->username . ':' . $this->password));
     $response = SimpleHTTP::send('PUT', $this->host, $this->port, $path, $content, $headers);
     return '2' == substr($response['status_code'] . '', 0, 1);
 }