related

package
v0.0.0-...-01d28b2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2017 License: BSD-3-Clause Imports: 10 Imported by: 4

Documentation

Index

Constants

View Source
const DefaultMediaType = "text/plain; charset=utf-8"

DefaultMediaType

Variables

View Source
var (
	ErrTypeMatch  = errors.New("root's media type doesn't match")
	ErrRootExists = errors.New("root part already exists")
)

Errors introduced by the multipart/related.

View Source
var (
	ErrDupRoot = errors.New("Detect duplicate roots")
)

Functions

This section is empty.

Types

type Object

type Object struct {
	Values []*ObjectHeader
}

A Object is parsed multipart/related compound object.

type ObjectHeader

type ObjectHeader struct {
	// contains filtered or unexported fields
}

A ObjectHeader describes a component of the aggregate whole of a multipart/related request.

func (*ObjectHeader) Read

func (oh *ObjectHeader) Read(b []byte) (n int, err error)

Read reads the content of a ObjectHeader.

type Part

type Part struct {
	Header textproto.MIMEHeader
	Root   bool
	// contains filtered or unexported fields
}

A Part represents a single part in a multipart/related body

func (*Part) Read

func (p *Part) Read(d []byte) (n int, err error)

Read reads the body of a part, after its headers and before the next part (if any) begins. It's a wrapper around multipart's Part.Read()

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader is an iterator over parts in a MIME multipart/related body.

func NewReader

func NewReader(
	r io.Reader,
	params map[string]string,
) *Reader

NewReader returns a new multipart/related Reader reading from r using the given MIME boundary. It's a wrapper around multipart's Reader

func (*Reader) NextPart

func (r *Reader) NextPart() (*Part, error)

NextPart returns the next part in the multipart/related or and error. When there are no more parts, the error io.EOF is returned.

func (*Reader) ReadObject

func (r *Reader) ReadObject() (*Object, error)

ReadObject parses an entire multipart/related message.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

A Writer generates multipart/related messages. See http://tools.ietf.org/html/rfc2387

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter returns a new multipart/related Writer with a random boundary, writing to w. It's a wrapper around multipart's Writer

func (*Writer) Boundary

func (w *Writer) Boundary() string

Boundary is a wrapper around multipart's Writer.Boundary

func (*Writer) Close

func (w *Writer) Close() error

Close is a wrapper around multipart's Writer.Close with additional errors.

func (*Writer) CreatePart

func (w *Writer) CreatePart(
	contentId string,
	header textproto.MIMEHeader,
) (io.Writer, error)

CreatePart is a wrapper around mulipart's Writer.CreatePart

func (*Writer) CreateRoot

func (w *Writer) CreateRoot(
	contentId string,
	mediaType string,
	header textproto.MIMEHeader,
) (io.Writer, error)

CreateRoot creates a new multipart/related root section with the provided contentId, mediaType and header. The body of the root should be written to the returned Writer.

header is used for adding additional information (e.g. Content- Transfer-Encoding), If Content-Id or Content-Type is specified in header, they will be overridden. If header is nil, creates a empty MIMEHeader.

func (*Writer) FormDataContentType

func (w *Writer) FormDataContentType() string

FormDataContentType returns the Content-Type for a multipart/related with this Writer's Boundary, Start, Type and StartInfo.

func (*Writer) SetBoundary

func (w *Writer) SetBoundary(boundary string) error

SetBoundary is a wrapper around multipart's Writer.SetBoundary

SetBoundary overrides the Writer's default randomly-generated boundary separator with an explicit value.

SetBoundary must be called before any parts are created, may only contain certain ASCII characters, and must be 1-69 bytes long.

func (*Writer) SetStart

func (w *Writer) SetStart(contentId string) error

SetStart changes the compound object's "root"

func (*Writer) SetStartInfo

func (w *Writer) SetStartInfo(info string)

SetStartInfo changes startInfo of the compound object

func (*Writer) SetType

func (w *Writer) SetType(mediaType string) error

SetType changes MIME mediaType of the compound object

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL