Exemplo n.º 1
0
 /**
  * @param UriInterface $uri
  *
  * @return Content
  * @throws LoadException
  */
 public function load(UriInterface $uri)
 {
     if (!$uri instanceof HttpUriInterface) {
         throw new InvalidUriTypeException($uri, 'Eloquent\\Schemer\\Uri\\HttpUriInterface');
     }
     if (!$uri->isAbsolute()) {
         throw new RelativeUriException($uri);
     }
     $response = $this->browser()->get($uri->toString());
     if (!$response->isSuccessful()) {
         throw new LoadException($uri);
     }
     $mimeType = $this->mimeTypeByResponse($response);
     if (null === $mimeType) {
         $mimeType = $this->extensionMap()->getByPath($this->pathFromUri($uri));
     }
     return new Content($response->getContent(), $mimeType);
 }