@@ 561,11 561,16 @@ concatUnlessBig siz builder stream
_ -> return $ Just $
LZ.toStrict $ BS.toLazyByteString builder
-getHttpContentType :: HTTP.Response -> MIME.ContentType
-getHttpContentType response =
- fromMaybe MIME.contentTypeApplicationOctetStream $
- (hush . Atto.parseOnly MIME.parseContentType =<<) $
- HTTP.getHeader response (s"content-type")
+getHttpContentType :: Text -> HTTP.Response -> MIME.ContentType
+getHttpContentType url response
+ | ext == s"xdc" =
+ MIME.ContentType (s"application") (s"webxdc+zip") mempty
+ | otherwise =
+ fromMaybe MIME.contentTypeApplicationOctetStream $
+ (hush . Atto.parseOnly MIME.parseContentType =<<) $
+ HTTP.getHeader response (s"content-type")
+ where
+ ext = T.takeWhileEnd (/='.') url
messageToAttachments :: (UIO.Unexceptional m) =>
XMPP.Message
@@ 583,7 588,7 @@ messageToAttachments message = catMaybes <$>
return Nothing
else
(fmap . fmap) (Attachment
- (getHttpContentType response)
+ (getHttpContentType url response)
(T.takeWhileEnd (/='/') url))
(concatUnlessBig 0 mempty stream)
)