/**
  * Send the HTTP request and return an HTTP response object
  *
  * @param string $method
  * @return tx_mklib_util_httprequest_Responce
  */
 public function request($method = NULL)
 {
     if (empty($this->uri)) {
         throw new Exception('No valid URI has been passed to the client');
     }
     if ($method) {
         $this->setMethod($method);
     }
     $response = NULL;
     // Make sure the adapter is loaded
     if (!$this->adapter instanceof tx_mklib_util_httprequest_adapter_Interface) {
         $this->setAdapter($this->config['adapter']);
     }
     // Clone the URI and add the additional GET parameters to it
     $uri = parse_url($this->uri);
     if (!empty($this->parameters) && $this->method == self::METHOD_GET) {
         $query = http_build_query($this->parameters, NULL, '&');
         if ($this->config['rfc3986_strict']) {
             $query = str_replace('+', '%20', $query);
         }
         $uri['query'] = empty($uri['query']) ? '' : $uri['query'] . '&';
         $uri['query'] .= $query;
     }
     $body = $this->prepareBody();
     $headers = $this->prepareHeaders();
     // Open the connection, send the request and read the response
     $this->adapter->connect($uri['host'], $uri['port'], $uri['scheme'] == 'https' ? true : false);
     tx_rnbase::load('tx_mklib_util_File');
     $this->adapter->write($this->method, tx_mklib_util_File::parseUrlFromParts($uri), $headers, $body);
     $response = $this->adapter->read();
     if (!$response) {
         throw new Exception('Unable to read response, or response is empty');
     }
     tx_rnbase::load('tx_mklib_util_httprequest_Responce');
     $response = tx_mklib_util_httprequest_Responce::fromString($response);
     // @TODO: redirect prüfen.
     //$response->isRedirect()
     return $response;
 }
 public function testParseUrlFromParts()
 {
     $url = 'https://*****:*****@jenkins.project.dmknet.de:80/jenkins?test=param#anchor';
     $parts = parse_url($url);
     $newUrl = tx_mklib_util_File::parseUrlFromParts($parts);
     $this->assertEquals($url, $newUrl);
     unset($parts['pass']);
     $url = 'https://kunde@jenkins.project.dmknet.de:80/jenkins?test=param#anchor';
     $newUrl = tx_mklib_util_File::parseUrlFromParts($parts);
     $this->assertEquals($url, $newUrl);
     unset($parts['user']);
     $url = 'https://jenkins.project.dmknet.de:80/jenkins?test=param#anchor';
     $newUrl = tx_mklib_util_File::parseUrlFromParts($parts);
     $this->assertEquals($url, $newUrl);
     unset($parts['port']);
     $url = 'https://jenkins.project.dmknet.de/jenkins?test=param#anchor';
     $newUrl = tx_mklib_util_File::parseUrlFromParts($parts);
     $this->assertEquals($url, $newUrl);
     unset($parts['query']);
     $url = 'https://jenkins.project.dmknet.de/jenkins#anchor';
     $newUrl = tx_mklib_util_File::parseUrlFromParts($parts);
     $this->assertEquals($url, $newUrl);
     unset($parts['fragment']);
     $url = 'https://jenkins.project.dmknet.de/jenkins';
     $newUrl = tx_mklib_util_File::parseUrlFromParts($parts);
     $this->assertEquals($url, $newUrl);
 }