59723

Zend HTTP Client Invalid URI?

Question:

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?

Answer1:

<blockquote>

Whats wrong this this specific url?

</blockquote>

The underscore.

From RFC 1912

<blockquote>

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

</blockquote>

<strong>Edit</strong>

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

See <a href="https://stackoverflow.com/questions/2180465/can-someone-have-a-subdomain-with-an-underscore-in-it/2183140#2183140" rel="nofollow">Can (domain name) subdomains have an underscore "_" in it?</a>

According to <a href="http://www.zendframework.com/issues/browse/ZF-9671" rel="nofollow">ZF-9671</a>, 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; } }

Recommend

  • I am not able to identify elements using protractor in angular 2 application
  • INT(3) column not cliping the value to appropriate length and allowing the full value to be inserted
  • Using the HTTP Range Header with a range specifier other than bytes?
  • Searching IMAP inbox for messages from a specefic sender and use of wild cards?
  • lua - metadata for documentation
  • dateutils rrule returns dates that 2 months apart
  • Different results with base64 encoding in Google Apps Scripts and JavaScript
  • How to create attribute (xmlns:xsd) to XML node in Java?
  • Meaning of Depth header in WebDAV PROPFIND method
  • What I have to do to solve “java.lang.IllegalArgumentException”?
  • Regular expression validation for URL in ASP.net
  • Getting Image from the server while ignoring the file's case sensitivity
  • create a temporary file with a specified name in java
  • Unknown xml serialization content/namespace from Service bus brokered message
  • Meta refresh with semicolon
  • error updating record in database
  • Violates RFC 2109: host > minus domain may not contain any dots
  • url scheme for ssh: Calling command on remote host
  • Is it possible to specialize on a static lifetime?
  • Using Sax parsing to edit and write XML in VB6
  • Android Google Maps API v2 start navigation
  • CakePHP ACL tutorial initDB function warnings
  • System.InvalidCastException: Specified cast is not valid
  • Debug.DrawLine not showing in the GameView
  • Yii2: Config params vs. const/define
  • Dialing with Intent.ACTION_CALL stopps at # in phone number
  • Meteor: Do Something On Email Verification Confirmation
  • Exception “firebase.functions() takes … no argument …” when specifying a region for a Cloud Function
  • Using variable in a value field in jMeter
  • Where to put my custom functions in Wordpress?
  • Symfony2: How to get request parameter
  • RestKit - RKRequestDelegate does not exist
  • Numpy divide by zero. Why?
  • SetUp method failed while running tests from teamcity
  • WPF Applying a trigger on binding failure
  • log4net write single file for each call to log.info
  • Getting error when using KSoap library to consume .NET web services
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Linking SubReports Without LinkChild/LinkMaster
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass