add dummy responses
authorChristian Weiske <cweiske@cweiske.de>
Thu, 16 Dec 2010 07:51:04 +0000 (08:51 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Thu, 16 Dec 2010 07:51:04 +0000 (08:51 +0100)
Wrt3g/DummyRequest.php
scripts/linksys-wrt3g.php

index 97f3217bd644b05954fe519c30b913d98690a1a1..e09973630ab7499b614c4458f78febce3f89fd97 100644 (file)
@@ -10,7 +10,8 @@ class Wrt3g_DummyRequest extends HTTP_Request2
      * @var array
      */
     public static $mapping = array(
      * @var array
      */
     public static $mapping = array(
-        '/Status_NoAuth.asp' => 'tests/status_noauth-connected.htm'
+        '/Status_NoAuth.asp'  => 'tests/status_noauth-connected.htm',
+        '/index_wstatus1.asp' => 'tests/index_wstatus1-connected-excellent.htm'
     );
 
 
     );
 
 
@@ -41,6 +42,14 @@ class Wrt3g_DummyRequest extends HTTP_Request2
     */
     public function send()
     {
     */
     public function send()
     {
+        $host = $this->url->getHost();
+        if (strlen($host) == 3 && is_numeric($host)) {
+            $this->adapter->addResponse(
+                "HTTP/1.0 $host dummy\n\nnothing"
+            );
+            return parent::send();
+        }
+
         $path = $this->url->getPath();
         if (!isset(self::$mapping[$path])) {
             throw new HTTP_Request2_Exception(
         $path = $this->url->getPath();
         if (!isset(self::$mapping[$path])) {
             throw new HTTP_Request2_Exception(
index 4d64b5ac4be2c31abfb48d19f0bf314640c3baa5..824c287ae8861718b8f2945de4fa10068aef9893 100755 (executable)
@@ -27,7 +27,10 @@ if (file_exists($configFile)) {
 }
 
 $parser = new Console_CommandLine();
 }
 
 $parser = new Console_CommandLine();
-$parser->description = 'Tool to control Linksys WRT3g routers';
+$parser->description = "Tool to control Linksys WRT3g routers
+
+Dummy responses can be controlled with the host parameter:
+ A 3-letter numeric host is interpreted as HTTP response code";
 $parser->version = '0.0.1';//FIXME: dynamic
 $parser->addOption(
     'host',
 $parser->version = '0.0.1';//FIXME: dynamic
 $parser->addOption(
     'host',