Browse files

[enhance] mime: get_text now requires a decoding function

  • Loading branch information...
1 parent 2787583 commit 9bd658c143ea93e963f2c3ac6a33af8f3e8e4e29 @Aqua-Ye Aqua-Ye committed Apr 26, 2012
Showing with 9 additions and 8 deletions.
  1. +9 −8 stdlib/web/mail/mime.opa
View
17 stdlib/web/mail/mime.opa
@@ -353,24 +353,25 @@ Mime = {{
// Text
@private
- body_to_string(body:Mime.body_part) : string =
+ body_to_string(body:Mime.body_part, decoder) : string =
match body
- {~plain} -> plain.f2
+ {~plain} -> decoder(plain.f1, plain.f2)
{html=_} -> ""
{attachment=_} -> ""
{multipart=parts} ->
- List.map(get_text_aux, parts)
- |> List.to_string_using("", "", "", _)
+ List.fold(part, acc ->
+ acc + get_text_aux(part, decoder)
+ , parts, "")
@private
- get_text_aux(entity:Mime.entity) =
- body_to_string(entity.body)
+ get_text_aux(entity:Mime.entity, decoder) =
+ body_to_string(entity.body, decoder)
/**
* Get the textual content of a MIME message
*/
- get_text(message:Mime.message) =
- get_text_aux(message.content)
+ get_text(message:Mime.message, decoder:(string, binary -> string)) : string =
+ get_text_aux(message.content, decoder)
// HTML

0 comments on commit 9bd658c

Please sign in to comment.