diff options
author | tyltr <31768692+tylitianrui@users.noreply.github.com> | 2021-09-02 01:27:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-01 19:27:14 +0200 |
commit | d9c75732a6b97ebcf32e964a664d97a694cb32dd (patch) | |
tree | d973fc5f896f64c91076969bba61cff0e0c374bf /status.go | |
parent | Remove the redundant badage (#1085) (diff) | |
download | fasthttp-d9c75732a6b97ebcf32e964a664d97a694cb32dd.tar.gz fasthttp-d9c75732a6b97ebcf32e964a664d97a694cb32dd.tar.bz2 fasthttp-d9c75732a6b97ebcf32e964a664d97a694cb32dd.zip |
improve invalidStatusLine by appending a `[]byte` directly (#1086)
* improve invalidStatusLine
* append []byte directly
* AppendUint
* negetive
* AppendInt
Diffstat (limited to 'status.go')
-rw-r--r-- | status.go | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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 } |