/**
  * Prepares the given HTTP-query-string for the HTTP-request.
  *
  * HTTP-query-strings always should be utf8-encoded and urlencoded afterwards.
  * So "/path/file?test=tatütata" will be converted to "/path/file?test=tat%C3%BCtata":
  *
  * @param stirng The quetry-string (like "/path/file?test=tatütata")
  * @return string
  */
 protected function prepareHTTPRequestQuery($query)
 {
     // If string already is URL-encoded -> do nothing
     if (PHPCrawlerUtils::isUrlEncodedString($query)) {
         return $query;
     }
     // if query is already utf-8 encoded -> simply urlencode it,
     // otherwise encode it to utf8 first.
     if (PHPCrawlerUtils::isUTF8String($query) == true) {
         $query = rawurlencode($query);
     } else {
         $query = rawurlencode(utf8_encode($query));
     }
     // Replace url-specific signs back
     $query = str_replace("%2F", "/", $query);
     $query = str_replace("%3F", "?", $query);
     $query = str_replace("%3D", "=", $query);
     $query = str_replace("%26", "&", $query);
     return $query;
 }