Exemplo n.º 1
0
Arquivo: Url.php Projeto: blar/http
 /**
  * @return string
  */
 public function getOrigin()
 {
     $origin = new Url();
     $origin->setScheme($this->getScheme());
     $origin->setHostname($this->getHostname());
     $origin->setPort($this->getPort());
     return rtrim($origin, '/');
 }
Exemplo n.º 2
0
 public function testOrigin()
 {
     $url = new Url('http://www.example.com/foo/bar?foo=23');
     $this->assertEquals('http://www.example.com', $url->getOrigin());
 }
Exemplo n.º 3
0
 /**
  * @param Blar\Http\HttpRequest $request Request.
  * @param Blar\Webservice\WebserviceMethod $method Method.
  * @return self
  */
 protected function prepareRequest($request, $method)
 {
     $templateVariables = new Collection();
     $query = new Query();
     $body = array();
     foreach ($method->getParameters() as $parameter) {
         switch ($parameter->getStyle()) {
             case 'template':
                 $templateVariables->set($parameter->getName(), $parameter->getValue());
                 break;
             case 'query':
                 $query->set($parameter->getName(), $parameter->getValue());
                 break;
             case 'header':
                 $request->getHeaders()->set($parameter->getName(), $parameter->getValue());
                 break;
             case 'body':
                 $body[$parameter->getName()] = $parameter->getValue();
                 break;
         }
     }
     $url = $method->getUrl();
     $template = new UriTemplate($url);
     $url = $template->create($templateVariables);
     $url = new Url($url);
     $url->setQuery($query);
     $request->setUrl($url);
     $request->setBody($body);
     return $this;
 }