本文整理汇总了Golang中net/textproto.Reader.ReadMIMEHeader方法的典型用法代码示例。如果您正苦于以下问题:Golang Reader.ReadMIMEHeader方法的具体用法?Golang Reader.ReadMIMEHeader怎么用?Golang Reader.ReadMIMEHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net/textproto.Reader
的用法示例。
在下文中一共展示了Reader.ReadMIMEHeader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: parseHeaderStr
/**
The Email Header is expected to follow this spec:
Mail Header: Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: by domain.de (Postfix, from userid 0)
id 034C710090703; Sat, 16 Mar 2013 02:05:26 +0100 (CET)
To: [email protected], [email protected], [...]
Subject: Test Message
Message-Id: <[email protected]>
Date: Sat, _6 Mar 2013 02:05:26 +0100 (CET)
From: [email protected] (root)
which translates to a more generic form of:
Key : Blank Value \newline
*/
func parseHeaderStr(header string) (*Header, error) {
if 0 == len(header) {
return nil, errors.New("Header string is empty")
}
var (
reader *textproto.Reader = textproto.NewReader(bufio.NewReader(bytes.NewBufferString(header)))
mHeader textproto.MIMEHeader
err error
)
if mHeader, err = reader.ReadMIMEHeader(); err != nil && err != io.EOF {
return nil, err
}
// for key, val := range mHeader {
// fmt.Printf("&&&& %s -> %s\n", key, val)
// }
return parseMainHeaderContent(mHeader)
}