示例#1
0
文件: Url.php 项目: 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, '/');
 }
示例#2
0
文件: UrlTest.php 项目: blar/http
 public function testOrigin()
 {
     $url = new Url('http://www.example.com/foo/bar?foo=23');
     $this->assertEquals('http://www.example.com', $url->getOrigin());
 }
示例#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;
 }