@@ -57,24 +57,32 @@ const (
5757 defaultMaxMemFileSize = 32 * MB
5858)
5959
60+ // WithMaxParts sets the maximum number of parts to be parsed.
61+ // default: 10000
6062func WithMaxParts (maxParts uint ) ParserOption {
6163 return func (c * parserConfig ) {
6264 c .maxParts = maxParts
6365 }
6466}
6567
68+ // WithMaxHeaders sets the maximum number of headers to be parsed.
69+ // default: 10000
6670func WithMaxHeaders (maxHeaders uint ) ParserOption {
6771 return func (c * parserConfig ) {
6872 c .maxHeaders = maxHeaders
6973 }
7074}
7175
76+ // WithMaxMemSize sets the maximum memory size to be used for parsing.
77+ // default: 32MB
7278func WithMaxMemSize (maxMemSize DataSize ) ParserOption {
7379 return func (c * parserConfig ) {
7480 c .maxMemSize = maxMemSize
7581 }
7682}
7783
84+ // WithMaxMemFileSize sets the maximum memory size to be used for parsing a file.
85+ // default: 32MB
7886func WithMaxMemFileSize (maxMemFileSize DataSize ) ParserOption {
7987 return func (c * parserConfig ) {
8088 c .maxMemFileSize = maxMemFileSize
@@ -86,10 +94,12 @@ type Value struct {
8694 header Header
8795}
8896
97+ // Unwrap returns the content and header of the value.
8998func (v Value ) Unwrap () (string , Header ) {
9099 return string (v .content ), v .header
91100}
92101
102+ // UnwrapRaw returns the raw content and header of the value.
93103func (v Value ) UnwrapRaw () ([]byte , Header ) {
94104 return v .content , v .header
95105}
@@ -112,18 +122,26 @@ func newHeader(h textproto.MIMEHeader) Header {
112122 }
113123}
114124
125+ // Get returns the first value associated with the given key.
126+ // If there are no values associated with the key, Get returns "".
115127func (h Header ) Get (key string ) string {
116128 return h .header .Get (key )
117129}
118130
131+ // ContentType returns the value of the "Content-Type" header field.
132+ // If there are no values associated with the key, ContentType returns "".
119133func (h Header ) ContentType () string {
120134 return h .header .Get ("Content-Type" )
121135}
122136
137+ // Name returns the value of the "name" parameter in the "Content-Disposition" header field.
138+ // If there are no values associated with the key, Name returns "".
123139func (h Header ) Name () string {
124140 return h .dispositionParams ["name" ]
125141}
126142
143+ // FileName returns the value of the "filename" parameter in the "Content-Disposition" header field.
144+ // If there are no values associated with the key, FileName returns "".
127145func (h Header ) FileName () string {
128146 return h .dispositionParams ["filename" ]
129147}
0 commit comments