go-rfc2616/requesturi/bytes_tolerant.go

31 lines
445 B
Go
Raw Normal View History

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