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


PHP Request::getHeaders方法代码示例

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


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

示例1: getServer

 /**
  * (non-PHPdoc)
  * @see Tinebase_Server_Plugin_Interface::getServer()
  */
 public static function getServer(\Zend\Http\Request $request)
 {
     /**************************** JSON API *****************************/
     if ($request->getHeaders('X-TINE20-REQUEST-TYPE') && $request->getHeaders('X-TINE20-REQUEST-TYPE')->getFieldValue() === 'JSON' || $request->getHeaders('CONTENT-TYPE') && substr($request->getHeaders('CONTENT-TYPE')->getFieldValue(), 0, 16) === 'application/json' || $request->getPost('requestType') === 'JSON' || $request->getHeaders('ACCESS-CONTROL-REQUEST-METHOD')) {
         return new Tinebase_Server_Json();
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:11,代码来源:Json.php

示例2: testProcessPostRequestReturnsToken

    public function testProcessPostRequestReturnsToken()
    {
        $request = new Request();
        $request->setMethod('post');

        $parameters = new ParameterDataContainer();
        $parameters->setBodyParam('format', 'ZIP');
        $event = new MvcEvent();
        $event->setParam('ZFContentNegotiationParameterData', $parameters);

        $request->getHeaders()->addHeaderLine('Content-Type', 'application/json');
        $request->getHeaders()->addHeaderLine('Accept', 'application/json');

        $this->controller->setRequest($request);
        $this->controller->setEvent($event);

        $cwd = getcwd();
        chdir(__DIR__ . '/TestAsset');
        $result = $this->controller->indexAction();
        chdir($cwd);

        $this->assertInternalType('array', $result);
        $this->assertTrue(isset($result['token']));
        $this->assertTrue(isset($result['format']));
        $package = sys_get_temp_dir() . '/apigility_' . $result['token'] . '.' . $result['format'];
        $this->assertTrue(file_exists($package));

        return $result;
    }
开发者ID:jbarentsen,项目名称:drb,代码行数:29,代码来源:PackageControllerTest.php

示例3: testFormPluginIsNotCalledIfAjaxRequest

 public function testFormPluginIsNotCalledIfAjaxRequest()
 {
     $headers = $this->request->getHeaders();
     $headers->addHeaderLine('X_REQUESTED_WITH', 'XMLHttpRequest');
     $this->target->form('elements');
     $result = $this->target->getResult();
     $this->assertEmpty($result);
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:8,代码来源:GetResultTest.php

示例4: fromZend

 /**
  * Convert a Zend\Http\Response in a PSR-7 response, using zend-diactoros
  *
  * @param  ZendRequest $zendRequest
  * @return ServerRequest
  */
 public static function fromZend(ZendRequest $zendRequest)
 {
     $body = new Stream('php://memory', 'wb+');
     $body->write($zendRequest->getContent());
     $headers = empty($zendRequest->getHeaders()) ? [] : $zendRequest->getHeaders()->toArray();
     $query = empty($zendRequest->getQuery()) ? [] : $zendRequest->getQuery()->toArray();
     $post = empty($zendRequest->getPost()) ? [] : $zendRequest->getPost()->toArray();
     $files = empty($zendRequest->getFiles()) ? [] : $zendRequest->getFiles()->toArray();
     $request = new ServerRequest([], self::convertFilesToUploaded($files), $zendRequest->getUriString(), $zendRequest->getMethod(), $body, $headers);
     $request = $request->withQueryParams($query);
     return $request->withParsedBody($post);
 }
开发者ID:MidnightDesign,项目名称:zend-psr7bridge,代码行数:18,代码来源:Psr7ServerRequest.php

示例5: getServer

 /**
  * (non-PHPdoc)
  * @see Tinebase_Server_Plugin_Interface::getServer()
  */
 public static function getServer(\Zend\Http\Request $request)
 {
     /**************************** SNOM API *****************************/
     if ($request->getHeaders('USER-AGENT') && preg_match('/^Mozilla\\/4\\.0 \\(compatible; (snom...)\\-SIP (\\d+\\.\\d+\\.\\d+)/i', $request->getHeaders('USER-AGENT')->getFieldValue())) {
         return new Voipmanager_Server_Snom();
         /**************************** ASTERISK API *****************************/
     } else {
         if ($request->getHeaders('USER-AGENT') && $request->getHeaders('USER-AGENT')->getFieldValue() === 'asterisk-libcurl-agent/1.0') {
             return new Voipmanager_Server_Asterisk();
         }
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:16,代码来源:Plugin.php

示例6: testOnRenderErrorCreatesAnApiProblemResponse

 public function testOnRenderErrorCreatesAnApiProblemResponse()
 {
     $response = new Response();
     $request = new Request();
     $request->getHeaders()->addHeaderLine('Accept', 'application/json');
     $event = new MvcEvent();
     $event->setError(Application::ERROR_EXCEPTION);
     $event->setRequest($request);
     $event->setResponse($response);
     $this->listener->onRenderError($event);
     $this->assertTrue($event->propagationIsStopped());
     $this->assertSame($response, $event->getResponse());
     $this->assertEquals(406, $response->getStatusCode());
     $headers = $response->getHeaders();
     $this->assertTrue($headers->has('Content-Type'));
     $this->assertEquals('application/problem+json', $headers->get('content-type')->getFieldValue());
     $content = json_decode($response->getContent(), true);
     $this->assertArrayHasKey('status', $content);
     $this->assertArrayHasKey('title', $content);
     $this->assertArrayHasKey('describedBy', $content);
     $this->assertArrayHasKey('detail', $content);
     $this->assertEquals(406, $content['status']);
     $this->assertEquals('Not Acceptable', $content['title']);
     $this->assertContains('www.w3.org', $content['describedBy']);
     $this->assertContains('accept', $content['detail']);
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:26,代码来源:RenderErrorListenerTest.php

示例7: findRegion

 public function findRegion($country, $query)
 {
     $request = new Request();
     $request->setMethod(Request::METHOD_GET);
     foreach ($query as $key => $value) {
         $request->getQuery()->set($key, $value);
     }
     $request->getHeaders()->addHeaderLine('Accept', 'application/json');
     switch ($country) {
         case 'CH':
             $request->setUri($this->config['url'] . '/ch-region');
             break;
         default:
             $request->setUri($this->config['url'] . '/ch-region');
             break;
     }
     $client = new Client();
     $response = $client->send($request);
     $body = $response->getBody();
     $result = json_decode($body, true);
     if ($result) {
         return $result['_embedded']['ch_region'];
     }
     /*echo "<textarea cols='100' rows='30' style='position:relative; z-index:10000; width:inherit; height:200px;'>";
       print_r($body);
       echo "</textarea>";
       die();*/
     return null;
 }
开发者ID:omusico,项目名称:casawp,代码行数:29,代码来源:GeoService.php

示例8: PlanJSONManager

 function PlanJSONManager($action, $url, $requestjson, $uid)
 {
     $request = new Request();
     $request->getHeaders()->addHeaders(array('Content-Type' => 'application/json; charset=UTF-8'));
     //$url="";
     try {
         $request->setUri($url);
         $request->setMethod($action);
         $client = new Client();
         if ($action == 'PUT' || $action == 'POST') {
             $client->setUri($url);
             $client->setMethod($action);
             $client->setRawBody($requestjson);
             $client->setEncType('application/json');
             $response = $client->send();
             return $response;
         } else {
             $response = $client->dispatch($request);
             //var_dump(json_decode($response->getBody(),true));
             return $response;
         }
     } catch (\Exception $e) {
         $e->getTrace();
     }
     return null;
 }
开发者ID:shivap87,项目名称:cost,代码行数:26,代码来源:RESTJSONManager.php

示例9: persist

 public function persist(HelpReport $report)
 {
     $data = ['description' => 'Report generated via Ocramius CLI', 'files' => ['report.json' => ['content' => json_encode($report)]], 'public' => false];
     $request = new Request();
     $request->setUri('https://api.github.com/gists');
     $request->setContent(json_encode($data));
     $request->setMethod(Request::METHOD_POST);
     $request->getHeaders()->addHeader(ContentType::fromString('Content-Type: application/json'));
     $request->getHeaders()->addHeaderLine('X-Requested-With: Ocramius CLI');
     $response = $this->client->send($request);
     if (!$response->isSuccess()) {
         throw new \UnexpectedValueException('Could not obtain a valid GIST from the github API');
     }
     $response = json_decode($response->getBody(), true);
     return $response['html_url'];
 }
开发者ID:ocramius,项目名称:ocramius,代码行数:16,代码来源:Gist.php

示例10: call

 public function call($params = null)
 {
     $request = new Request();
     $request->getHeaders()->addHeaders(array('Accept' => 'application/json'));
     if (!is_null($this->bearer_token)) {
         $request->getHeaders()->addHeaders(array('Authorization' => $this->bearer_token));
     }
     $request->setUri($this->endpoint);
     $request->setMethod($this->method);
     if (!is_null($params)) {
         $request->getPost()->fromArray($params);
     }
     $client = new Client($this->endpoint, array('adapter' => 'Zend\\Http\\Client\\Adapter\\Curl'));
     $response = $client->dispatch($request);
     return Json::decode($response->getBody(), Json::TYPE_ARRAY);
 }
开发者ID:arnie87,项目名称:gofiliate_test,代码行数:16,代码来源:RestManager.php

示例11: request

 /**
  * @inheritdoc
  */
 public function request(array $params)
 {
     try {
         $request = new Request();
         $headers = $request->getHeaders();
         $request->setUri($params['url']);
         $headers->addHeaderLine('Accept-Encoding', 'gzip,deflate');
         if ($params['config']->isAuthenticationPossible() === true && $this->option['keys']['public'] !== null && $this->option['keys']['private'] !== null) {
             /**
              * Note: DATE_RFC1123 my not be RFC 1123 compliant, depending on your platform.
              * @link http://www.php.net/manual/de/function.gmdate.php#25031
              */
             $date = gmdate('D, d M Y H:i:s \\G\\M\\T');
             $path = $request->getUri()->getPath();
             $headers->addHeaderLine('Date', $date);
             $headers->addHeaderLine('Authorization', $this->signRequest('GET', $date, $path));
         }
         if (isset($params['lastmodified'])) {
             $headers->addHeaderLine('If-Modified-Since', $params['lastmodified']);
         }
         $response = $this->client->send($request);
         $body = $response->getBody();
         $headers = null;
         if ($this->option['responseheader']) {
             $headers = $response->getHeaders()->toArray();
             $this->lastResponseHeaders = $headers;
         }
     } catch (\Exception $e) {
         throw new ClientException('Client exception catched, use getPrevious().', 0, $e);
     }
     return $this->createResponse($params['config']->isJson(), $response->getStatusCode(), $body, $headers);
 }
开发者ID:coss,项目名称:bnetlib,代码行数:35,代码来源:ZendFramework.php

示例12: callServer

 public function callServer($method, $params)
 {
     // Get the URI and Url Elements
     $apiUrl = $this->generateUrl($method);
     $requestUri = $apiUrl['uri'];
     // Convert the params to something MC can understand
     $params = $this->processParams($params);
     $params["apikey"] = $this->getConfig('apiKey');
     $request = new Request();
     $request->setMethod(Request::METHOD_POST);
     $request->setUri($requestUri);
     $request->getHeaders()->addHeaders(array('Host' => $apiUrl['host'], 'User-Agent' => 'MCAPI/' . $this->getConfig('apiVersion'), 'Content-type' => 'application/x-www-form-urlencoded'));
     $client = new Client();
     $client->setRequest($request);
     $client->setParameterPost($params);
     $result = $client->send();
     if ($result->getHeaders()->get('X-MailChimp-API-Error-Code')) {
         $error = unserialize($result->getBody());
         if (isset($error['error'])) {
             throw new MailchimpException('The mailchimp API has returned an error (' . $error['code'] . ': ' . $error['error'] . ')');
             return false;
         } else {
             throw new MailchimpException('There was an unspecified error');
             return false;
         }
     }
     return $result->getBody();
 }
开发者ID:aaron4m,项目名称:zf2-mailchimp,代码行数:28,代码来源:Mailchimp.php

示例13: testAtomAcceptHeaderSelectsFeedStrategy

 public function testAtomAcceptHeaderSelectsFeedStrategy()
 {
     $request = new HttpRequest();
     $request->getHeaders()->addHeaderLine('Accept', 'application/atom+xml');
     $this->event->setRequest($request);
     $result = $this->strategy->selectRenderer($this->event);
     $this->assertSame($this->renderer, $result);
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:8,代码来源:FeedStrategyTest.php

示例14: preparePostRequest

 private function preparePostRequest($post)
 {
     $postRequest = new Request();
     $postRequest->setMethod(Request::METHOD_POST);
     $postRequest->setPost($post);
     $postRequest->setUri($this->url);
     $postRequest->getHeaders()->addHeaders(['Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8']);
     return $postRequest;
 }
开发者ID:seyfer,项目名称:zend2-tutorial.me,代码行数:9,代码来源:Sender.php

示例15: createAjaxRequestWithSpecificPostData

 public function createAjaxRequestWithSpecificPostData($postData)
 {
     $request = new Request();
     $request->getHeaders()->addHeaders(['X_REQUESTED_WITH' => 'XMLHttpRequest']);
     $parameters = new \Zend\Stdlib\Parameters();
     $parameters->fromArray($postData);
     $request->setPost($parameters);
     return $request;
 }
开发者ID:slawojstanislawski,项目名称:doctrine-entity-creator,代码行数:9,代码来源:AbstractDecControllerTest.php


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