ncw / swift

Go language interface to Swift / Openstack Object Storage / Rackspace cloud files (golang)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bulk upload method returns err if content type exists charset

Halfi opened this issue · comments

If server returns content type like this application/json; charset=utf-8, it brokens client.

swift/swift.go

Line 1993 in 24e3012

if headers["Content-Type"] != "application/json" {

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
	}

Ah, well spotted!

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

Fancy sending a PR to fix?

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