Skip to content

Commit

Permalink
[WebRequest] Add lastRedirection to get last url redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
StefansArya committed Nov 4, 2019
1 parent 4f7b297 commit 613fc24
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Library/WebRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,4 +460,16 @@ public static function contentSize($url){
return 0;
return (float)$data['headers']['Content-Length'];
}

public static function lastRedirection($url){
$ch = curl_init($url);

curl_setopt($ch, CURLOPT_USERAGENT, self::$userAgent);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);

return curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
}
}

0 comments on commit 613fc24

Please sign in to comment.