Exemple #1
0
 private function addContentType(puzzle_message_RequestInterface $request, puzzle_stream_StreamInterface $body)
 {
     if (!$body instanceof puzzle_stream_MetadataStreamInterface) {
         return;
     }
     if (!($uri = $body->getMetadata('uri'))) {
         return;
     }
     // Guess the content-type based on the stream's "uri" metadata value.
     // The file extension is used to determine the appropriate mime-type.
     if ($contentType = puzzle_Mimetypes::getInstance()->fromFilename($uri)) {
         $request->setHeader('Content-Type', $contentType);
     }
 }