mirror of
https://github.com/golang/go
synced 2024-11-25 06:57:58 -07:00
net/http: use WriteString directly when possible
Several places used io.WriteString unnecessarily when the static type already implemented WriteString. No need to check for it at runtime. R=golang-dev, r CC=golang-dev https://golang.org/cl/9608043
This commit is contained in:
parent
fc3bec386e
commit
c6c439d7a0
@ -278,7 +278,7 @@ func (cw *chunkWriter) close() {
|
||||
// zero EOF chunk, trailer key/value pairs (currently
|
||||
// unsupported in Go's server), followed by a blank
|
||||
// line.
|
||||
io.WriteString(cw.res.conn.buf, "0\r\n\r\n")
|
||||
cw.res.conn.buf.WriteString("0\r\n\r\n")
|
||||
}
|
||||
}
|
||||
|
||||
@ -512,7 +512,7 @@ func (ecr *expectContinueReader) Read(p []byte) (n int, err error) {
|
||||
}
|
||||
if !ecr.resp.wroteContinue && !ecr.resp.conn.hijacked() {
|
||||
ecr.resp.wroteContinue = true
|
||||
io.WriteString(ecr.resp.conn.buf, "HTTP/1.1 100 Continue\r\n\r\n")
|
||||
ecr.resp.conn.buf.WriteString("HTTP/1.1 100 Continue\r\n\r\n")
|
||||
ecr.resp.conn.buf.Flush()
|
||||
}
|
||||
return ecr.readCloser.Read(p)
|
||||
@ -847,7 +847,7 @@ func (cw *chunkWriter) writeHeader(p []byte) {
|
||||
setHeader.connection = "close"
|
||||
}
|
||||
|
||||
io.WriteString(w.conn.buf, statusLine(w.req, code))
|
||||
w.conn.buf.WriteString(statusLine(w.req, code))
|
||||
cw.header.WriteSubset(w.conn.buf, excludeHeader)
|
||||
setHeader.Write(w.conn.buf.Writer)
|
||||
w.conn.buf.Write(crlf)
|
||||
|
Loading…
Reference in New Issue
Block a user