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


PHP Request::getHeaders方法代碼示例

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


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

示例1: setCurlOptsFromRequest

 protected static function setCurlOptsFromRequest($curl, Message\Request $request)
 {
     curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request->getMethod());
     curl_setopt($curl, CURLOPT_URL, $request->getUrl());
     curl_setopt($curl, CURLOPT_HTTPHEADER, $request->getHeaders());
     curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getContent());
 }
開發者ID:richardmiller,項目名稱:Linktuesday.com,代碼行數:7,代碼來源:Curl.php

示例2: getHeaders

 public function getHeaders()
 {
     $headers = parent::getHeaders();
     if ($this->isSafe()) {
         return $headers;
     }
     if ($this->isMultipart()) {
         $headers[] = 'Content-Type: multipart/form-data; boundary=' . $this->getBoundary();
     } else {
         $headers[] = 'Content-Type: application/x-www-form-urlencoded';
     }
     return $headers;
 }
開發者ID:ChazalFlorian,項目名稱:enjoyPangolin,代碼行數:13,代碼來源:FormRequest.php

示例3: setCurlOptsFromRequest

 protected static function setCurlOptsFromRequest($curl, Message\Request $request)
 {
     $options = array(CURLOPT_CUSTOMREQUEST => $request->getMethod(), CURLOPT_URL => $request->getUrl(), CURLOPT_HTTPHEADER => $request->getHeaders(), CURLOPT_HTTPGET => false, CURLOPT_NOBODY => false, CURLOPT_POSTFIELDS => null);
     switch ($request->getMethod()) {
         case Message\Request::METHOD_HEAD:
             $options[CURLOPT_NOBODY] = true;
             break;
         case Message\Request::METHOD_GET:
             $options[CURLOPT_HTTPGET] = true;
             break;
         case Message\Request::METHOD_POST:
         case Message\Request::METHOD_PUT:
             $options[CURLOPT_POSTFIELDS] = $fields = self::getPostFields($request);
             // remove the content-type header
             if (is_array($fields)) {
                 $options[CURLOPT_HTTPHEADER] = array_filter($options[CURLOPT_HTTPHEADER], function ($header) {
                     return 0 !== strpos($header, 'Content-Type: ');
                 });
             }
             break;
     }
     curl_setopt_array($curl, $options);
 }
開發者ID:kingsj,項目名稱:core,代碼行數:23,代碼來源:Curl.php

示例4: removeCsrfHeader

 /**
  * Removes the CSRF token header from a $request.
  *
  * @param Request $request
  */
 private function removeCsrfHeader(Request $request)
 {
     foreach ($request->getHeaders() as $headerString) {
         list($headerName) = explode(': ', $headerString);
         if (strtolower($headerName) !== 'x-csrf-token') {
             $headers[] = $headerString;
         }
     }
     $request->setHeaders($headers);
 }
開發者ID:ezsystems,項目名稱:ezpublish-kernel,代碼行數:15,代碼來源:SessionTest.php

示例5: testCookieMerge

 public function testCookieMerge()
 {
     $request = new Request();
     $request->addHeader('Cookie: foo=bar');
     $request->addHeader('Content-Type: text/plain');
     $request->addHeader('Cookie: bar=foo');
     $this->assertEquals(array('Cookie: foo=bar; bar=foo', 'Content-Type: text/plain'), $request->getHeaders());
     $expected = "GET / HTTP/1.0\r\n";
     $expected .= "Cookie: foo=bar; bar=foo\r\n";
     $expected .= "Content-Type: text/plain\r\n";
     $this->assertEquals($expected, (string) $request);
 }
開發者ID:saberyounis,項目名稱:Sonata-Project,代碼行數:12,代碼來源:RequestTest.php

示例6: getStreamContextArray

 /**
  * Converts a request into an array for stream_context_create().
  * 
  * @param Message\Request $request A request object
  * 
  * @return array An array for stream_context_create()
  */
 public function getStreamContextArray(Message\Request $request)
 {
     return array('http' => array('method' => $request->getMethod(), 'header' => implode("\r\n", $request->getHeaders()), 'content' => $request->getContent(), 'protocol_version' => $request->getProtocolVersion(), 'ignore_errors' => $this->getIgnoreErrors(), 'max_redirects' => $this->getMaxRedirects(), 'timeout' => $this->getTimeout()));
 }
開發者ID:richardmiller,項目名稱:Linktuesday.com,代碼行數:11,代碼來源:AbstractStream.php


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