REST Response Error: inet_pton() [function.inet-pton]: Unrecognized address

classic Classic list List threaded Threaded
1 message Options
zpc
Reply | Threaded
Open this post in threaded view
|

REST Response Error: inet_pton() [function.inet-pton]: Unrecognized address

zpc

Hello all,

I've got a tricky situation here. I'm making a request to a REST client. It works like so:

$client = new Zend_Rest_Client('http://db.tigsource.com/games/' . $urlTitle . '.xml');
$result = $client->get();

And that's it. It works in normal cases. However, this particular service is not consistent in how they deal with apostrophes when translating a title to a URL, e.g. the title "zpc's example" might be accessed through one of either "zpc-s-example.xml" or "zpcs-example.xml". Since they are inconsistent in this way, I have to request it one way, and if it doesn't work, the other.

I have a method that does this, and in my unit tests, it works just as it should. In a single test (so no teardown and setup takes place between them), I request two titles whose URLs handle the apostrophes differently, and the function successfully attempts the second URL style if the first throws an exception.

However, when I manually test it, the second request throws an exception (whereas in the unit test, it's successful) with the following error message:

REST Response Error: inet_pton() [function.inet-pton]: Unrecognized address db.tigsource.com

Here's the main code in question, with the non-relevant parts taken out:

        // $tryAgain will be true if the title contains apostrophes
        $urlTitle = $this->urlizeTitle($title);
        $client = new Zend_Rest_Client();
        do {            
            try {                            
                    $client->setUri('http://db.tigsource.com/games/' . $urlTitle . '.xml');
                    $result = $client->get();                    
                    break;
            } catch (Exception $e) {
                if ($tryAgain) {
                    $tryAgain = false;
                    $urlTitle = $this->urlizeTitleOmitApostrophes($title);                    
                } else {
                    // return error info and some other stuff
                }
            }
        } while (1==1);
The stack trace after calling $client->setUri() the second time looks like this:
#0 /Applications/MAMP/htdocs/indiedevnet/library/Zend/Validate/Ip.php(62): Zend_Rest_Client_Result->handleXmlErrors(2, 'inet_pton() [isValid('db.tigsource.co...')
#2 /Applications/MAMP/htdocs/indiedevnet/library/Zend/Uri/Http.php(448): Zend_Validate_Hostname->isValid('db.tigsource.co...')
#3 /Applications/MAMP/htdocs/indiedevnet/library/Zend/Uri/Http.php(280): Zend_Uri_Http->validateHost('db.tigsource.co...')
#4 /Applications/MAMP/htdocs/indiedevnet/library/Zend/Uri/Http.php(154): Zend_Uri_Http->valid()
#5 /Applications/MAMP/htdocs/indiedevnet/library/Zend/Uri.php(132): Zend_Uri_Http->__construct()
#6 /Applications/MAMP/htdocs/indiedevnet/library/Zend/Rest/Client.php(77): Zend_Uri::factory('http', '//db.tigsource....')

Any ideas what's causing this? I'm using ZF 1.7.5 if that's any help.

Much thanks in advance