funchasToken(v, token string)bool { iflen(token) > len(v) || token == "" { returnfalse } if v == token { returntrue } for sp := 0; sp <= len(v)-len(token); sp++ { // Check that first character is good. // The token is ASCII, so checking only a single byte // is sufficient. We skip this potential starting // position if both the first byte and its potential // ASCII uppercase equivalent (b|0x20) don't match. // False positives ('^' => '~') are caught by EqualFold. if b := v[sp]; b != token[0] && b|0x20 != token[0] { continue } // Check that start pos is on a valid token boundary. if sp > 0 && !isTokenBoundary(v[sp-1]) { continue } // Check that end pos is on a valid token boundary. if endPos := sp + len(token); endPos != len(v) && !isTokenBoundary(v[endPos]) { continue } if strings.EqualFold(v[sp:sp+len(token)], token) { returntrue } } returnfalse }
功能描述: 查看v字符串中是不是包含token.
2018/12/21
RTSP服务器:
参照http模块处理http请求的流程处理RTSP的处理
代码分析:
1 2 3 4 5
type onceCloseListener struct { net.Listener //隐式声明 once sync.Once closeErr error }