开发者

Zend HTTP Client Invalid URI?

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

$client = new Zend_Http_Client('http://xxfire_killumiex.ap开发者_JAVA技巧i.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?


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;
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