MCPcopy Create free account
hub / github.com/imroc/req / upcomingHeaderKeys

Method upcomingHeaderKeys

textproto_reader.go:332–354  ·  view source on GitHub ↗

upcomingHeaderKeys returns an approximation of the number of keys that will be in this header. If it gets confused, it returns 0.

()

Source from the content-addressed store, hash-verified

330// upcomingHeaderKeys returns an approximation of the number of keys
331// that will be in this header. If it gets confused, it returns 0.
332func (r *textprotoReader) upcomingHeaderKeys() (n int) {
333 // Try to determine the 'hint' size.
334 r.R.Peek(1) // force a buffer load if empty
335 s := r.R.Buffered()
336 if s == 0 {
337 return
338 }
339 peek, _ := r.R.Peek(s)
340 for len(peek) > 0 && n < 1000 {
341 var line []byte
342 line, peek, _ = bytes.Cut(peek, nl)
343 if len(line) == 0 || (len(line) == 1 && line[0] == '\r') {
344 // Blank line separating headers from the body.
345 break
346 }
347 if line[0] == ' ' || line[0] == '\t' {
348 // Folded continuation of the previous line.
349 continue
350 }
351 n++
352 }
353 return n
354}
355
356const toLower = 'a' - 'A'
357

Callers 1

readMIMEHeaderMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected