func (e *Entity) MultipartReader() MultipartReader {
	if !strings.HasPrefix(e.mediaType, "multipart/") {
		return nil
	}
	if mb, ok := e.Body.(*multipartBody); ok {
		return mb
	}
	return &multipartReader{textproto.NewMultipartReader(e.Body, e.mediaParams["boundary"])}
}
MultipartReader returns a MultipartReader that reads parts from this entity's
body. If this entity is not multipart, it returns nil.
package message
import (
	"bufio"
	"errors"
	"io"
	"math"
	"strings"
	"github.com/emersion/go-message/textproto"
)
type Entity struct {
	Header Header     
	Body   io.Reader  
	mediaType   string
	mediaParams map[string]string
}
func New(header Header, body io.Reader) (*Entity, error) {
	var err error
	mediaType, mediaParams, _ := header.ContentType()
	if !strings.HasPrefix(mediaType, "multipart/") {
		enc := header.Get("Content-Transfer-Encoding")
		if decoded, encErr := encodingReader(enc, body); encErr != nil {
			err = UnknownEncodingError{encErr}
		} else {
			body = decoded
		}
	}
	if strings.HasPrefix(mediaType, "text/") {
		if ch, ok := mediaParams["charset"]; ok {
			if converted, charsetErr := charsetReader(ch, body); charsetErr != nil {
				err = UnknownCharsetError{charsetErr}
			} else {
				body = converted
			}
		}
	}
	return &Entity{
		Header:      header,
		Body:        body,
		mediaType:   mediaType,
		mediaParams: mediaParams,
	}, err
}
func NewMultipart(header Header, parts []*Entity) (*Entity, error) {
	r := &multipartBody{
		header: header,
		parts:  parts,
	}
	return New(header, r)
}
const maxHeaderBytes = 1 << 20  
var errHeaderTooBig = errors.New("message: header exceeds maximum size")
type limitedReader struct {
	R io.Reader
	N int64
}
func (lr *limitedReader) Read(p []byte) (int, error) {
	if lr.N <= 0 {
		return 0, errHeaderTooBig
	}
	if int64(len(p)) > lr.N {
		p = p[0:lr.N]
	}
	n, err := lr.R.Read(p)
	lr.N -= int64(n)
	return n, err
}
func Read(r io.Reader) (*Entity, error) {
	lr := &limitedReader{R: r, N: maxHeaderBytes}
	br := bufio.NewReader(lr)
	h, err := textproto.ReadHeader(br)
	if err != nil {
		return nil, err
	}
	lr.N = math.MaxInt64
	return New(Header{h}, br)
}