コード例 #1
0
ファイル: live_test.php プロジェクト: Clansuite/Clansuite
 public function testRecordOfSentCharacters()
 {
     $socket = new SimpleSocket('www.lastcraft.com', 80, 15);
     $this->assertTrue($socket->write("GET /test/network_confirm.php HTTP/1.0\r\n"));
     $socket->write("Host: www.lastcraft.com\r\n");
     $socket->write("Connection: close\r\n\r\n");
     $socket->close();
     $this->assertEqual($socket->getSent(), "GET /test/network_confirm.php HTTP/1.0\r\n" . "Host: www.lastcraft.com\r\n" . "Connection: close\r\n\r\n");
 }
コード例 #2
0
ファイル: live_test.php プロジェクト: simpletest/simpletest
 public function testRecordOfSentCharacters()
 {
     $socket = new SimpleSocket($this->host, $this->port, 15);
     $this->assertTrue($socket->write("GET /network_confirm.php HTTP/1.0\r\n"));
     $socket->write("Host: {$this->host}\r\n");
     $socket->write("Connection: close\r\n\r\n");
     $socket->close();
     $this->assertEqual($socket->getSent(), "GET /network_confirm.php HTTP/1.0\r\n" . "Host: {$this->host}\r\n" . "Connection: close\r\n\r\n");
 }
コード例 #3
0
ファイル: live_test.php プロジェクト: GerHobbelt/simpletest
 function testRecordOfSentCharacters()
 {
     $site = $this->getServerInfo();
     $socket = new SimpleSocket($site['host'], $site['port'], 15);
     $this->assertTrue($socket->write("GET {$site['path']}network_confirm.php HTTP/1.0\r\n"));
     $socket->write("Host: {$site['host']}\r\n");
     $socket->write("Connection: close\r\n\r\n");
     $socket->close();
     $this->assertEqual($socket->getSent(), "GET {$site['path']}network_confirm.php HTTP/1.0\r\n" . "Host: {$site['host']}\r\n" . "Connection: close\r\n\r\n");
 }
コード例 #4
0
ファイル: live_test.php プロジェクト: adamfranco/harmoni
 function testSocket()
 {
     $socket = new SimpleSocket("www.lastcraft.com", 80);
     $this->assertFalse($socket->isError(), "Error [" . $socket->getError() . "]");
     $this->assertTrue($socket->isOpen());
     $this->assertTrue($socket->write("GET www.lastcraft.com/test/network_confirm.php HTTP/1.0\r\n"));
     $socket->write("Host: localhost\r\n");
     $socket->write("Connection: close\r\n\r\n");
     $this->assertEqual($socket->read(8), "HTTP/1.1");
     $socket->close();
     $this->assertEqual($socket->read(8), "");
 }
コード例 #5
0
ファイル: eclipse.php プロジェクト: JackCanada/moodle-hacks
 function invoke($method)
 {
     ob_start();
     parent::invoke($method);
     $output = ob_get_contents();
     ob_end_clean();
     $sock = new SimpleSocket("127.0.0.1", $this->_port, 5);
     $sock->write($output);
     $sock->close();
     echo $sock->getError();
 }
コード例 #6
0
ファイル: http.php プロジェクト: JackCanada/moodle-hacks
 /**
  *    Sends the headers.
  *    @param SimpleSocket $socket           Open socket.
  *    @param string $method                 HTTP request method,
  *                                          usually GET.
  *    @param SimpleFormEncoding $encoding   Content to send with request.
  *    @access private
  */
 function _dispatchRequest(&$socket, $encoding)
 {
     foreach ($this->_headers as $header_line) {
         $socket->write($header_line . "\r\n");
     }
     if (count($this->_cookies) > 0) {
         $socket->write("Cookie: " . implode(";", $this->_cookies) . "\r\n");
     }
     $encoding->writeHeadersTo($socket);
     $socket->write("\r\n");
     $encoding->writeTo($socket);
 }
コード例 #7
0
ファイル: http.php プロジェクト: BGCX067/ezpdo2-svn-to-git
 /**
  *    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)
 {
     if ($content) {
         $socket->write("Content-Length: " . strlen($content) . "\r\n");
         $socket->write("Content-Type: application/x-www-form-urlencoded\r\n");
     }
     foreach ($this->_headers as $header_line) {
         $socket->write($header_line . "\r\n");
     }
     if (count($this->_cookies) > 0) {
         $socket->write("Cookie: " . $this->_marshallCookies($this->_cookies) . "\r\n");
     }
     $socket->write("\r\n");
     if ($content) {
         $socket->write($content);
     }
 }
コード例 #8
0
 /**
  *    Dispatches the form data down the socket.
  *    @param SimpleSocket $socket        Socket to write to.
  *    @access public
  */
 function writeTo(&$socket)
 {
     $socket->write($this->encode());
 }
