当前位置: 首页>>代码示例>>PHP>>正文


PHP HTTP_Request2::getBody方法代码示例

本文整理汇总了PHP中HTTP_Request2::getBody方法的典型用法代码示例。如果您正苦于以下问题:PHP HTTP_Request2::getBody方法的具体用法?PHP HTTP_Request2::getBody怎么用?PHP HTTP_Request2::getBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HTTP_Request2的用法示例。


在下文中一共展示了HTTP_Request2::getBody方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: calculateRequestLength

 /**
  * Calculates length of the request body, adds proper headers
  *
  * @param    array   associative array of request headers, this method will
  *                   add proper 'Content-Length' and 'Content-Type' headers
  *                   to this array (or remove them if not needed)
  */
 protected function calculateRequestLength(&$headers)
 {
     $this->requestBody = $this->request->getBody();
     if (is_string($this->requestBody)) {
         $this->contentLength = strlen($this->requestBody);
     } elseif (is_resource($this->requestBody)) {
         $stat = fstat($this->requestBody);
         $this->contentLength = $stat['size'];
         rewind($this->requestBody);
     } else {
         $this->contentLength = $this->requestBody->getLength();
         $headers['content-type'] = 'multipart/form-data; boundary=' . $this->requestBody->getBoundary();
         $this->requestBody->rewind();
     }
     if (in_array($this->request->getMethod(), self::$bodyDisallowed) || 0 == $this->contentLength) {
         // No body: send a Content-Length header nonetheless (request #12900),
         // but do that only for methods that require a body (bug #14740)
         if (in_array($this->request->getMethod(), self::$bodyRequired)) {
             $headers['content-length'] = 0;
         } else {
             unset($headers['content-length']);
             // if the method doesn't require a body and doesn't have a
             // body, don't send a Content-Type header. (request #16799)
             unset($headers['content-type']);
         }
     } else {
         if (empty($headers['content-type'])) {
             $headers['content-type'] = 'application/x-www-form-urlencoded';
         }
         $headers['content-length'] = $this->contentLength;
     }
 }
开发者ID:ahanjir07,项目名称:vivvo-dev,代码行数:39,代码来源:Adapter.php

示例2: testSetMultipartBody

 public function testSetMultipartBody()
 {
     require_once 'HTTP/Request2/MultipartBody.php';
     $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_POST);
     $body = new HTTP_Request2_MultipartBody(array('foo' => 'bar'), array());
     $req->setBody($body);
     $this->assertSame($body, $req->getBody());
 }
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:8,代码来源:Request2Test.php

示例3: getBody

 /**
  * Gets the request body.
  * 
  * @return string
  */
 public function getBody()
 {
     return $this->_request->getBody();
 }
开发者ID:southworkscom,项目名称:azure-sdk-for-php,代码行数:9,代码来源:HttpClient.php

示例4: getBody

 public function getBody()
 {
     if ($this->nvpRequest) {
         $ret = "";
         foreach ($this->postParams as $k => $v) {
             if ($ret) {
                 $ret .= '&';
             }
             $ret .= sprintf("%s[%d]=%s", $k, strlen($v), $v);
         }
         return $ret;
     } else {
         return parent::getBody();
     }
 }
开发者ID:irovast,项目名称:eyedock,代码行数:15,代码来源:HttpRequest.php

示例5: debugCall

 /**
  * Collect debug information on the last call.
  *
  * @return array
  * @uses   self::$client
  */
 public function debugCall()
 {
     return array('event' => $this->client->getLastEvent(), 'url' => (string) $this->client->getUrl(), 'data' => $this->client->getBody(), 'method' => $this->client->getMethod());
 }
开发者ID:hypertiny,项目名称:Services_UseKetchup,代码行数:10,代码来源:Common.php

示例6: getBodyArray

 /**
  * Получаем данные от Яндекса в форме массива.
  *
  * @param HTTP_Request2 $resp Объект запроса
  *
  * @return array
  */
 public function getBodyArray($resp)
 {
     if ($resp == '') {
         return array();
     }
     $body = json_decode($resp->getBody(), true);
     return $body;
 }
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:15,代码来源:walletWebmoney.php

示例7: _send_request

 private function _send_request()
 {
     try {
         $response = $this->request->send();
     } catch (Exception $e) {
         debug_add("Failed to execute request " . $this->request->getUrl() . ": " . $e->getMessage(), MIDCOM_LOG_WARN);
         return false;
     }
     $this->code = $response->getStatus();
     if ($this->code != 200) {
         debug_print_r($this->request->getUrl() . " returned response code {$this->code}, body:", $response->getBody());
         debug_print_r('Request content:', $this->request->getBody());
         return false;
     }
     return true;
 }
