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


PHP Sabre_HTTP_Request类代码示例

本文整理汇总了PHP中Sabre_HTTP_Request的典型用法代码示例。如果您正苦于以下问题:PHP Sabre_HTTP_Request类的具体用法?PHP Sabre_HTTP_Request怎么用?PHP Sabre_HTTP_Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testExpand

    function testExpand()
    {
        $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', 'REQUEST_URI' => '/calendars/user1/calendar1', 'HTTP_DEPTH' => '1'));
        $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
    <D:prop>
        <C:calendar-data>
            <C:expand start="20120205T230000Z" end="20120212T225959Z"/>
        </C:calendar-data>
        <D:getetag/>
    </D:prop>
    <C:filter>
        <C:comp-filter name="VCALENDAR">
            <C:comp-filter name="VEVENT">
                <C:time-range start="20120205T230000Z" end="20120212T225959Z"/>
            </C:comp-filter>
        </C:comp-filter>
    </C:filter>
</C:calendar-query>');
        $response = $this->request($request);
        // Everts super awesome xml parser.
        $body = substr($response->body, $start = strpos($response->body, 'BEGIN:VCALENDAR'), strpos($response->body, 'END:VCALENDAR') - $start + 13);
        $body = str_replace('&#13;', '', $body);
        $vObject = Sabre_VObject_Reader::read($body);
        // We only expect 3 events
        $this->assertEquals(3, count($vObject->VEVENT), 'We got 6 events instead of 3. Output: ' . $body);
        // TZID should be gone
        $this->assertFalse(isset($vObject->VEVENT->DTSTART['TZID']));
    }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:29,代码来源:ExpandEventsDoubleEventsTest.php

示例2: testCorrect

    function testCorrect()
    {
        $xml = '<?xml version="1.0"?>
<d:principal-search-property-set xmlns:d="DAV:"/>';
        $serverVars = array('REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/principals');
        $request = new Sabre_HTTP_Request($serverVars);
        $request->setBody($xml);
        $server = $this->getServer();
        $server->httpRequest = $request;
        $server->exec();
        $this->assertEquals('HTTP/1.1 200 Ok', $server->httpResponse->status, $server->httpResponse->body);
        $this->assertEquals(array('Content-Type' => 'application/xml; charset=utf-8'), $server->httpResponse->headers);
        $check = array('/d:principal-search-property-set', '/d:principal-search-property-set/d:principal-search-property', '/d:principal-search-property-set/d:principal-search-property/d:prop', '/d:principal-search-property-set/d:principal-search-property/d:prop/d:displayname', '/d:principal-search-property-set/d:principal-search-property/d:description');
        $xml = simplexml_load_string($server->httpResponse->body);
        $xml->registerXPathNamespace('d', 'DAV:');
        foreach ($check as $v1 => $v2) {
            $xpath = is_int($v1) ? $v2 : $v1;
            $result = $xml->xpath($xpath);
            $count = 1;
            if (!is_int($v1)) {
                $count = $v2;
            }
            $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body);
        }
    }
开发者ID:Gninety,项目名称:Microweber,代码行数:25,代码来源:PrincipalSearchPropertySetTest.php

示例3: testQueryTimerange

    function testQueryTimerange()
    {
        $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', 'REQUEST_URI' => '/calendars/user1/calendar1', 'HTTP_DEPTH' => '1'));
        $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
    <D:prop>
        <C:calendar-data>
            <C:expand start="20120226T230000Z" end="20120228T225959Z"/>
        </C:calendar-data>
        <D:getetag/>
    </D:prop>
    <C:filter>
        <C:comp-filter name="VCALENDAR">
            <C:comp-filter name="VEVENT">
                <C:time-range start="20120226T230000Z" end="20120228T225959Z"/>
            </C:comp-filter>
        </C:comp-filter>
    </C:filter>
</C:calendar-query>');
        $response = $this->request($request);
        if (strpos($response->body, 'BEGIN:VCALENDAR') === false) {
            $this->fail('Got no events instead of 1. Output: ' . $response->body);
        }
        // Everts super awesome xml parser.
        $body = substr($response->body, $start = strpos($response->body, 'BEGIN:VCALENDAR'), strpos($response->body, 'END:VCALENDAR') - $start + 13);
        $body = str_replace('&#13;', '', $body);
        $vObject = VObject\Reader::read($body);
        // We expect 1 event
        $this->assertEquals(1, count($vObject->VEVENT), 'We got 0 events instead of 1. Output: ' . $body);
    }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:30,代码来源:GetEventsByTimerangeTest.php

