コード例 #1
0
 function _SendRequest()
 {
     FMDebug("Path: " . $this->_aURLSplit["path"]);
     if (!isset($this->_aURLSplit["path"]) || $this->_aURLSplit["path"] === "") {
         $s_path = "/";
     } else {
         $s_path = $this->_aURLSplit["path"];
     }
     if (isset($this->_aURLSplit["query"])) {
         //
         // add the query to the path
         // Note that parse_url decodes the query string (urldecode), so
         // we need to split it into its component parameters
         // are re-encode their values.  Calling urlencode($this->_aURLSplit["query"])
         // encodes the '=' between parameters and this breaks things.
         //
         $a_params = explode('&', $this->_aURLSplit["query"]);
         foreach ($a_params as $i_idx => $s_param) {
             if (($i_pos = strpos($s_param, "=")) === false) {
                 $a_params[$i_idx] = urlencode($s_param);
             } else {
                 $a_params[$i_idx] = substr($s_param, 0, $i_pos) . '=' . urlencode(substr($s_param, $i_pos + 1));
             }
         }
         $s_path .= "?" . implode('&', $a_params);
     }
     //
     // add the fragment to the path.
     //
     if (isset($this->_aURLSplit["fragment"])) {
         $s_path .= '#' . urlencode($this->_aURLSplit["fragment"]);
     }
     //
     // build the request
     //
     $s_req = "GET {$s_path} HTTP/1.0\r\n";
     //
     // Add authentication
     //
     if (isset($this->_sAuthLine)) {
         $s_req .= "Authorization: {$this->_sAuthLine}\r\n";
     } elseif (isset($this->_sAuthType)) {
         $s_req .= "Authorization: " . $this->_sAuthType . " " . base64_encode($this->_sAuthUser . ":" . $this->_sAuthPass) . "\r\n";
     }
     //
     // Specify the host name
     //
     $s_req .= "Host: " . $this->GetHost() . "\r\n";
     //
     // Specify the user agent
     //
     if (isset($this->_sAgent)) {
         $s_req .= "User-Agent: " . $this->_sAgent . "\r\n";
     }
     //
     // Accept any output
     //
     $s_req .= "Accept: */*\r\n";
     //
     // End of request headers
     //
     $s_req .= "\r\n";
     $this->_sRequest = $s_req;
     return parent::Write($s_req);
 }
コード例 #2
0
ファイル: formmail.php プロジェクト: aaron-cheng/Pur
 function _SendRequest()
 {
     $this->_PrepareRequest();
     return NetIO::Write($this->_sRequest);
 }