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


PHP Util::toHTTPDate方法代码示例

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


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

示例1: propFind

 /**
  * Fetches properties for a path.
  *
  * This method received a PropFind object, which contains all the
  * information about the properties that need to be fetched.
  *
  * Ususually you would just want to call 'get404Properties' on this object,
  * as this will give you the _exact_ list of properties that need to be
  * fetched, and haven't yet.
  *
  * @param string $path
  * @param PropFind $propFind
  * @return void
  */
 public function propFind($path, PropFind $propFind)
 {
     $propertyNames = $propFind->get404Properties();
     if (!$propertyNames) {
         return;
     }
     // error_log("propFind: path($path), " . print_r($propertyNames, true));
     $cachedNodes = \CB\Cache::get('DAVNodes');
     // error_log("propFind: " . print_r($cachedNodes, true));
     $path = trim($path, '/');
     $path = str_replace('\\', '/', $path);
     // Node with $path is not in cached nodes, return
     if (!array_key_exists($path, $cachedNodes)) {
         return;
     }
     $node = $cachedNodes[$path];
     // while($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
     //     $propFind->set($row['name'], $row['value']);
     // }
     foreach ($propertyNames as $prop) {
         if ($prop == '{DAV:}creationdate') {
             $dttm = new \DateTime($node['cdate']);
             // $dttm->getTimestamp()
             $propFind->set($prop, \Sabre\HTTP\Util::toHTTPDate($dttm));
         } elseif ($prop == '{urn:schemas-microsoft-com:office:office}modifiedby' or $prop == '{DAV:}getmodifiedby') {
             // This has to be revised, because the User.login differs from User.DisplayName
             // moreover, during an edit, Word will check for File Properties and we
             // tell Word that the file is modified by another user
             // $propFind->set($prop, \CB\User::getDisplayName($node['uid']));
         }
     }
 }
开发者ID:youprofit,项目名称:casebox,代码行数:46,代码来源:PropertyStorageBackend.php

示例2: serialize

 /**
  * serialize
  *
  * @param DAV\Server $server
  * @param \DOMElement $prop
  * @return void
  */
 public function serialize(DAV\Server $server, \DOMElement $prop)
 {
     $doc = $prop->ownerDocument;
     //$prop->setAttribute('xmlns:b','urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/');
     //$prop->setAttribute('b:dt','dateTime.rfc1123');
     $prop->nodeValue = HTTP\Util::toHTTPDate($this->time);
 }
开发者ID:samj1912,项目名称:repo,代码行数:14,代码来源:GetLastModified.php

示例3: testSerialize

    function testSerialize()
    {
        $dt = new \DateTime('2010-03-14 16:35', new \DateTimeZone('UTC'));
        $lastMod = new GetLastModified($dt);
        $doc = new \DOMDocument();
        $root = $doc->createElement('d:getlastmodified');
        $root->setAttribute('xmlns:d', 'DAV:');
        $doc->appendChild($root);
        $server = new DAV\Server();
        $lastMod->serialize($server, $root);
        $xml = $doc->saveXML();
        /*
        $this->assertEquals(
        '<?xml version="1.0"?>
        <d:getlastmodified xmlns:d="DAV:" xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/" b:dt="dateTime.rfc1123">' .
        HTTP\Util::toHTTPDate($dt) .
        '</d:getlastmodified>
        ', $xml);
        */
        $this->assertEquals('<?xml version="1.0"?>
<d:getlastmodified xmlns:d="DAV:">' . HTTP\Util::toHTTPDate($dt) . '</d:getlastmodified>
', $xml);
        $ok = false;
        try {
            GetLastModified::unserialize(DAV\XMLUtil::loadDOMDocument($xml)->firstChild, array());
        } catch (DAV\Exception $e) {
            $ok = true;
        }
        if (!$ok) {
            $this->markTestFailed('Unserialize should not be supported');
        }
    }
开发者ID:MetallianFR68,项目名称:myroundcube,代码行数:32,代码来源:GetLastModifiedTest.php

示例4: testHEAD

 function testHEAD()
 {
     $request = new HTTP\Request('HEAD', '/test.txt');
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals(['X-Sabre-Version' => [DAV\Version::VERSION], 'Content-Type' => ['application/octet-stream'], 'Content-Length' => [13], 'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt')))], 'ETag' => ['"' . md5_file($this->tempDir . '/test.txt') . '"']], $this->response->getHeaders());
     $this->assertEquals(200, $this->response->status);
     $this->assertEquals('', $this->response->body);
 }
开发者ID:MetallianFR68,项目名称:myroundcube,代码行数:9,代码来源:ServerTest.php

