public static function newFromHeaders($name, $headers, $token, $url, $cdnUrl = NULL, $cdnSslUrl = NULL) {
    $object = new RemoteObject($name);

    //$object->allHeaders = $headers;
    $object->setHeaders($headers);

    //throw new \Exception(print_r($headers, TRUE));

    // Fix inconsistant header.
    if (isset($headers['ETag'])) {
      $headers['Etag'] = $headers['ETag'];
    }

    $object->setContentType($headers['Content-Type']);
    $object->contentLength = empty($headers['Content-Length']) ? 0 : (int) $headers['Content-Length'];
    $object->etag = (string) $headers['Etag']; // ETag is now Etag.
    $object->lastModified = strtotime($headers['Last-Modified']);

    // Set the metadata, too.
    $object->setMetadata(Container::extractHeaderAttributes($headers));


    // If content encoding and disposition exist, set them on the
    // object.
    if (!empty($headers['Content-Disposition'])) {
      $object->setDisposition($headers['Content-Disposition']);

    }
    if (!empty($headers['Content-Encoding'])) {
      $object->setEncoding($headers['Content-Encoding']);
    }

    $object->token = $token;
    $object->url = $url;
    $object->cdnUrl = $cdnUrl;
    $object->cdnSslUrl = $cdnSslUrl;

    return $object;
  }