mirror of
https://github.com/valyala/fasthttp.git
synced 2026-06-14 15:56:44 +03:00
improve invalidStatusLine by appending a []byte directly (#1086)
* improve invalidStatusLine * append []byte directly * AppendUint * negetive * AppendInt
This commit is contained in:
@@ -4,3 +4,4 @@ tags
|
||||
*.fasthttp.br
|
||||
.idea
|
||||
.DS_Store
|
||||
vendor/
|
||||
|
||||
@@ -2,6 +2,7 @@ package fasthttp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -181,5 +182,12 @@ func statusLine(statusCode int) []byte {
|
||||
|
||||
func invalidStatusLine(statusCode int) []byte {
|
||||
statusText := StatusMessage(statusCode)
|
||||
return []byte(fmt.Sprintf("HTTP/1.1 %d %s\r\n", statusCode, statusText))
|
||||
// xxx placeholder of status code
|
||||
var line = make([]byte, 0, len("HTTP/1.1 xxx \r\n")+len(statusText))
|
||||
line = append(line, []byte("HTTP/1.1 ")...)
|
||||
line = strconv.AppendInt(line, int64(statusCode), 10)
|
||||
line = append(line, []byte(" ")...)
|
||||
line = append(line, []byte(statusText)...)
|
||||
line = append(line, []byte("\r\n")...)
|
||||
return line
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user