示例4: testIssue205

    function testIssue205()
    {
        $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', 'REQUEST_URI' => '/calendars/user1/calendar1', 'HTTP_DEPTH' => '1'));
        $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
    <D:prop>
        <C:calendar-data>
            <C:expand start="20120325T220000Z" end="20120401T215959Z"/>
        </C:calendar-data>
        <D:getetag/>
    </D:prop>
    <C:filter>
        <C:comp-filter name="VCALENDAR">
            <C:comp-filter name="VEVENT">
                <C:comp-filter name="VALARM">
                    <C:time-range start="20120325T220000Z" end="20120401T215959Z"/>
                </C:comp-filter>
            </C:comp-filter>
        </C:comp-filter>
    </C:filter>
</C:calendar-query>');
        $response = $this->request($request);
        $this->assertFalse(strpos($response->body, '<s:exception>Exception</s:exception>'), 'Exception occurred: ' . $response->body);
        $this->assertFalse(strpos($response->body, 'Unknown or bad format'), 'DateTime unknown format Exception: ' . $response->body);
        // Everts super awesome xml parser.
        $body = substr($response->body, $start = strpos($response->body, 'BEGIN:VCALENDAR'), strpos($response->body, 'END:VCALENDAR') - $start + 13);
        $body = str_replace('&#13;', '', $body);
        $vObject = VObject\Reader::read($body);
        $this->assertEquals(1, count($vObject->VEVENT));
    }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:30,代码来源:Issue205Test.php

示例5: testExpand

    /**
     * @depends testSimple
     */
    function testExpand()
    {
        $xml = '<?xml version="1.0"?>
<d:expand-property xmlns:d="DAV:">
  <d:property name="current-user-principal">
      <d:property name="displayname" />
  </d:property>
</d:expand-property>';
        $serverVars = array('REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/');
        $request = new Sabre_HTTP_Request($serverVars);
        $request->setBody($xml);
        $server = $this->getServer();
        $server->httpRequest = $request;
        $server->exec();
        $this->assertEquals('HTTP/1.1 207 Multi-Status', $server->httpResponse->status);
        $this->assertEquals(array('Content-Type' => 'application/xml; charset=utf-8'), $server->httpResponse->headers);
        $check = array('/d:multistatus', '/d:multistatus/d:response' => 1, '/d:multistatus/d:response/d:href' => 1, '/d:multistatus/d:response/d:propstat' => 1, '/d:multistatus/d:response/d:propstat/d:prop' => 1, '/d:multistatus/d:response/d:propstat/d:prop/d:current-user-principal' => 1, '/d:multistatus/d:response/d:propstat/d:prop/d:current-user-principal/d:response' => 1, '/d:multistatus/d:response/d:propstat/d:prop/d:current-user-principal/d:response/d:href' => 1, '/d:multistatus/d:response/d:propstat/d:prop/d:current-user-principal/d:response/d:propstat' => 1, '/d:multistatus/d:response/d:propstat/d:prop/d:current-user-principal/d:response/d:propstat/d:prop' => 1, '/d:multistatus/d:response/d:propstat/d:prop/d:current-user-principal/d:response/d:propstat/d:prop/d:displayname' => 1);
        $xml = simplexml_load_string($server->httpResponse->body);
        $xml->registerXPathNamespace('d', 'DAV:');
        foreach ($check as $v1 => $v2) {
            $xpath = is_int($v1) ? $v2 : $v1;
            $result = $xml->xpath($xpath);
            $count = 1;
            if (!is_int($v1)) {
                $count = $v2;
            }
            $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result));
        }
    }
开发者ID:Gninety,项目名称:Microweber,代码行数:32,代码来源:ExpandPropertiesTest.php

示例6: sendPROPFIND

 public function sendPROPFIND($body)
 {
     $serverVars = array('REQUEST_URI' => '/', 'REQUEST_METHOD' => 'PROPFIND', 'HTTP_DEPTH' => '0');
     $request = new Sabre_HTTP_Request($serverVars);
     $request->setBody($body);
     $this->server->httpRequest = $request;
     $this->server->exec();
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:8,代码来源:SupportedReportSetTest.php

示例7: testGetAbsoluteUri

 function testGetAbsoluteUri()
 {
     $s = array('HTTP_HOST' => 'sabredav.org', 'REQUEST_URI' => '/foo');
     $r = new Sabre_HTTP_Request($s);
     $this->assertEquals('http://sabredav.org/foo', $r->getAbsoluteUri());
     $s = array('HTTP_HOST' => 'sabredav.org', 'REQUEST_URI' => '/foo', 'HTTPS' => 'on');
     $r = new Sabre_HTTP_Request($s);
     $this->assertEquals('https://sabredav.org/foo', $r->getAbsoluteUri());
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:9,代码来源:RequestTest.php

示例8: testGetQueryString

 function testGetQueryString()
 {
     $s = array('QUERY_STRING' => 'bla');
     $r = new Sabre_HTTP_Request($s);
     $this->assertEquals('bla', $r->getQueryString());
     $s = array();
     $r = new Sabre_HTTP_Request($s);
     $this->assertEquals('', $r->getQueryString());
 }
开发者ID:rolwi,项目名称:koala,代码行数:9,代码来源:RequestTest.php

示例9: testPatchSuccess

 public function testPatchSuccess()
 {
     $this->node->put('00000000');
     $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'PATCH', 'REQUEST_URI' => '/partial', 'HTTP_X_UPDATE_RANGE' => 'bytes=3-5', 'HTTP_CONTENT_TYPE' => 'application/x-sabredav-partialupdate', 'HTTP_CONTENT_LENGTH' => 3));
     $request->setBody('111');
     $response = $this->request($request);
     $this->assertEquals('HTTP/1.1 204 No Content', $response->status, 'Full response body:' . $response->body);
     $this->assertEquals('00111000', $this->node->get());
 }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:9,代码来源:PluginTest.php

