本文整理匯總了Golang中net/textproto.Conn.EndRequest方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conn.EndRequest方法的具體用法?Golang Conn.EndRequest怎麽用?Golang Conn.EndRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net/textproto.Conn
的用法示例。
在下文中一共展示了Conn.EndRequest方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: handleConnection
func (s *server) handleConnection(p *textproto.Conn) {
id := p.Next()
p.StartRequest(id)
p.EndRequest(id)
p.StartResponse(id)
p.PrintfLine("OK MPD gompd0.1")
p.EndResponse(id)
endIdle := make(chan bool)
inIdle := false
defer p.Close()
for {
id := p.Next()
p.StartRequest(id)
req, err := s.readRequest(p)
if err != nil {
return
}
// We need to do this inside request because idle response
// may not have ended yet, but it will end after the following.
if inIdle {
endIdle <- true
}
p.EndRequest(id)
if req.typ == idle {
inIdle = true
go s.writeIdleResponse(p, id, endIdle, req.args[1:])
// writeIdleResponse does it's own StartResponse/EndResponse
continue
}
p.StartResponse(id)
if inIdle {
inIdle = false
}
switch req.typ {
case noIdle:
case commandListOk:
var ok, closed bool
ok = true
for _, args := range req.cmdList {
ok, closed = s.writeResponse(p, args, "list_OK")
if closed {
return
}
if !ok {
break
}
}
if ok {
p.PrintfLine("OK")
}
case simple:
if _, closed := s.writeResponse(p, req.args, "OK"); closed {
return
}
}
p.EndResponse(id)
}
}