go-rfc2616/version/bytes_tolerant.go

31 lines
439 B
Go
Raw Permalink Normal View History

2023-12-09 11:58:21 +00:00
package version
import (
"sourcecode.social/reiver/go-rfc2616/sp"
)
func BytesTolerant(p []byte) (result []byte, rest []byte, ok bool) {
if len(p) <= 0 {
return nil, nil, true
}
{
p0 := p[0]
if sp.ByteIsTolerant(p0) || '\r' == p0 || '\n' == p0{
return nil, p, true
}
}
{
for i,b := range p {
if sp.ByteIsTolerant(b) || '\r' == b || '\n' == b {
return p[:i], p[i:], true
}
}
return p, nil, true
}
}