當前位置: 首頁>>代碼示例>>PHP>>正文


PHP EntityBody::getContentLength方法代碼示例

本文整理匯總了PHP中Guzzle\Http\EntityBody::getContentLength方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityBody::getContentLength方法的具體用法?PHP EntityBody::getContentLength怎麽用?PHP EntityBody::getContentLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Guzzle\Http\EntityBody的用法示例。


在下文中一共展示了EntityBody::getContentLength方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setBody

 /**
  * Set the body of the request
  *
  * @param string|resource|EntityBody $body Body to use in the entity body
  *      of the request
  * @param string $contentType (optional) Content-Type to set.  Leave null
  *      to use an existing Content-Type or to guess the Content-Type
  * @param bool $tryChunkedTransfer (optional) Set to TRUE to try to use
  *      Tranfer-Encoding chunked
  *
  * @return EntityEnclosingRequest
  * @throws RequestException if the protocol is < 1.1 and Content-Length can
  *      not be determined
  */
 public function setBody($body, $contentType = null, $tryChunkedTransfer = false)
 {
     $this->body = EntityBody::factory($body);
     $this->removeHeader('Content-Length');
     $this->setHeader('Expect', '100-Continue');
     if ($contentType) {
         $this->setHeader('Content-Type', (string) $contentType);
     }
     if ($tryChunkedTransfer) {
         $this->setHeader('Transfer-Encoding', 'chunked');
     } else {
         $this->removeHeader('Transfer-Encoding');
         // Set the Content-Length header if it can be determined
         $size = $this->body->getContentLength();
         if ($size !== null && $size !== false) {
             $this->setHeader('Content-Length', $size);
         } else {
             if ('1.1' == $this->protocolVersion) {
                 $this->setHeader('Transfer-Encoding', 'chunked');
             } else {
                 throw new RequestException('Cannot determine entity body ' . 'size and cannot use chunked Transfer-Encoding when ' . 'using HTTP/' . $this->protocolVersion);
             }
         }
     }
     return $this;
 }
開發者ID:MicroSDHC,項目名稱:justinribeiro.com-examples,代碼行數:40,代碼來源:EntityEnclosingRequest.php

示例2: getContentLength

 /**
  * @return int
  */
 public function getContentLength()
 {
     return $this->contentLength !== null ? $this->contentLength : $this->content->getContentLength();
 }
開發者ID:santikrass,項目名稱:apache,代碼行數:7,代碼來源:DataObject.php

示例3: getContentLength

 /**
  * @return int
  */
 public function getContentLength()
 {
     return $this->contentLength ?: $this->content->getContentLength();
 }
開發者ID:fandikurnia,項目名稱:CiiMS,代碼行數:7,代碼來源:DataObject.php


注:本文中的Guzzle\Http\EntityBody::getContentLength方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。