Exemple #1
0
 function call_geocoder_service($url)
 {
     $response_msg = array(100 => array('100 Continue', 'information'), 101 => array('101 Switching Protocols', 'information'), 102 => array('102 Processing', 'information'), 200 => array('200 OK', 'success'), 201 => array('201 Created', 'success'), 202 => array('202 Accepted', 'success'), 203 => array('203 Non-Authoriative Information', 'success'), 204 => array('204 No Content', 'success'), 205 => array('205 Reset Content', 'success'), 206 => array('206 Partial Content', 'success'), 207 => array('207 Multi-Status', 'success'), 300 => array('300 Multiple Choices', 'redirection'), 301 => array('301 Moved Permanently', 'redirection'), 302 => array('302 Found', 'redirection'), 303 => array('303 See Other', 'redirection'), 304 => array('304 Not Modified', 'redirection'), 305 => array('305 Use Proxy', 'redirection'), 306 => array('306 (Unused)', 'redirection'), 307 => array('307 Temporary Redirect', 'redirection'), 400 => array('400 Bad Request', 'client error'), 401 => array('401 Unauthorized', 'client error'), 402 => array('402 Payment Granted', 'client error'), 403 => array('403 Forbidden', 'client error'), 404 => array('404 Not found', 'client error'), 405 => array('405 Method Not Allowed', 'client error'), 406 => array('406 Not Acceptable', 'client error'), 407 => array('407 Proxy Authentication Required', 'client error'), 408 => array('408 Request Time-out', 'client error'), 409 => array('409 Conflict', 'client error'), 410 => array('410 Gone', 'client error'), 411 => array('411 Length Required', 'client error'), 412 => array('412 Precondition Failed', 'client error'), 413 => array('413 Request Entity Too Large', 'client error'), 414 => array('414 Request-URI Too Large', 'client error'), 415 => array('415 Unsupported Media Type', 'client error'), 416 => array('416 Requested range not satisfiable', 'client error'), 417 => array('417 Expectation Failed', 'client error'), 422 => array('422 Unprocessable Entity', 'client error'), 423 => array('423 Locked', 'client error'), 424 => array('424 Failed Dependency', 'client error'), 500 => array('500 Internal Server Error', 'server error'), 501 => array('501 Not Implemented', 'server error'), 502 => array('502 Bad Gateway', 'server error'), 503 => array('503 Service Unavailable', 'server error'), 504 => array('504 Gateway Timeout', 'server error'), 505 => array('505 HTTP Version Not Supported', 'server error'), 507 => array('507 Insufficient Storage', 'server error'));
     $http = new AkHttpClient();
     $options = array();
     if ($this->geocoders->timeout > 0) {
         $options['timeout'] = $this->geocoders->timeout;
     }
     if (!is_null($this->geocoders->proxy_addr)) {
         $options['_proxy_host'] = $this->geocoders->proxy_addr;
         $options['_proxy_port'] = $this->geocoders->proxy_port;
         if (!is_null($this->geocoders->proxy_user)) {
             $options['_proxy_user'] = $this->geocoders->proxy_user;
             if (!is_null($this->geocoders->proxy_pass)) {
                 $options['_proxy_pass'] = $this->geocoders->proxy_pass;
             }
         }
     }
     $result = array();
     $instance = $http->getRequestInstance($url, 'GET', $options);
     $body = $http->get($url, $options);
     $result['code'] = $http->getResponseCode();
     if ($response_msg[$result['code']][1] != 'success') {
         $result['body'] = $response_msg[$result['code']][0];
         $result['success'] = false;
     } else {
         $result['content-type'] = $http->getResponseHeader('Content-Type');
         $result['server'] = $http->getResponseHeader('Server');
         $result['content-length'] = $http->getResponseHeader('Content-Length');
         $result['body'] = $body;
         $result['http-version'] = $instance->_http;
         $result['success'] = true;
     }
     return $result;
 }
Exemple #2
0
 public function testFileUpload()
 {
     $Http = new AkHttpClient();
     $options['params'] = array('photo' => array('title' => 'My Photo.'));
     $options['file'] = array('inputname' => 'photo', 'filename' => __FILE__);
     $result = $Http->post($this->_test_script . 'people/1/photo', $options);
     $this->assertEqual("My Photo.|" . basename(__FILE__), $result);
 }
 function testFileUpload()
 {
     $Http = new AkHttpClient();
     $options['params'] = array('photo' => array('title' => 'My Photo.'));
     $options['file'] = array('inputname' => 'photo', 'filename' => __FILE__);
     $result = $Http->post(AK_TESTING_URL . '/person/1/photo', $options);
     $this->assertEquals("My Photo.|" . basename(__FILE__), $result);
 }