示例5: setUp

 function setUp()
 {
     parent::setUp();
     $this->server->createFile('files/test.txt', 'Test contents');
     $this->lastModified = HTTP\Util::toHTTPDate(new DateTime('@' . $this->server->tree->getNodeForPath('files/test.txt')->getLastModified()));
     $stream = popen('echo "Test contents"', 'r');
     $streamingFile = new Mock\StreamingFile('no-seeking.txt', $stream);
     $streamingFile->setSize(12);
     $this->server->tree->getNodeForPath('files')->addNode($streamingFile);
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:10,代码来源:ServerRangeTest.php

示例6: testHEAD

 function testHEAD()
 {
     $serverVars = array('REQUEST_URI' => '/test.txt', 'REQUEST_METHOD' => 'HEAD');
     $request = new HTTP\Request($serverVars);
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals(array('Content-Type' => 'application/octet-stream', 'Content-Length' => 13, 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))), 'ETag' => '"' . md5_file($this->tempDir . '/test.txt') . '"'), $this->response->headers);
     $this->assertEquals('HTTP/1.1 200 OK', $this->response->status);
     $this->assertEquals('', $this->response->body);
 }
开发者ID:samj1912,项目名称:repo,代码行数:10,代码来源:ServerTest.php

示例7: testBaseUri

 function testBaseUri()
 {
     $serverVars = ['REQUEST_URI' => '/blabla/test.txt', 'REQUEST_METHOD' => 'GET'];
     $filename = $this->tempDir . '/test.txt';
     $request = HTTP\Sapi::createFromServerArray($serverVars);
     $this->server->setBaseUri('/blabla/');
     $this->assertEquals('/blabla/', $this->server->getBaseUri());
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals(['X-Sabre-Version' => [Version::VERSION], 'Content-Type' => ['application/octet-stream'], 'Content-Length' => [13], 'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($filename)))], 'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"']], $this->response->getHeaders());
     $this->assertEquals(200, $this->response->status);
     $this->assertEquals('Test contents', stream_get_contents($this->response->body));
 }
开发者ID:BlaBlaNet,项目名称:hubzilla,代码行数:13,代码来源:ServerSimpleTest.php

示例8: checkPreconditions


//.........这里部分代码省略.........

                if ($haveMatch) {
                    if ($etag) $response->setHeader('ETag', $etag);
                    if ($request->getMethod() === 'GET') {
                        $response->setStatus(304);
                        return false;
                    } else {
                        throw new Exception\PreconditionFailed('An If-None-Match header was specified, but the ETag matched (or * was specified).', 'If-None-Match');
                    }
                }
            }

        }

        if (!$ifNoneMatch && ($ifModifiedSince = $request->getHeader('If-Modified-Since'))) {

            // The If-Modified-Since header contains a date. We
            // will only return the entity if it has been changed since
            // that date. If it hasn't been changed, we return a 304
            // header
            // Note that this header only has to be checked if there was no If-None-Match header
            // as per the HTTP spec.
            $date = HTTP\Util::parseHTTPDate($ifModifiedSince);

            if ($date) {
                if (is_null($node)) {
                    $node = $this->tree->getNodeForPath($path);
                }
                $lastMod = $node->getLastModified();
                if ($lastMod) {
                    $lastMod = new \DateTime('@' . $lastMod);
                    if ($lastMod <= $date) {
                        $response->setStatus(304);
                        $response->setHeader('Last-Modified', HTTP\Util::toHTTPDate($lastMod));
                        return false;
                    }
                }
            }
        }

        if ($ifUnmodifiedSince = $request->getHeader('If-Unmodified-Since')) {

            // The If-Unmodified-Since will allow allow the request if the
            // entity has not changed since the specified date.
            $date = HTTP\Util::parseHTTPDate($ifUnmodifiedSince);

            // We must only check the date if it's valid
            if ($date) {
                if (is_null($node)) {
                    $node = $this->tree->getNodeForPath($path);
                }
                $lastMod = $node->getLastModified();
                if ($lastMod) {
                    $lastMod = new \DateTime('@' . $lastMod);
                    if ($lastMod > $date) {
                        throw new Exception\PreconditionFailed('An If-Unmodified-Since header was specified, but the entity has been changed since the specified date.', 'If-Unmodified-Since');
                    }
                }
            }

        }

        // Now the hardest, the If: header. The If: header can contain multiple
        // urls, ETags and so-called 'state tokens'.
        //
        // Examples of state tokens include lock-tokens (as defined in rfc4918)
开发者ID:nikosv,项目名称:openeclass,代码行数:67,代码来源:Server.php

