Skip to content
This repository was archived by the owner on Mar 12, 2024. It is now read-only.

Commit fa3108f

Browse files
committed
Merge branch 'master' of github.com:qiniu/httptest
2 parents fd26aa7 + 39de73a commit fa3108f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

response.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"io"
88
"io/ioutil"
9+
"mime"
910
"net/http"
1011
"reflect"
1112
"strings"
@@ -88,7 +89,12 @@ func newResponse(req *Request, resp *http.Response, err error) (p *Response) {
8889
}
8990
p.BodyType = p.Header.Get("Content-Type")
9091
if len(p.RawBody) > 0 {
91-
switch p.BodyType {
92+
bodyType, _, err := mime.ParseMediaType(p.BodyType)
93+
if err != nil {
94+
p.ctx.Fatal("unmarshal response body failed:", err)
95+
}
96+
97+
switch bodyType {
9298
case "application/json":
9399
p.Err = json.Unmarshal(p.RawBody, &p.BodyObj)
94100
if p.Err != nil {

0 commit comments

Comments
 (0)