示例10: testCollectionGet

 function testCollectionGet()
 {
     $serverVars = array('REQUEST_URI' => '/', 'REQUEST_METHOD' => 'GET');
     $request = new Sabre_HTTP_Request($serverVars);
     $request->setBody('');
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals(array('Content-Type' => 'application/xml; charset=utf-8', 'DAV' => '1, 3, extended-mkcol'), $this->response->headers);
     $this->assertEquals('HTTP/1.1 207 Multi-Status', $this->response->status, 'Incorrect status response received. Full response body: ' . $this->response->body);
 }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:10,代码来源:MapGetToPropFindTest.php

示例11: testUpdateFileParsableBody

 function testUpdateFileParsableBody()
 {
     $this->calBackend->createCalendarObject('calendar1', 'blabla.ics', 'foo');
     $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'PUT', 'REQUEST_URI' => '/calendars/admin/calendar1/blabla.ics'));
     $request->setBody("BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n");
     $response = $this->request($request);
     $this->assertEquals('HTTP/1.1 204 No Content', $response->status);
     $expected = array('uri' => 'blabla.ics', 'calendardata' => "BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n", 'calendarid' => 'calendar1');
     $this->assertEquals($expected, $this->calBackend->getCalendarObject('calendar1', 'blabla.ics'));
 }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:10,代码来源:ValidateICalTest.php

示例12: testUpdateFileParsableBody

 function testUpdateFileParsableBody()
 {
     $this->cardBackend->createCard('addressbook1', 'blabla.vcf', 'foo');
     $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'PUT', 'REQUEST_URI' => '/addressbooks/admin/addressbook1/blabla.vcf'));
     $body = "BEGIN:VCARD\r\nUID:foo\r\nEND:VCARD\r\n";
     $request->setBody($body);
     $response = $this->request($request);
     $this->assertEquals('HTTP/1.1 204 No Content', $response->status);
     $expected = array('uri' => 'blabla.vcf', 'carddata' => $body);
     $this->assertEquals($expected, $this->cardBackend->getCard('addressbook1', 'blabla.vcf'));
 }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:11,代码来源:ValidateVCardTest.php

示例13: testPutFail

 function testPutFail()
 {
     $serverVars = array('REQUEST_URI' => '/testput.txt', 'REQUEST_METHOD' => 'PUT', 'HTTP_X_EXPECTED_ENTITY_LENGTH' => '20');
     $request = new Sabre_HTTP_Request($serverVars);
     $request->setBody('');
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals('HTTP/1.1 403 Forbidden', $this->response->status);
     $this->assertEquals(array('Content-Type' => 'application/xml; charset=utf-8'), $this->response->headers);
     $this->assertFalse(file_exists(SABRE_TEMPDIR . '/testput.txt'));
 }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:11,代码来源:ServerFinderBlockTest.php

示例14: testPutUpdate

 function testPutUpdate()
 {
     $serverVars = array('REQUEST_URI' => '/test.txt', 'REQUEST_METHOD' => 'PUT');
     $request = new Sabre_HTTP_Request($serverVars);
     $request->setBody('Testing updated file');
     $this->server->httpRequest = $request;
     $this->server->exec();
     $this->assertEquals('0', $this->response->headers['Content-Length']);
     $this->assertEquals('HTTP/1.1 204 No Content', $this->response->status);
     $this->assertEquals('', $this->response->body);
     $this->assertEquals('Testing updated file', file_get_contents($this->tempDir . '/test.txt'));
 }
开发者ID:ZerGabriel,项目名称:friendica-addons,代码行数:12,代码来源:ServerTest.php

示例15: testReportPassThrough

 function testReportPassThrough()
 {
     $fakeServer = new Sabre_DAV_Server(new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleDirectory('bla')));
     $plugin = new Sabre_DAV_Auth_Plugin(new Sabre_DAV_Auth_MockBackend(), 'realm');
     $fakeServer->addPlugin($plugin);
     $request = new Sabre_HTTP_Request(array('REQUEST_METHOD' => 'REPORT', 'HTTP_CONTENT_TYPE' => 'application/xml', 'REQUEST_URI' => '/'));
     $request->setBody('<?xml version="1.0"?><s:somereport xmlns:s="http://www.rooftopsolutions.nl/NS/example" />');
     $fakeServer->httpRequest = $request;
     $fakeServer->httpResponse = new Sabre_HTTP_ResponseMock();
     $fakeServer->exec();
     $this->assertEquals('HTTP/1.1 501 Not Implemented', $fakeServer->httpResponse->status);
 }
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:12,代码来源:PluginTest.php


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