示例9: testIfRangeModificationDateModified

 /**
  * @depends testRange
  */
 function testIfRangeModificationDateModified()
 {
     $node = $this->server->tree->getNodeForPath('test.txt');
     $serverVars = array('REQUEST_URI' => '/test.txt', 'REQUEST_METHOD' => 'GET', 'HTTP_RANGE' => 'bytes=2-5', 'HTTP_IF_RANGE' => '-2 years');
     $request = HTTP\Sapi::createFromServerArray($serverVars);
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals(array('X-Sabre-Version' => [Version::VERSION], 'Content-Type' => ['application/octet-stream'], 'Content-Length' => [13], 'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt')))], 'ETag' => ['"' . md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')) . '"']), $this->response->getHeaders());
     $this->assertEquals(200, $this->response->status);
     $this->assertEquals('Test contents', stream_get_contents($this->response->body));
 }
开发者ID:MetallianFR68,项目名称:myroundcube,代码行数:14,代码来源:ServerRangeTest.php

示例10: testBaseUri

 function testBaseUri()
 {
     $serverVars = array('REQUEST_URI' => '/blabla/test.txt', 'REQUEST_METHOD' => 'GET');
     $request = new HTTP\Request($serverVars);
     $this->server->setBaseUri('/blabla/');
     $this->assertEquals('/blabla/', $this->server->getBaseUri());
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals(array('Content-Type' => 'application/octet-stream', 'Content-Length' => 13, 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt')))), $this->response->headers);
     $this->assertEquals('HTTP/1.1 200 OK', $this->response->status);
     $this->assertEquals('Test contents', stream_get_contents($this->response->body));
 }
开发者ID:MetallianFR68,项目名称:myroundcube,代码行数:12,代码来源:ServerSimpleTest.php

示例11: checkPreconditions


//.........这里部分代码省略.........
                 // Stripping any extra spaces
                 $ifMatchItem = trim($ifMatchItem, ' ');
                 $etag = $node->getETag();
                 if ($etag === $ifMatchItem) {
                     $haveMatch = true;
                 } else {
                     // Evolution has a bug where it sometimes prepends the "
                     // with a \. This is our workaround.
                     if (str_replace('\\"', '"', $ifMatchItem) === $etag) {
                         $haveMatch = true;
                     }
                 }
             }
             if (!$haveMatch) {
                 throw new Exception\PreconditionFailed('An If-Match header was specified, but none of the specified the ETags matched.', 'If-Match');
             }
         }
     }
     if ($ifNoneMatch = $this->httpRequest->getHeader('If-None-Match')) {
         // The If-None-Match header contains an etag.
         // Only if the ETag does not match the current ETag, the request will succeed
         // The header can also contain *, in which case the request
         // will only succeed if the entity does not exist at all.
         $nodeExists = true;
         if (!$node) {
             try {
                 $node = $this->tree->getNodeForPath($uri);
             } catch (Exception\NotFound $e) {
                 $nodeExists = false;
             }
         }
         if ($nodeExists) {
             $haveMatch = false;
             if ($ifNoneMatch === '*') {
                 $haveMatch = true;
             } else {
                 // There might be multiple etags
                 $ifNoneMatch = explode(',', $ifNoneMatch);
                 $etag = $node->getETag();
                 foreach ($ifNoneMatch as $ifNoneMatchItem) {
                     // Stripping any extra spaces
                     $ifNoneMatchItem = trim($ifNoneMatchItem, ' ');
                     if ($etag === $ifNoneMatchItem) {
                         $haveMatch = true;
                     }
                 }
             }
             if ($haveMatch) {
                 if ($handleAsGET) {
                     $this->httpResponse->sendStatus(304);
                     return false;
                 } else {
                     throw new Exception\PreconditionFailed('An If-None-Match header was specified, but the ETag matched (or * was specified).', 'If-None-Match');
                 }
             }
         }
     }
     if (!$ifNoneMatch && ($ifModifiedSince = $this->httpRequest->getHeader('If-Modified-Since'))) {
         // The If-Modified-Since header contains a date. We
         // will only return the entity if it has been changed since
         // that date. If it hasn't been changed, we return a 304
         // header
         // Note that this header only has to be checked if there was no If-None-Match header
         // as per the HTTP spec.
         $date = HTTP\Util::parseHTTPDate($ifModifiedSince);
         if ($date) {
             if (is_null($node)) {
                 $node = $this->tree->getNodeForPath($uri);
             }
             $lastMod = $node->getLastModified();
             if ($lastMod) {
                 $lastMod = new \DateTime('@' . $lastMod);
                 if ($lastMod <= $date) {
                     $this->httpResponse->sendStatus(304);
                     $this->httpResponse->setHeader('Last-Modified', HTTP\Util::toHTTPDate($lastMod));
                     return false;
                 }
             }
         }
     }
     if ($ifUnmodifiedSince = $this->httpRequest->getHeader('If-Unmodified-Since')) {
         // The If-Unmodified-Since will allow allow the request if the
         // entity has not changed since the specified date.
         $date = HTTP\Util::parseHTTPDate($ifUnmodifiedSince);
         // We must only check the date if it's valid
         if ($date) {
             if (is_null($node)) {
                 $node = $this->tree->getNodeForPath($uri);
             }
             $lastMod = $node->getLastModified();
             if ($lastMod) {
                 $lastMod = new \DateTime('@' . $lastMod);
                 if ($lastMod > $date) {
                     throw new Exception\PreconditionFailed('An If-Unmodified-Since header was specified, but the entity has been changed since the specified date.', 'If-Unmodified-Since');
                 }
             }
         }
     }
     return true;
 }
