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

Undefined index: scheme #33

Closed
aristoler opened this issue Aug 30, 2018 · 5 comments
Closed

Undefined index: scheme #33

aristoler opened this issue Aug 30, 2018 · 5 comments

Comments

@aristoler
Copy link

你好,出现大量的scheme错误,是什么原因?怎么解决
E_NOTICE: ErrorException: Undefined index: scheme in /Users/Arist/Git/php-curl/src/Toolkit.php:302
Stack trace:

function urlFormater($url)
{
    if (! $this->isUrl($url)) {
        return;
    }
    $url = trim($url);
    $url = str_replace(' ', '+', $url);
    $parse = parse_url($url);
    strtolower($parse['scheme']);
    strtolower($parse['host']);
    return $this->buildUrl($parse);
}
@aristoler
Copy link
Author

aristoler commented Aug 30, 2018

_NOTICE: ErrorException: Undefined index: scheme in /Users/Arist/GitHere/php-curl/src/Toolkit.php:302
Stack trace:
#0 /Users/Arist/Git/php-curl/src/Toolkit.php(302): ErrorHandler::{closure}(8, 'Undefined index...', '/Users/Arist/Gi...', 302, Array)
#1 /Users/Arist/Git/php-curl/src/HttpClone.php(93): Ares333\Curl\Toolkit->urlFormater('//s145js.nicebo...')
#2 /Users/Arist/Git/php-curl/src/HttpClone.php(143): Ares333\Curl\HttpClone->urlFormater('//s145js.nicebo...')
#3 /Users/Arist/Git/php-curl/src/HttpClone.php(221): Ares333\Curl\HttpClone->url2src('//s145js.nicebo...', 、, true)
#4 /Users/Arist/Git/php-curl/demo/http_clone.php(37): Ares333\Curl\HttpClone->onProcess(Array, Array)
#5 [internal function]: HttpCloneDemo->onProcess(Array, Array)
#6 /Users/Arist/Git/php-curl/src/Curl.php(494): call_user_func(Array, Array, Array)
#7 /Users/Arist/Git/php-curl/src/Curl.php(466): Ares333\Curl\Curl->onProcess(Array, Array)
#8 /Users/Arist/Git/php-curl/src/Curl.php(285): Ares333\Curl\Curl->runTask()
#9 /Users/Arist/Git/php-curl/src/HttpClone.php(126): Ares333\Curl\Curl->start()
#10 /Users/Arist/Git/php-curl/demo/http_clone.php(93): Ares333\Curl\HttpClone->start()

@ares333
Copy link
Owner

ares333 commented Aug 30, 2018

没遇到过,echo $url变量看一下,php的parse_url()解析url变量出问题了。

@aristoler
Copy link
Author

Omit the protocol from embedded resources. Omit the protocol portion (http:, https:) from URLs pointing to images and other media files, style sheets, and scripts unless the respective files are not available over both protocols. Omitting the protocol—which makes the URL relative—prevents mixed content issues and results in minor file size savings. 以上是原因。scheme不一定存在。 strtolower($parse['scheme']);

@ares333
Copy link
Owner

ares333 commented Sep 1, 2018

这种机制在浏览器中默认支持,curl不支持,所以需要一个默认scheme,scheme由library添加不合适,在用户逻辑里面补全默认sheme可以解决问题。

@aristoler
Copy link
Author

默认不太合适。用父级页面的scheme比较合适

@ares333 ares333 closed this as completed Feb 22, 2020
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

No branches or pull requests

2 participants