On Thu, 6 Apr 2017 14:50:43 +0300
Konstantin Khomoutov <flatw...@users.sourceforge.net> wrote:

> > I get string which contains:
[...]
> What you're dealing with is a typical set of headers of a so-called
> "MIME-formatted" e-mail message followed by its body.  The usual set
> of headers is missing (those 'From', 'To' etc) and that's why it looks
> strange.
> 
> So you parse it like a regular mail message using the net/mail package
> and then base64-decode its body.
[...]
> As shown, you can (should?) inspect the parsed headers to know which
> content type the decoded document really is (say, if in the future
> your source would sent Content-Type: text/json you'll be better
> prepared for this).
[...]

Also note that depending on your source it might indeed be possible to
get data with the value of the "Content-Type" header set to one
of "multipart" types [2] in which case the message's body will be text
delimited into a set of parts each of which will have its own set of
headers, including the Content-Type header.  Dealing with such payloads
is what mime/multipart is for.

I don't know your situation but I'd assert the headers you parse have
expected values (i.e. content type is "text/xml" or "application/xml"
etc, and the content transfer encoding is indeed base64).

2. https://en.wikipedia.org/wiki/MIME#Content-Type

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to