ncw / swift

Go language interface to Swift / Openstack Object Storage / Rackspace cloud files (golang)
MIT License
310 stars 107 forks source link

Bulk upload method returns err if content type exists charset #143

Open Halfi opened 5 years ago

Halfi commented 5 years ago

If server returns content type like this application/json; charset=utf-8, it brokens client. https://github.com/ncw/swift/blob/24e3012fc8a71f004a6455bce2088031d50bf2b6/swift.go#L1993

Please use strings.Contains instead equal.

    // Detect old servers which don't support this feature
    if !strings.Contains(headers["Content-Type"], "application/json") {
        err = Forbidden
        return
    }
ncw commented 5 years ago

Ah, well spotted!

Actually calling mime.ParseMediaType is the correct thing to do to parse it.

Fancy sending a PR to fix?

ncw commented 5 years ago

There is probably more than one place in the code which needs fixing...