/**
  * Create a request string (header and body)
  *
  * @param ConnectionOptions $options - connection options
  * @param string            $method  - HTTP method
  * @param string            $url     - HTTP URL
  * @param string            $body    - optional body to post
  * @param array             $customHeader - any arry containing header elements
  *
  * @return string - assembled HTTP request string
  */
 public static function buildRequest(ConnectionOptions $options, $method, $url, $body, $customHeader = array())
 {
     $host = $contentType = $authorization = $connection = '';
     $length = strlen($body);
     $endpoint = $options[ConnectionOptions::OPTION_ENDPOINT];
     if (Endpoint::getType($endpoint) !== Endpoint::TYPE_UNIX) {
         $host = sprintf('Host: %s%s', Endpoint::getHost($endpoint), self::EOL);
     }
     if ($options[ConnectionOptions::OPTION_BATCH] === true) {
         $contentType = 'Content-Type: multipart/form-data; boundary=' . self::MIME_BOUNDARY . self::EOL;
     } else {
         if ($length > 0 && $options[ConnectionOptions::OPTION_BATCHPART] === false) {
             // if body is set, we should set a content-type header
             $contentType = 'Content-Type: application/json' . self::EOL;
         }
     }
     if (isset($options[ConnectionOptions::OPTION_AUTH_TYPE]) && isset($options[ConnectionOptions::OPTION_AUTH_USER])) {
         // add authorization header
         $authorizationValue = base64_encode($options[ConnectionOptions::OPTION_AUTH_USER] . ':' . $options[ConnectionOptions::OPTION_AUTH_PASSWD]);
         $authorization = sprintf('Authorization: %s %s%s', $options[ConnectionOptions::OPTION_AUTH_TYPE], $authorizationValue, self::EOL);
     }
     if (isset($options[ConnectionOptions::OPTION_CONNECTION])) {
         // add connection header
         $connection = sprintf("Connection: %s%s", $options[ConnectionOptions::OPTION_CONNECTION], self::EOL);
     }
     $apiVersion = 'X-Arango-Version: ' . Connection::$_apiVersion . self::EOL;
     $customHeaders = "";
     foreach ($customHeader as $headerKey => $headerValue) {
         $customHeaders .= $headerKey . ": " . $headerValue . self::EOL;
     }
     // finally assemble the request
     $request = sprintf('%s %s %s%s', $method, $url, self::PROTOCOL, self::EOL) . $host . $apiVersion . $customHeaders . $contentType . $authorization . $connection . sprintf('Content-Length: %s%s%s', $length, self::EOL, self::EOL) . $body;
     return $request;
 }