开发者ID:nemein,项目名称:openpsa,代码行数:16,代码来源:solr.php

示例8: TRB_detectTrackbackUrl

/**
 * Attempt to auto-detect the Trackback URL of a post.
 *
 * @param    string $url URL of post with embedded RDF for the Trackback URL
 * @return   mixed           Trackback URL, or false on error
 *                       Note: The RDF, if found, is only parsed using a regular expression. Using
 *                       the XML parser may be more successful on some occassions ...
 */
function TRB_detectTrackbackUrl($url)
{
    $retval = false;
    $req = new HTTP_Request2($url, HTTP_Request2::METHOD_GET);
    $req->setHeader('User-Agent', 'Geeklog/' . VERSION);
    try {
        $response = $req->send();
    } catch (HTTP_Request2_Exception $e) {
        COM_errorLog('TRB_detectTrackbackUrl: ' . $e->getMessage());
        return false;
    }
    $page = $req->getBody();
    // search for the RDF first
    $startPos = strpos($page, '<rdf:RDF ');
    if ($startPos !== false) {
        $endPos = strpos($page, '</rdf:RDF>', $startPos);
        $endPos += strlen('</rdf:RDF>');
        $rdf = substr($page, $startPos, $endPos - $startPos);
        // Okay, we COULD fire up the XML parser now. But then again ...
        if (preg_match('/trackback:ping="(.*)"/', $rdf, $matches) == 1) {
            if (!empty($matches[1])) {
                $retval = $matches[1];
            }
        }
    }
    // no luck with the RDF? try searching for a rel="trackback" link
    if ($retval === false) {
        // remove all linefeeds first to help the regexp below
        $page = str_replace(array("\r", "\n"), '', $page);
        preg_match_all("/<a[^>]*href=[\"']([^\"']*)[\"'][^>]*>(.*?)<\\/a>/i", $page, $matches);
        for ($i = 0; $i < count($matches[0]); $i++) {
            $link = $matches[0][$i];
            if (strpos($link, 'rel="trackback"') !== false) {
                $retval = $matches[1][$i];
                break;
            }
        }
    }
    return $retval;
}
开发者ID:Geeklog-Core,项目名称:geeklog,代码行数:48,代码来源:lib-trackback.php

示例9: isDoubleCcTld

 /**
  * Check if the last two parts of the FQDN are whitelisted.
  *
  * @param string $fqdn Host to check if it is whitelisted.
  *
  * @access protected
  * @return boolean True if the host is whitelisted
  */
 protected function isDoubleCcTld($fqdn)
 {
     // 30 Days should be way enough
     $options = array('lifeTime' => '2592000', 'automaticSerialization' => true);
     $id = md5($this->doubleCcTldFile);
     $cache = new Cache_Lite($options);
     if ($data = $cache->get($id)) {
         // Cache hit
     } else {
         // Cache miss
         $http = new HTTP_Request2($this->doubleCcTldFile);
         if (!PEAR::isError($http->send())) {
             $data = $http->getBody();
         }
         $data = explode("\n", $data);
         $data = array_flip($data);
         $cache->save($data, $id);
     }
     // if
     if (array_key_exists($fqdn, $data)) {
         return true;
     } else {
         return false;
     }
     // if
 }
开发者ID:jimjag,项目名称:Serendipity,代码行数:34,代码来源:SURBL.php

示例10: testBug17460

 public function testBug17460()
 {
     $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_POST);
     $req->addPostParameter('foo', 'bar')->setHeader('content-type', 'application/x-www-form-urlencoded; charset=UTF-8');
     $this->assertEquals('foo=bar', $req->getBody());
 }
开发者ID:SuhitNarayan,项目名称:SuhitNarayan-SEMANTICTECH,代码行数:6,代码来源:Request2Test.php

示例11: sendRequest

 public function sendRequest(HTTP_Request2 $request)
 {
     $this->requests[] = array('config' => $request->getConfig(), 'url' => $request->getUrl(), 'method' => $request->getMethod(), 'headers' => $request->getHeaders(), 'auth' => $request->getAuth(), 'body' => (string) $request->getBody());
     return parent::sendRequest($request);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:5,代码来源:TraceHttpAdapter.php


注:本文中的HTTP_Request2::getBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。