+ $this->config = new Wrt3g_Config($this);
+ $this->config->load($options);
+ }
+
+
+
+ /**
+ * Returns the base URL to use for requests that require authentification.
+ * Includes username, password and host.
+ *
+ * @return string URL without trailing slash after the host
+ */
+ protected function getAuthBaseUrl()
+ {
+ return 'http://'
+ . $this->config->user
+ . ':' . $this->config->password
+ . '@' . $this->config->host;
+ }
+
+
+
+ /**
+ * Returns the base URL to use for requests that do
+ * not require authentification.
+ *
+ * @return string URL without trailing slash after the host
+ */
+ protected function getAnonBaseUrl()
+ {
+ return 'http://' . $this->config->host;
+ }
+
+
+
+ /**
+ * Creates a new HTTP_Request2 object, attaches an observer
+ * if necessary and returns it.
+ *
+ * @return HTTP_Request2
+ */
+ protected function createRequest()
+ {
+ $r = new $this->requestClass();
+ if ($this->verbosity >= 3) {
+ //register observer
+ $r->attach(new Wrt3g_RequestObserver($this));
+ }
+ return $r;
+ }
+
+
+
+ /**
+ * Reboots the router.
+ *
+ * @return HTTP_Request2_Response
+ *
+ * @throws Exception When the router can't be reached, or unauthorized
+ */
+ public function reboot()
+ {
+ $url = $this->getAuthBaseUrl() . '/apply.cgi';
+ $this->log('Connecting to ' . $url);
+
+ $r = $this->createRequest();