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


PHP Headers::addHeaderLine方法代码示例

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


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

示例1:

 function it_should_be_use_constant(Headers $headers)
 {
     $headers->clearHeaders()->shouldBeCalledTimes(1);
     $headers->addHeaderLine("Content-Type", "application/json")->shouldBeCalledTimes(1);
     $headers->addHeaderLine("Authorization", "token token")->shouldBeCalledTimes(1);
     $this->setHeaders($headers);
     $this->setStatusFor("aaa", ["state" => \Gstatus\Request\Status::FAILURE]);
     $this->prepareRequest("token");
     $this->getContent()->shouldBe('{"state":"failure"}');
 }
开发者ID:gianarb,项目名称:gstatus,代码行数:10,代码来源:StatusSpec.php

示例2: getHeadersFromResponse

 /**
  * @param \Zend_Controller_Response_Abstract $response
  * @return \Zend\Http\Headers
  */
 protected function getHeadersFromResponse(\Zend_Controller_Response_Abstract $response)
 {
     $headers = new HttpHeaders();
     foreach ($response->getRawHeaders() as $header) {
         $headers->addHeaderLine($header);
     }
     foreach ($response->getHeaders() as $header) {
         $headers->addHeaderLine($header['name'], $header['value']);
     }
     return $headers;
 }
开发者ID:xemlock,项目名称:Zf1Module,代码行数:15,代码来源:RenderListener.php

