Documentation and better naming

This commit is contained in:
Roberto Abdelkader Martínez Pérez
2019-10-03 14:17:24 +02:00
parent 681ee3cba8
commit 80eea3c886
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -5,6 +5,7 @@ import (
"strings" "strings"
) )
// GetReason returns the reason phrase part of an HTTP response
func GetReason(r *http.Response) string { func GetReason(r *http.Response) string {
if i := strings.IndexByte(r.Status, ' '); i != -1 { if i := strings.IndexByte(r.Status, ' '); i != -1 {
return r.Status[i+1:] return r.Status[i+1:]
+1 -1
View File
@@ -40,7 +40,7 @@ func TestReasonOfMultipleWords(t *testing.T) {
} }
} }
func TestOddSizeStatusCode(t *testing.T) { func TestBehaveWithOddSizeStatusCode(t *testing.T) {
r := &nethttp.Response{Status: "2 FOO BAR BAZ"} r := &nethttp.Response{Status: "2 FOO BAR BAZ"}
if GetReason(r) != "FOO BAR BAZ" { if GetReason(r) != "FOO BAR BAZ" {
t.Errorf("Unexpected reason found") t.Errorf("Unexpected reason found")