开发者ID:floffel03,项目名称:pydio-core,代码行数:101,代码来源:Server.php

示例12: testIfRangeModificationDateModified

 /**
  * @depends testRange
  * @covers \Sabre\DAV\Server::httpGet
  */
 function testIfRangeModificationDateModified()
 {
     $node = $this->server->tree->getNodeForPath('test.txt');
     $serverVars = array('REQUEST_URI' => '/test.txt', 'REQUEST_METHOD' => 'GET', 'HTTP_RANGE' => 'bytes=2-5', 'HTTP_IF_RANGE' => '-2 years');
     $request = new HTTP\Request($serverVars);
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals(array('Content-Type' => 'application/octet-stream', 'Content-Length' => 13, 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt'))), 'ETag' => '"' . md5(file_get_contents(SABRE_TEMPDIR . '/test.txt')) . '"'), $this->response->headers);
     $this->assertEquals('HTTP/1.1 200 OK', $this->response->status);
     $this->assertEquals('Test contents', stream_get_contents($this->response->body));
 }
开发者ID:TamirAl,项目名称:hubzilla,代码行数:15,代码来源:ServerRangeTest.php

示例13: xmlSerialize

 /**
  * The serialize method is called during xml writing.
  *
  * It should use the $writer argument to encode this object into XML.
  *
  * Important note: it is not needed to create the parent element. The
  * parent element is already created, and we only have to worry about
  * attributes, child elements and text (if any).
  *
  * Important note 2: If you are writing any new elements, you are also
  * responsible for closing them.
  *
  * @param Writer $writer
  * @return void
  */
 function xmlSerialize(Writer $writer)
 {
     $writer->write(HTTP\Util::toHTTPDate($this->time));
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:19,代码来源:GetLastModified.php

示例14: testBaseUri

 function testBaseUri()
 {
     $serverVars = array('REQUEST_URI' => '/blabla/test.txt', 'REQUEST_METHOD' => 'GET');
     $request = HTTP\Sapi::createFromServerArray($serverVars);
     $this->server->setBaseUri('/blabla/');
     $this->assertEquals('/blabla/', $this->server->getBaseUri());
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals(array('X-Sabre-Version' => Version::VERSION, 'Content-Type' => 'application/octet-stream', 'Content-Length' => 13, 'Last-Modified' => HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt')))), $this->response->getHeaders());
     $this->assertEquals(200, $this->response->status);
     $this->assertEquals('Test contents', stream_get_contents($this->response->body));
 }
开发者ID:mattes,项目名称:sabre-dav,代码行数:12,代码来源:ServerSimpleTest.php

示例15: testIfRangeModificationDateModified

 /**
  * @depends testRange
  */
 function testIfRangeModificationDateModified()
 {
     $node = $this->server->tree->getNodeForPath('test.txt');
     $request = new HTTP\Request('GET', '/test.txt', ['Range' => 'bytes=2-5', 'If-Range' => '-2 years']);
     $filename = SABRE_TEMPDIR . '/test.txt';
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals(['X-Sabre-Version' => [Version::VERSION], 'Content-Type' => ['application/octet-stream'], 'Content-Length' => [13], 'Last-Modified' => [HTTP\Util::toHTTPDate(new \DateTime('@' . filemtime($this->tempDir . '/test.txt')))], 'ETag' => ['"' . sha1(fileinode($filename) . filesize($filename) . filemtime($filename)) . '"']], $this->response->getHeaders());
     $this->assertEquals(200, $this->response->status);
     $this->assertEquals('Test contents', stream_get_contents($this->response->body));
 }
开发者ID:Befox,项目名称:cdav,代码行数:14,代码来源:ServerRangeTest.php


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