示例3: testClearHeaderAndHeaderNotExists

 public function testClearHeaderAndHeaderNotExists()
 {
     $response = $this->response = $this->getMock('Magento\\Framework\\HTTP\\PhpEnvironment\\Response', ['getHeaders', 'send']);
     $this->headers->addHeaderLine('Header-name: header-value');
     $header = \Zend\Http\Header\GenericHeader::fromString('Header-name: header-value');
     $this->headers->expects($this->once())->method('has')->with('Header-name')->will($this->returnValue(false));
     $this->headers->expects($this->never())->method('get')->with('Header-name')->will($this->returnValue($header));
     $this->headers->expects($this->never())->method('removeHeader')->with($header);
     $response->expects($this->once())->method('getHeaders')->will($this->returnValue($this->headers));
     $response->clearHeader('Header-name');
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:11,代码来源:ResponseTest.php

示例4: disableHttpCache

 /**
  * Prepare cache-busting headers for GET requests
  *
  * Invoked from the onFinish() method for GET requests to disable client-side HTTP caching.
  *
  * @param Headers $headers
  */
 protected function disableHttpCache(Headers $headers)
 {
     $headers->addHeader(new GenericHeader('Expires', '0'));
     $headers->addHeader(new GenericMultiHeader('Cache-Control', 'no-store, no-cache, must-revalidate'));
     $headers->addHeader(new GenericMultiHeader('Cache-Control', 'post-check=0, pre-check=0'));
     $headers->addHeaderLine('Pragma', 'no-cache');
 }
开发者ID:zfcampus,项目名称:zf-apigility-admin,代码行数:14,代码来源:DisableHttpCacheListener.php

示例5: indexAction

 /**
  * {@inheritDoc}
  *
  * @return Stream|Response
  */
 public function indexAction()
 {
     $response = $this->getResponse();
     $params = $this->params()->fromRoute();
     if ($params['path'] === '') {
         $response->setStatusCode(404);
         return $response;
     }
     $info = pathinfo($params['path']);
     if ($info['dirname'] === '.') {
         $info['dirname'] = '';
     }
     /* @var $folder \CmsFile\Mapping\FolderInterface */
     $folder = $this->getFolderService()->getMapper()->findOneByPath('/' . trim($info['dirname'], '/'));
     if (!$folder) {
         $response->setStatusCode(404);
         return $response;
     }
     $file = $folder->getFile($info['basename']);
     if (!$file) {
         $response->setStatusCode(404);
         return $response;
     }
     $response = new Stream();
     $response->setStream(fopen($file, 'r'));
     $response->setStatusCode(200);
     $headers = new Headers();
     $headers->addHeaderLine('Content-Type', $file->getType())->addHeaderLine('Content-Disposition', 'attachment; filename="' . $file->getTitle() . '"')->addHeaderLine('Content-Length', filesize($file));
     $response->setHeaders($headers);
     return $response;
 }
开发者ID:coolms,项目名称:file,代码行数:36,代码来源:IndexController.php

示例6: get

 public function get($id)
 {
     $headers = new Headers();
     $headers->addHeaderLine('Access-Control-Allow-Origin', '*');
     $json = new JsonModel(array('data' => $this->listadoCursos($id)));
     return $json;
 }
开发者ID:sebaxplace,项目名称:skilla-local,代码行数:7,代码来源:EjemploServidorRestfulController.php

示例7: injectEsiHeader

 /**
  *
  */
 private function injectEsiHeader()
 {
     if (!$this->esiHeaderInjected) {
         $this->responseHeaders->addHeaderLine('Surrogate-Control', 'ESI/1.0');
         $this->esiHeaderInjected = true;
     }
 }
开发者ID:hummer2k,项目名称:convarnish,代码行数:10,代码来源:InjectCacheHeaderListener.php

示例8: nearby

 public static function nearby($countryCode, $postalCode)
 {
     $http = new Client();
     $http->setOptions(array('sslverifypeer' => false));
     $headers = new Headers();
     $headers->addHeaderLine('Content-Type', 'application/json');
     $http->setHeaders($headers);
     $http->setUri(self::$apiUrl . 'nearby/' . urlencode($countryCode) . '/' . urlencode($postalCode));
     $http->setMethod('GET');
     $response = $http->send();
     $json = Json::decode($response->getBody());
     return $json;
 }
开发者ID:TomHAnderson,项目名称:ZippopotamusClient-PHP,代码行数:13,代码来源:Zippopotamus.php

示例9: testGet

 public function testGet()
 {
     $expectedDate = '2015-01-01';
     $headers = new Headers();
     $headers->addHeaderLine(sprintf('Cookie: %s=%s', TimetableCookieListener::COOKIE_NAME, $expectedDate));
     $request = new Request();
     $request->setHeaders($headers);
     $response = new Response();
     $listener = new TimetableCookieListener($request, $response);
     $event = new TimetableManagerEvent();
     $listener->getTime($event);
     $this->assertTrue($event->hasPointInTime());
     $this->assertEquals($expectedDate, $event->getPointInTime()->format('Y-m-d'));
 }
开发者ID:nathansalter,项目名称:verona,代码行数:14,代码来源:TimetableCookieListenerTest.php

示例10: getCountries

 public static function getCountries()
 {
     $http = new Client();
     $http->setOptions(array('sslverifypeer' => false));
     $headers = new Headers();
     $headers->addHeaderLine('X-Mashape-Key', MASHAPE_API_KEY);
     $http->setHeaders($headers);
     $http->setUri("https://restcountries-v1.p.mashape.com/all");
     $http->setMethod('GET');
     $response = $http->send();
     $json = Json::decode($response->getBody());
     $data = array();
     foreach ($json as $country) {
         $data[] = array("code" => strtolower($country->alpha2Code), "name" => $country->name);
     }
     return $data;
 }
开发者ID:johnluetke,项目名称:findcheeseheads.com,代码行数:17,代码来源:SearchAPI.php

示例11: _doAuth

 /**
  * Acts like a client sending the given Authenticate header value.
  *
  * @param  string $clientHeader Authenticate header value
  * @param  string $scheme       Which authentication scheme to use
  * @return array Containing the result, the response headers, and the status
  */
 public function _doAuth($clientHeader, $scheme)
 {
     // Set up stub request and response objects
     $response = new Response();
     $response->setStatusCode(200);
     $headers = new Headers();
     $headers->addHeaderLine('Proxy-Authorization', $clientHeader);
     $headers->addHeaderLine('User-Agent', 'PHPUnit');
     $request = new Request();
     $request->setUri('http://localhost/');
     $request->setMethod('GET');
     $request->setHeaders($headers);
     // Select an Authentication scheme
     switch ($scheme) {
         case 'basic':
             $use = $this->_basicConfig;
             break;
         case 'digest':
             $use = $this->_digestConfig;
             break;
         case 'both':
         default:
             $use = $this->_bothConfig;
     }
     // Create the HTTP Auth adapter
     $a = new \Zend\Authentication\Adapter\Http($use);
     $a->setBasicResolver($this->_basicResolver);
     $a->setDigestResolver($this->_digestResolver);
     // Send the authentication request
     $a->setRequest($request);
     $a->setResponse($response);
     $result = $a->authenticate();
     $return = array('result' => $result, 'status' => $response->getStatusCode(), 'headers' => $response->getHeaders());
     return $return;
 }
开发者ID:nieldm,项目名称:zf2,代码行数:42,代码来源:ProxyTest.php

示例12: testUnsupportedScheme

 public function testUnsupportedScheme()
 {
     $response = new Response();
     $headers = new Headers();
     $request = new Request();
     $headers->addHeaderLine('Authorization', 'NotSupportedScheme <followed by a space character');
     $request->setHeaders($headers);
     $a = new Adapter\Http($this->_digestConfig);
     $a->setDigestResolver($this->_digestResolver)->setRequest($request)->setResponse($response);
     $result = $a->authenticate();
     $this->assertEquals($result->getCode(), Authentication\Result::FAILURE_UNCATEGORIZED);
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:12,代码来源:ObjectTest.php

示例13: testGetContent

 /**
  * @covers Hermes\Api\Response::__construct
  * @covers Hermes\Api\Response::getContent
  */
 public function testGetContent()
 {
     $http = new Client();
     $response = new ZendResponse();
     $headers = new Headers();
     $headers->addHeaderLine('Content-Type', 'application/json');
     $response->setHeaders($headers);
     $response->setContent(static::$sampleJson);
     $this->object = new Response($http, $response);
     $content = $this->object->getContent();
 }
开发者ID:mt-olympus,项目名称:hermes,代码行数:15,代码来源:ResponseTest.php

示例14: testUpdateCanBeAccessed

 public function testUpdateCanBeAccessed()
 {
     $data = array('firstName' => 'Jim', 'lastName' => 'Smith', 'middleInitial' => null, 'address1' => '123 Main St', 'address2' => 'Ste 400', 'city' => 'Pleasantville', 'state' => 'OK', 'zip' => '12345', 'zip4' => '6789', 'email' => 'john.smith@company.com', 'phoneNumber' => '8885551212', 'id' => 1);
     $contact = new Contact();
     $contact->exchangeArray($data);
     $entityManager = $this->getMockBuilder('\\Doctrine\\Common\\Persistence\\ObjectManager')->disableOriginalConstructor()->getMock();
     $entityManager->expects($this->once())->method('merge')->with($this->anything())->will($this->returnValue($contact));
     $entityManager->expects($this->once())->method('flush');
     $entityManager->expects($this->once())->method('find')->with('AddressBook\\Model\\Contact', 1)->will($this->returnValue($contact));
     $this->controller->setObjectManager($entityManager);
     $this->routeMatch->setParam('id', '1');
     $this->request->setMethod('put');
     $this->request->setContent(json_encode($data));
     $headers = new Headers();
     $headers->addHeaderLine('Content-type', 'application/json');
     $this->request->setHeaders($headers);
     $result = $this->controller->dispatch($this->request);
     $response = $this->controller->getResponse();
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals('{"data":1}', $result->serialize());
 }
开发者ID:jcrosswh,项目名称:AddressBook,代码行数:21,代码来源:AddressBookControllerTest.php

示例15: call

 /**
  * Call an api method
  *
  * @param $method
  * @param $params
  * @return mixed
  * @throws \Exception
  */
 public function call($method, $params)
 {
     $params['apikey'] = $this->getApiKey();
     $params = json_encode($params);
     $client = $this->getClient();
     $uri = $this->getBaseUri() . $method . '.json';
     $headers = new Headers();
     $headers->addHeaderLine('Accept-Encoding', 'identity');
     $headers->addHeaderLine('Content-Type', 'application/json');
     $headers->addHeaderLine('Accept', '*/*');
     $request = new Request();
     $request->setHeaders($headers);
     $request->setUri($uri);
     $request->setMethod('POST');
     $request->setContent($params);
     $response = $client->dispatch($request);
     if ($response->isSuccess()) {
         return json_decode($response->getContent(), true);
     } else {
         /*@TODO throw a more useful exception*/
         throw new \Exception('Request Failed');
     }
 }
开发者ID:carnage,项目名称:mailchimp,代码行数:31,代码来源:Api.php


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