php-phantomjs icon indicating copy to clipboard operation
php-phantomjs copied to clipboard

Incorrect return of $response->getStatus()

Open jaypeeig opened this issue 7 years ago • 3 comments

jaypeeig avatar Sep 01 '17 06:09 jaypeeig

I always get int 301 even if it reached the site

jaypeeig avatar Sep 02 '17 04:09 jaypeeig

I had the same problem. Say for example your URL is set to http://google.com - this will never return a 200 response, because it redirects to https://www.google.com. Make sure that you're adding the final destination URL after the redirect, or change the check to:

if($response->getStatus() === 200 || $response->getStatus() === 301) {
    // Do stuff
}

LiamMcArthur avatar Sep 13 '17 10:09 LiamMcArthur

I think it needs a follow redirect on https

jaypeeig avatar Oct 03 '17 07:10 jaypeeig