コード例 #9
0
ファイル: http.php プロジェクト: sebs/simpletest
 /**
  *    Sends the headers.
  *    @param SimpleSocket $socket           Open socket.
  *    @param string $method                 HTTP request method,
  *                                          usually GET.
  *    @param SimpleFormEncoding $encoding   Content to send with request.
  *    @access private
  */
 function _dispatchRequest(&$socket, $method, $encoding)
 {
     if ($encoding || $method == 'POST') {
         $socket->write("Content-Length: " . $this->_getContentLength($encoding) . "\r\n");
         $socket->write("Content-Type: application/x-www-form-urlencoded\r\n");
     }
     foreach ($this->_headers as $header_line) {
         $socket->write($header_line . "\r\n");
     }
     if (count($this->_cookies) > 0) {
         $socket->write("Cookie: " . $this->_marshallCookies($this->_cookies) . "\r\n");
     }
     $socket->write("\r\n");
     if ($encoding) {
         $socket->write($encoding->asString());
     }
 }
コード例 #10
0
ファイル: http.php プロジェクト: guicara/simpletest
 /**
  * Sends the headers.
  *
  * @param SimpleSocket $socket           Open socket.
  * @param string $method                 HTTP request method, usually GET.
  * @param SimpleFormEncoding $encoding   Content to send with request.
  */
 protected function dispatchRequest($socket, $encoding)
 {
     foreach ($this->headers as $header_line) {
         $socket->write($header_line . "\r\n");
     }
     if (count($this->cookies) > 0) {
         $socket->write('Cookie: ' . implode(';', $this->cookies) . "\r\n");
     }
     $encoding->writeHeadersTo($socket);
     $socket->write("\r\n");
     $encoding->writeTo($socket);
 }
コード例 #11
0
ファイル: http.php プロジェクト: adamfranco/harmoni
 /**
  *    Fetches the content and parses the headers.
  *    @param $socket        Test override.
  *    @return               Either false or a HttpResponse.
  *    @access public
  */
 function fetch($socket = false)
 {
     if (!is_object($socket)) {
         $socket = new SimpleSocket($this->_url->getHost());
     }
     if ($socket->isError()) {
         return false;
     }
     $socket->write("GET " . $this->_url->getPath() . $this->_url->getEncodedRequest() . " HTTP/1.0\r\n");
     $socket->write("Host: " . $this->_url->getHost() . "\r\n");
     foreach ($this->_user_headers as $header_line) {
         $socket->write($header_line . "\r\n");
     }
     if (count($this->_cookies) > 0) {
         $socket->write("Cookie: " . $this->_marshallCookies($this->_cookies) . "\r\n");
     }
     $socket->write("Connection: close\r\n");
     $socket->write("\r\n");
     return $this->_createResponse($socket);
 }
コード例 #12
0
ファイル: http.php プロジェクト: BackupTheBerlios/limb-svn
 /**
  *    Sends the headers.
  *    @param SimpleSocket $socket   Open socket.
  *    @param string $method         HTTP request method,
  *                                  usually GET.
  *    @access protected
  */
 function _request(&$socket, $method) {
     $socket->write($method . " " . $this->_url->getPath() . $this->_url->getEncodedRequest() . " HTTP/1.0\r\n");
     $socket->write("Host: " . $this->_url->getHost() . "\r\n");
     foreach ($this->_user_headers as $header_line) {
         $socket->write($header_line . "\r\n");
     }
     if (count($this->_cookies) > 0) {
         $socket->write("Cookie: " . $this->_marshallCookies($this->_cookies) . "\r\n");
     }
     $socket->write("Connection: close\r\n");
     $socket->write("\r\n");
 }
コード例 #13
0
ファイル: eclipsetest.php プロジェクト: sebs/simpletest
 /**
  *    Runs the test methods in the test case, or not if the
  *    scorer blocks it.
  *    @param SimpleTest $test_case    Test case to run test on.
  *    @param string $method           Name of test method.
  *    @access public
  */
 function run()
 {
     $methods = get_class_methods(get_class($this->_test_case));
     $invoker =& $this->_test_case->createInvoker();
     foreach ($methods as $method) {
         if (!$this->_isTest($method)) {
             continue;
         }
         if ($this->_isConstructor($method)) {
             continue;
         }
         ob_start();
         echo $this->_start;
         $this->_scorer->paintMethodStart($method);
         if ($this->_scorer->shouldInvoke($this->_test_case->getLabel(), $method)) {
             $invoker->invoke($method);
         }
         $this->_scorer->paintMethodEnd($method);
         echo $this->_end;
         $output = ob_get_contents();
         ob_end_clean();
         $sock = new SimpleSocket("127.0.0.1", $this->_port, 5);
         $sock->write($output);
         $sock->close();
         echo $sock->getError();
     }
 }