Zend HTTP Client Invalid URI?

China☆狼群 提交于 2019-12-11 17:47:15

问题


I'm having trouble using Zend HTTP on a URL:

$client = new Zend_Http_Client('http://xxfire_killumiex.api.channel.livestream.com/2.0/info.json');
$feed = $client->request()->getBody();

For some reason, this gives me an error...

Invalid URI supplied

Whats wrong this this specific url?


回答1:


Whats wrong this this specific url?

The underscore.

From RFC 1912

Allowable characters in a label for a host name are only ASCII letters, digits, and the `-' character.

Edit

After doing some more reading, it seems that Zend may be wrong in this case.

See Can (domain name) subdomains have an underscore "_" in it?

According to ZF-9671, you might be out of luck, though I've re-opened the issue.

My suggestion in the meantime; Create your own HTTP client class like this

class My_Http_Client extends Zend_Http_Client
{
    public function validateHost($host = null)
    {
        if ($host === null) {
            $host = $this->_host;
        }

        // If the host is empty, then it is considered invalid
        if (strlen($host) === 0) {
            return false;
        }

        return true;
    }
}


来源:https://stackoverflow.com/questions/5318674/zend-http-client-invalid-uri

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!