From 0c29f7e44d8b766f944b086642a38526cf38c182 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Thu, 16 Dec 2010 08:51:04 +0100 Subject: [PATCH] add dummy responses --- Wrt3g/DummyRequest.php | 11 ++++++++++- scripts/linksys-wrt3g.php | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Wrt3g/DummyRequest.php b/Wrt3g/DummyRequest.php index 97f3217..e099736 100644 --- a/Wrt3g/DummyRequest.php +++ b/Wrt3g/DummyRequest.php @@ -10,7 +10,8 @@ class Wrt3g_DummyRequest extends HTTP_Request2 * @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() { + $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( diff --git a/scripts/linksys-wrt3g.php b/scripts/linksys-wrt3g.php index 4d64b5a..824c287 100755 --- a/scripts/linksys-wrt3g.php +++ b/scripts/linksys-wrt3g.php @@ -27,7 +27,10 @@ if (file_exists($configFile)) { } $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', -- 2.30.2