follow redirect, do not verify ssl certificates, use final after-redirect url
[phinde.git] / bin / index.php
index eb82df231f7819edc8e7a04eeee52438171adef7..dd32dea86148e5007a8aa133a8e2a21bfa579212 100755 (executable)
@@ -24,11 +24,11 @@ if ($existingDoc && $existingDoc->status == 'indexed') {
 }
 //FIXME: sourcetitle, sourcelink
 
 }
 //FIXME: sourcetitle, sourcelink
 
-//FIXME: enable redirects
-//FIXME: enable ssl 
 $req = new \HTTP_Request2($url);
 $req = new \HTTP_Request2($url);
+$req->setConfig('follow_redirects', true);
 $req->setConfig('connect_timeout', 5);
 $req->setConfig('timeout', 10);
 $req->setConfig('connect_timeout', 5);
 $req->setConfig('timeout', 10);
+$req->setConfig('ssl_verify_peer', false);
 $res = $req->send();
 //FIXME: try-catch
 
 $res = $req->send();
 //FIXME: try-catch
 
@@ -49,7 +49,7 @@ if (!in_array($mimetype, $supportedIndexTypes)) {
 
 //FIXME: update index only if changed since last index time
 //FIXME: extract base url from html
 
 //FIXME: update index only if changed since last index time
 //FIXME: extract base url from html
-//FIXME: use final URL after redirects
+$url = $res->getEffectiveUrl();
 $base = new \Net_URL2($url);
 
 $indexDoc = new \stdClass();
 $base = new \Net_URL2($url);
 
 $indexDoc = new \stdClass();
@@ -61,6 +61,7 @@ $doc = new \DOMDocument();
 $sx = simplexml_import_dom($doc);
 
 $indexDoc->url = $url;
 $sx = simplexml_import_dom($doc);
 
 $indexDoc->url = $url;
+$indexDoc->schemalessUrl = Helper::noSchema($url);
 $indexDoc->type = 'html';
 $indexDoc->subtype = '';
 $indexDoc->mimetype = $mimetype;
 $indexDoc->type = 'html';
 $indexDoc->subtype = '';
 $indexDoc->mimetype = $mimetype;