diff --git a/phpQuery/phpQuery/plugins/WebBrowser.php b/phpQuery/phpQuery/plugins/WebBrowser.php index 6688d3f..e5e83d0 100644 --- a/phpQuery/phpQuery/plugins/WebBrowser.php +++ b/phpQuery/phpQuery/plugins/WebBrowser.php @@ -84,6 +84,26 @@ public static function location($self, $url = null) { } return $return; } + + + public static function download($self, $url = null) { + $xhr = isset($self->document->xhr) + ? $self->document->xhr + : null; + $xhr = phpQuery::ajax(array( + 'url' => $url, + ), $xhr); + $return = false; + if ($xhr->getLastResponse()->isSuccessful()) { + $return = phpQueryPlugin_WebBrowser::browserDownload($xhr); + if (isset($self->document->WebBrowserCallback)) + phpQuery::callbackRun( + $self->document->WebBrowserCallback, + array($return) + ); + } + return $return; + } } class phpQueryPlugin_WebBrowser { /** @@ -246,6 +266,17 @@ public static function browserReceive($xhr) { } else return $pq; } + + /** + * @param Zend_Http_Client $xhr + */ + public static function browserDownload($xhr) { + phpQuery::debug("[WebBrowser] Received from ".$xhr->getUri(true)); + // TODO handle meta redirects + $body = $xhr->getLastResponse()->getBody(); + + return $body; + } /** * * @param $e diff --git a/test-cases/document-types/document-utf8.php b/test-cases/document-types/document-utf8.php index 35353c7..9621d58 100644 --- a/test-cases/document-types/document-utf8.php +++ b/test-cases/document-types/document-utf8.php @@ -8,6 +8,6 @@
Hello World! ąśżźć - '>Attr test + '>Attr test