Scala: parse MIME/multipart raw emails over HTTP one at a time -
i'm trying parse raw email messages on http 1 @ time come in mime/multipart. here chunk of 1 of mails, mail code threw exception on
java.nio.charset.malformedinputexception: input length = 1
and here (i think) relevant chunk of mail:
content-type: multipart/alternative; boundary="------------000401070001090809020709" --------------000401070001090809020709 content-type: text/plain; charset=windows-1252; format=flowed content-transfer-encoding: 8bit
is there scala library out there handling type of input? otherwise there easy way write code handles it?
i've been looking @ mime4j , scala code in particular.
as of now, code uses scala.io.source.fromurl scrape raw mail follows:
scrape(scala.io.source.fromurl(url))
which turns bufferedsource string , splits it:
source.mkstring.split("\n\n", 2)
i've tried using implicit codec since scala.io.source.fromurl can take codec:
implicit val codec = codec("utf-8") codec.onmalformedinput(codingerroraction.replace) codec.onunmappablecharacter(codingerroraction.replace)
but think i'd need 1 of these each charset?
any appreciated.
Comments
Post a Comment