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


PHP SimpleHttpRequest类代码示例

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


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

示例1: testHttp

 function testHttp()
 {
     $http = new SimpleHttpRequest("www.lastcraft.com/test/network_confirm.php?gkey=gvalue");
     $http->setCookie(new SimpleCookie("ckey", "cvalue"));
     $this->assertIsA($reponse = $http->fetch(), "SimpleHttpResponse");
     $this->assertEqual($reponse->getResponseCode(), 200);
     $this->assertEqual($reponse->getMimeType(), "text/html");
     $this->assertWantedPattern('/A target for the SimpleTest test suite/', $reponse->getContent());
     $this->assertWantedPattern('/gkey=gvalue/', $reponse->getContent());
     $this->assertWantedPattern('/ckey=cvalue/', $reponse->getContent());
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:11,代码来源:live_test.php

示例2: addAdditionalHeaders

 /**
  *    Adds additional manual headers.
  *    @param SimpleHttpRequest $request    Outgoing request.
  *    @access private
  */
 protected function addAdditionalHeaders(&$request)
 {
     foreach ($this->additional_headers as $header) {
         $request->addHeaderLine($header);
     }
 }
开发者ID:Boris-de,项目名称:videodb,代码行数:11,代码来源:user_agent.php

示例3: addBasicHeaders

 /**
  *    Presents the appropriate headers for this
  *    location for basic authentication.
  *    @param SimpleHttpRequest $request  Request to modify.
  *    @param string $username            Username for realm.
  *    @param string $password            Password for realm.
  *    @access public
  */
 static function addBasicHeaders($request, $username, $password)
 {
     if ($username && $password) {
         $request->addHeaderLine('Authorization: Basic ' . base64_encode("{$username}:{$password}"));
     }
 }
开发者ID:GerHobbelt,项目名称:simpletest,代码行数:14,代码来源:authentication.php

示例4: testContentHeadersCalculatedWithXmlEntityBody

 public function testContentHeadersCalculatedWithXmlEntityBody()
 {
     $socket = new MockSimpleSocket();
     $socket->expectAt(0, 'write', array("Content-Length: 27\r\n"));
     $socket->expectAt(1, 'write', array("Content-Type: text/xml\r\n"));
     $socket->expectAt(2, 'write', array("\r\n"));
     $socket->expectAt(3, 'write', array("<a><b>one</b><c>two</c></a>"));
     $route = new MockSimpleRoute();
     $route->setReturnReference('createConnection', $socket);
     $route->expect('createConnection', array('POST', 15));
     $request = new SimpleHttpRequest($route, new SimplePostEncoding('<a><b>one</b><c>two</c></a>', 'text/xml'));
     $this->assertIsA($request->fetch(15), 'SimpleHttpResponse');
 }
开发者ID:VasuLief,项目名称:simpletest,代码行数:13,代码来源:http_test.php

示例5: testContentHeadersCalculated

 function testContentHeadersCalculated()
 {
     $socket = new MockSimpleSocket();
     $socket->expectArgumentsAt(0, 'write', array("Content-Length: 3\r\n"));
     $socket->expectArgumentsAt(1, 'write', array("Content-Type: application/x-www-form-urlencoded\r\n"));
     $socket->expectArgumentsAt(2, 'write', array("\r\n"));
     $socket->expectArgumentsAt(3, 'write', array("a=A"));
     $route = new MockSimpleRoute();
     $route->setReturnReference('createConnection', $socket);
     $route->expectArguments('createConnection', array('POST', 15));
     $request = new SimpleHttpRequest($route, new SimplePostEncoding(array('a' => 'A')));
     $this->assertIsA($request->fetch(15), 'SimpleHttpResponse');
 }
开发者ID:Hassanj343,项目名称:candidats,代码行数:13,代码来源:http_test.php

示例6: post

 public static function post($url, $data)
 {
     return SimpleHttpRequest::doConnect('post', $url, $data);
 }
开发者ID:aerios,项目名称:simple-http-request,代码行数:4,代码来源:SimpleHttpRequest.php

示例7: foreach

 /**
  *    Adds additional manual headers.
  *    @param SimpleHttpRequest $request    Outgoing request.
  *    @access private
  */
 function _addAdditionalHeaders($request)
 {
     foreach ($this->_additional_headers as $header) {
         $request->addHeaderLine($header);
     }
 }
开发者ID:Nurudeen,项目名称:prado,代码行数:11,代码来源:user_agent.php

示例8: addHeaders

 /**
  *    Adds the current cookies to a request.
  *    @param SimpleHttpRequest $request    Request to modify.
  *    @param SimpleUrl $url                Cookie selector.
  *    @access private
  */
 function addHeaders(&$request, $url)
 {
     $cookies = $this->getValidCookies($url->getHost(), $url->getPath());
     foreach ($cookies as $cookie) {
         $request->setCookie($cookie);
     }
 }
开发者ID:sebs,项目名称:simpletest,代码行数:13,代码来源:user_agent.php

示例9: fetchUrl

 /**
  *    Fetches a URL performing the standard tests.
  *    @param $url        Target to fetch as string.
  *    @param $request    Test version of SimpleHttpRequest.
  *    @return            Content of page.
  *    @access public
  */
 function fetchUrl($url, $request = false)
 {
     if (!is_object($request)) {
         $request = new SimpleHttpRequest($url);
     }
     foreach ($this->_cookie_jar->getValidCookies() as $cookie) {
         $request->setCookie($cookie);
     }
     $this->_response = $request->fetch();
     $this->_checkExpectations($url, $this->_response);
     foreach ($this->_response->getNewCookies() as $cookie) {
         $parsed_url = new SimpleUrl($url);
         if ($parsed_url->getHost()) {
             $cookie->setHost($parsed_url->getHost());
         }
         $this->_cookie_jar->setCookie($cookie);
     }
     return $this->_response->getContent();
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:26,代码来源:browser.php

示例10: addBasicHeaders

 /**
  *    Presents the appropriate headers for this
  *    location for basic authentication.
  *    @param SimpleHttpRequest $request  Request to modify.
  *    @param string $username            Username for realm.
  *    @param string $password            Password for realm.
  *    @access public
  *    @static
  */
 function addBasicHeaders(&$request, $username, $password) {
     if ($username && $password) {
         $request->addHeaderLine(
                 'Authorization: Basic ' . base64_encode("$username:$password"));
     }
 }
开发者ID:unruthless,项目名称:ThinkUp,代码行数:15,代码来源:authentication.php

示例11: testMultipleCookieWriting

 function testMultipleCookieWriting()
 {
     $request = new SimpleHttpRequest("a.valid.host/and/path");
     $request->setCookie(new SimpleCookie("a", "A"));
     $request->setCookie(new SimpleCookie("b", "B"));
     $socket =& new MockSimpleSocket($this);
     $socket->setReturnValue("isError", false);
     $socket->expectArgumentsSequence(2, "write", array("Cookie: a=A;b=B\r\n"));
     $request->fetch($socket);
     $socket->tally();
 }
开发者ID:adamfranco,项目名称:harmoni,代码行数:11,代码来源:http_test.php

示例12:

 /**
  *    Sends the headers.
  *    @param SimpleSocket $socket   Open socket.
  *    @param string $method         HTTP request method,
  *                                  usually GET.
  *    @param string $content        Content to send with request.
  *    @access protected
  */
 function _dispatchRequest(&$socket, $method, $content)
 {
     parent::_dispatchRequest($socket, $method, SimpleUrl::encodeRequest($content));
 }
开发者ID:BGCX067,项目名称:ezpdo2-svn-to-git,代码行数:12,代码来源:http.php

示例13: strlen

 /**
  *    Sends the headers and request data.
  *    @param SimpleSocket $socket  Open socket.
  *    @param string $method        HTTP request method, usually GET.
  *    @access protected
  */
 function _request(&$socket, $method) {
     $this->addHeaderLine('Content-Length: ' . strlen($this->_pushed_content));
     parent::_request($socket, $method);
     $socket->write($this->_pushed_content);
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:11,代码来源:http.php

示例14: strlen

 /**
  *    Sends the headers and request data.
  *    @param SimpleSocket $socket  Open socket.
  *    @param string $method        HTTP request method, usually GET.
  *    @access protected
  */
 function _request(&$socket, $method)
 {
     $this->addHeaderLine('Content-Length: ' . strlen($this->_pushed_content));
     $this->addHeaderLine('Content-Type: application/x-www-form-urlencoded');
     parent::_request($socket, $method);
     $socket->write($this->_pushed_content);
 }
开发者ID:sebs,项目名称:simpletest,代码行数:13,代码来源:http.php


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