swift icon indicating copy to clipboard operation
swift copied to clipboard

Bulk upload method returns err if content type exists charset

Open Halfi opened this issue 5 years ago • 2 comments

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
	}

Halfi avatar Apr 03 '19 19:04 Halfi

Ah, well spotted!

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

Fancy sending a PR to fix?

ncw avatar Apr 04 '19 17:04 ncw

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

ncw avatar Apr 04 '19 17:04 ncw