Skip to content

Commit acfbad6

Browse files
committed
Use Go's http.StatusText for HTTP status messages
Also remove `status.go`, which contained all the status messages copied from the Go http package.
1 parent 933ddbb commit acfbad6

File tree

3 files changed

+3
-57
lines changed

3 files changed

+3
-57
lines changed

scgi.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (conn *scgiConn) WriteHeader(status int) {
4343
conn.wroteHeaders = true
4444

4545
var buf bytes.Buffer
46-
text := statusText[status]
46+
text := http.StatusText(status)
4747

4848
fmt.Fprintf(&buf, "HTTP/1.1 %d %s\r\n", status, text)
4949

status.go

Lines changed: 0 additions & 54 deletions
This file was deleted.

web_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func init() {
138138

139139
Get("/error/code/(.*)", func(ctx *Context, code string) string {
140140
n, _ := strconv.Atoi(code)
141-
message := statusText[n]
141+
message := http.StatusText(n)
142142
ctx.Abort(n, message)
143143
return ""
144144
})
@@ -237,7 +237,7 @@ var tests = []Test{
237237
{"GET", "/error/notfound/notfound", nil, "", 404, "notfound"},
238238
{"GET", "/doesnotexist", nil, "", 404, "Page not found"},
239239
{"POST", "/doesnotexist", nil, "", 404, "Page not found"},
240-
{"GET", "/error/code/500", nil, "", 500, statusText[500]},
240+
{"GET", "/error/code/500", nil, "", 500, http.StatusText(500)},
241241
{"POST", "/posterror/code/410/failedrequest", nil, "", 410, "failedrequest"},
242242
{"GET", "/getparam?a=abcd", nil, "", 200, "abcd"},
243243
{"GET", "/getparam?b=abcd", nil, "", 200, ""},

0 commit comments

Comments
 (0)