Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request scheme will never be HTTPS #213

Open
melvin-ibuildings opened this issue Dec 13, 2017 · 0 comments · May be fixed by #214
Open

Request scheme will never be HTTPS #213

melvin-ibuildings opened this issue Dec 13, 2017 · 0 comments · May be fixed by #214

Comments

@melvin-ibuildings
Copy link

While using this library with the drupal module i noticed that absolute images in the format
<img src="/myimage/image.png"> would not get translated to amp-img.

The images do not have a width or height so it has to load the images to find these.

This part in the README looked much like my problem but did not seem to be the fix i needed as it did not work after following the tips.

If you have s with https urls and they don't have height/width attributes and you are using PHP 5.6 or higher and you have not listed any certificate authorities (cafile) in your php.ini file then the library may have problems converting these to . This is because of http://php.net/manual/en/migration56.openssl.php . That link also has a work around.

When debugging i noticed the url used was http://myserver:443 which does not work as it expected htts://myserver.

The problem seems to be in this code

       // Get the request scheme http, https etc.
        if (empty($options['request_scheme'])) {
            if (!empty($_SERVER['https'])) {
                $this->options['request_scheme'] = 'https://';
            } else {
                $this->options['request_scheme'] = 'http://';
            }
        }

where $_SERVER['https'] should be $_SERVER['HTTPS'] (this solved it for me)

Also not sure if you want to support the edgecase noted in the PHP doc by checking for "off" as well

'HTTPS'
Set to a non-empty value if the script was queried through the HTTPS protocol.
Note: Note that when using ISAPI with IIS, the value will be off if the request was not made through the HTTPS protocol.

@blauerberg blauerberg linked a pull request Jan 19, 2018 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant