Ejemplo n.º 1
0
 function go($force = 0, $asis = 0)
 {
     #-- prepare parts
     $url = $this->prepare_url();
     if (!$url && !$force) {
         return;
     }
     $BODY = $this->body($url);
     if ($BODY === false && !$force) {
         return;
     }
     $HEAD = $this->head($url);
     #-- open socket
     if (!$this->connect($url)) {
         return;
     }
     #-- send request data
     fwrite($this->socket, $HEAD);
     fwrite($this->socket, $BODY);
     $HEAD = false;
     $BODY = false;
     #-- read response, end connection
     while (!feof($this->socket) && strlen($DATA) <= 1 << 22) {
         $DATA .= fread($this->socket, 32 << 10);
         #echo "fread(".strlen($DATA).") ";
     }
     fclose($this->socket);
     unset($this->socket);
     #-- for raw http pings
     if ($asis) {
         return $DATA;
     }
     #-- decode response
     $r = new http_response();
     $r->from($DATA);
     // should auto-unset $DATA
     #-- handle redirects
     if ($this->active_client) {
         $this->auto_actions($r);
     }
     #-- fin
     return $r;
 }