Closed CGsama closed 4 months ago
Hi @CGsama it's unlikely we will start supporting this, as you've correctly spotted the issue is that the server (Less3) is sending this header: Accept-Charset: ISO-8859-1, utf-8
.
Go's stdlib by default only accepts utf8.
// CharsetReader, if non-nil, defines a function to generate
// charset-conversion readers, converting from the provided
// non-UTF-8 charset into UTF-8. If CharsetReader is nil or
// returns an error, parsing stops with an error. One of the
// CharsetReader's result values must be non-nil.
CharsetReader func(charset string, input io.Reader) (io.Reader, error)
You've already opened an issue with Less3: https://github.com/jchristn/Less3/issues/9
They just need to remove this header from the response, Amazon S3 does not send this header. We are compatible with S3, if they also want to be compatible then they must use the same responses as S3 has.
Or maybe the header is being set by your nginx server configuration? Server: nginx/1.18.0 (Ubuntu)
Another thing to get them to look at is the XML response, it should be <?xml version="1.0" encoding="UTF-8"?>
Hi @CGsama it's unlikely we will start supporting this, as you've correctly spotted the issue is that the server (Less3) is sending this header:
Accept-Charset: ISO-8859-1, utf-8
.Go's stdlib by default only accepts utf8.
// CharsetReader, if non-nil, defines a function to generate // charset-conversion readers, converting from the provided // non-UTF-8 charset into UTF-8. If CharsetReader is nil or // returns an error, parsing stops with an error. One of the // CharsetReader's result values must be non-nil. CharsetReader func(charset string, input io.Reader) (io.Reader, error)
You've already opened an issue with Less3: jchristn/Less3#9
They just need to remove this header from the response, Amazon S3 does not send this header. We are compatible with S3, if they also want to be compatible then they must use the same responses as S3 has.
Hi Mark, thank you very much for the advice! I tries nginx to remove the header but not work, after wireshark I have success locate the issue is the REST response at https://github.com/jchristn/S3Server/blob/253c325de052eaa3ef6d5c97783e0a604860cb80/src/S3Server/SerializationHelper.cs#L174 So that it force ISO-8859-1 in XML encoding field. Change it to UTF8 solved it!
Pretty much all xml decoding would have to be rewritten in minio-go to something like:
d := xml.NewDecoder(resp.Body)
d.CharsetReader = func(cs string, input io.Reader) (io.Reader, error) {
enc, _ := charset.Lookup(cs)
if enc == nil {
return nil, fmt.Errorf("unsupported charset: %q", cs)
}
return enc.NewDecoder().Reader(input), nil
}
Given this isn't a more prevalent issue, I don't see a big need for this currently.
Expected behavior
Able to do s3 compatible operations on Less3, which successfully by awscli and s3 browser
Actual behavior
All operations will throw the same error
seems similar to this case https://stackoverflow.com/questions/6002619/unmarshal-an-iso-8859-1-xml-input-in-go
Steps to reproduce the behavior
install Less3 add to alias do any operation
mc --version
System information