go-rfc2616/method/bytes_tolerant.go

27 lines
390 B
Go
Raw Normal View History

2023-12-08 19:42:28 +00:00
package method
func BytesTolerant(p []byte) (result []byte, rest []byte, ok bool) {
if len(p) <= 0 {
return nil, nil, false
}
{
p0 := p[0]
if ' ' == p0 || '\t' == p0 || '\r' == p0 || '\n' == p0 {
return nil, p, false
}
}
{
for i,b := range p {
if ' ' == b || '\t' == b || '\r' == b || '\n' == b {
return p[:i], p[i:], true
}
}
return p, nil, true
}
}