use mime.ParseMediaType for Content-Type response parsing
This commit was moved from ipfs/go-ipfs-http-client@217d1945237321c12f96abef82707217a30813b0
Łukasz Magiera committed
Feb 19, 2019 at 22:33 UTC
db1af499c9d661a70ac6fcce9cc7347b934385e4
1 file changed
+7
-6
client/httpapi/response.go
+7
-6
@@ -4,14 +4,13 @@ import (
4
"encoding/json"
5
"errors"
6
"fmt"
7
+ "github.com/ipfs/go-ipfs-files"
8
"io"
9
"io/ioutil"
10
+ "mime"
11
"net/http"
12
"net/url"
13
"os"
12
- "strings"
13
-
14
- files "github.com/ipfs/go-ipfs-files"
14
)
15
16
type trailerReader struct {
@@ -116,9 +115,11 @@ func (r *Request) Send(c *http.Client) (*Response, error) {
115
return nil, err
116
}
117
119
- contentType := resp.Header.Get("Content-Type")
120
- parts := strings.Split(contentType, ";")
121
- contentType = parts[0]
118
+
119
+ contentType, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type"))
120
+ if err != nil {
121
+ return nil, err
122
+ }
123
124
nresp := new(Response)
125