dns: marshal to io.writer instead of byte slice

This commit is contained in:
nadoo committed 2020-04-20 12:41:53 +08:00
1 parent a0542a028e
commit 149824cc20
5 files changed
+55 -67

No files matched your search

+6 -3
View File
@@ -120,8 +120,12 @@ func (s *HTTP) servHTTP(req *request, c *conn.Conn) {
}
defer rc.Close()
buf := pool.GetWriteBuffer()
defer pool.PutWriteBuffer(buf)
// send request to remote server
_, err = rc.Write(req.Marshal())
req.WriteBuf(buf)
_, err = rc.Write(buf.Bytes())
if err != nil {
return
}
@@ -159,13 +163,12 @@ func (s *HTTP) servHTTP(req *request, c *conn.Conn) {
header.Set("Proxy-Connection", "close")
header.Set("Connection", "close")
buf := pool.GetWriteBuffer()
buf.Reset()
writeStartLine(buf, proto, code, status)
writeHeaders(buf, header)
log.F("[http] %s <-> %s", c.RemoteAddr(), req.target)
c.Write(buf.Bytes())
pool.PutWriteBuffer(buf)
b := pool.GetBuffer(conn.TCPBufSize)
io.CopyBuffer(c, r, b)