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


PHP Request::setHeader方法代码示例

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


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

示例1: testDigestAuthInt

 public function testDigestAuthInt()
 {
     $this->auth->setQOP(Digest::QOP_AUTHINT | Digest::QOP_AUTH);
     list($nonce, $opaque) = $this->getServerTokens(Digest::QOP_AUTHINT | Digest::QOP_AUTH);
     $username = 'admin';
     $password = 12345;
     $nc = '00003';
     $cnonce = uniqid();
     $digestHash = md5(md5($username . ':' . self::REALM . ':' . $password) . ':' . $nonce . ':' . $nc . ':' . $cnonce . ':' . 'auth-int:' . md5('POST' . ':' . '/' . ':' . md5('body')));
     $this->request->setMethod('POST');
     $this->request->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . self::REALM . '", nonce="' . $nonce . '", uri="/", response="' . $digestHash . '", opaque="' . $opaque . '", qop=auth-int,nc=' . $nc . ',cnonce="' . $cnonce . '"');
     $this->request->setBody('body');
     $this->auth->init();
     $this->assertTrue($this->auth->validateA1(md5($username . ':' . self::REALM . ':' . $password)), 'Authentication is deemed invalid through validateA1');
 }
开发者ID:LukasReschke,项目名称:sabre-http,代码行数:15,代码来源:DigestTest.php

示例2: sendRequest

 protected function sendRequest($body, $path = '/jmap', $headers = [])
 {
     if (!is_string($body)) {
         $body = json_encode($body);
     }
     $request = new HTTP\Request('POST', $path, $headers, $body);
     $request->setHeader('Authorization', 'X-JMAP ' . $this->session->key);
     $this->server->httpRequest = $request;
     $this->server->process();
     return $this->server->httpResponse;
 }
开发者ID:roundcube-next,项目名称:roundcube-server,代码行数:11,代码来源:JmapServerTest.php

示例3: testCollectionGetIfNoneMatch

 /**
  * Adding the If-None-Match should have 0 effect, but it threw an error.
  */
 function testCollectionGetIfNoneMatch()
 {
     $request = new HTTP\Request('GET', '/dir');
     $request->setHeader('If-None-Match', '"foo-bar"');
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals(200, $this->response->getStatus(), "Incorrect status received. Full response body: " . $this->response->getBodyAsString());
     $this->assertEquals(['X-Sabre-Version' => [DAV\Version::VERSION], 'Content-Type' => ['text/html; charset=utf-8'], 'Content-Security-Policy' => ["img-src 'self'; style-src 'self';"]], $this->response->getHeaders());
     $body = $this->response->getBodyAsString();
     $this->assertTrue(strpos($body, '<title>dir') !== false, $body);
     $this->assertTrue(strpos($body, '<a href="/dir/child.txt">') !== false);
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:15,代码来源:PluginTest.php

示例4: proxy

 /**
  * Proxy the given JMAP message to the connected JMAP server
  *
  * @param string $method The name of the method to be called on the server
  * @param array  $args   Object containing named arguments for that method or response
  * @return array List of response messages returned by the server
  */
 protected function proxy($method, array $args = [])
 {
     if (!isset($this->proxyuri) && ($identity = $this->controller->getIdentity())) {
         $this->proxyuri = $identity->uri;
     }
     if (empty($this->proxyuri)) {
         throw new RuntimeException("JmapProxy Error: unauthenticated; missing session URI");
     }
     $error = 'Not Implemented';
     $tag = '#' . $this->reqid++;
     $request = new HTTP\Request('POST', $this->proxyuri);
     $request->setHeader('Content-Type', 'application/json');
     $request->setBody(json_encode([[$method, $args, $tag]]));
     $this->logger->debug('proxy:request ' . $method, ['args' => $args, 'uri' => $this->proxyuri, 'tag' => $tag]);
     try {
         $client = new HttpClient();
         $this->setCurlProxySettings($client);
         $response = $client->send($request);
         $this->logger->debug('proxy:response', ['dump' => strval($response)]);
         if ($response->getStatus() === 200) {
             $results = json_decode($response->getBodyAsString(), true);
             return array_filter($results, function ($res) use($tag) {
                 return count($res) == 3 && $res[2] == $tag;
             });
         }
         $error = 'Unexpected HTTP response: ' . $response->getStatus() . ' ' . $response->getStatusText();
     } catch (HTTP\ClientHttpException $e) {
         $error = 'JmapProxy HTTP Error: ' . $e->getHttpStatus() . ' ' . $e->getMessage();
     } catch (\Exception $e) {
         $error = 'JmapProxy HTTP Error: ' . $e->getMessage();
     }
     $this->logger->err($error);
     // fail with a runtime error
     throw new RuntimeException($error);
 }
开发者ID:roundcube-next,项目名称:roundcube-server,代码行数:42,代码来源:JmapProxy.php


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