Closed wferem1 closed 3 years ago
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
:memo: Please visit https://cla.developers.google.com/ to sign.
Once you've signed (or fixed any issues), please reply here with @googlebot I signed it!
and we'll verify it.
ℹ️ Googlers: Go here for more info.
@googlebot I signed it!
@kevmoo since the other PR dart-lang/http_parser#48 is not working, i created a new
We'll need tests here, too. CC @natebosch – I'm really not working
I'm not sure if it makes sense to set a default in this library since it will be a behavior difference against the HTTP parsing that happens in the SDK. We're also looking at whether it makes sense to default to UTF8 decoding in packge:http
when reading response.body
as a string: https://github.com/dart-lang/http/issues/175
cc @lrhn - do you have any thoughts on the right place for this type of defaulting?
I added a test for the default charset. I understand that this may not seem the right place to do this defaulting, so you may close this PR if it is done in the http package.
I don't think this is where I'd insert a default (if anywhere). Modifying the source data early in the process prevents later code from recognizing that there originally was no charset
and do something customized in that case.
I'd rather do something at the point where the charset
is consumed. That is, if we try to get an encoding for the body, and the media type has no charset
parameter, then I'd see if there is a default encoding for that particular media type.
If there isn't, I'm inclined to actually refuse to decode without an encoding being provided by the user, rather than defaulting to something (especially if that something is Latin-1, because that encoding is irrefutable, and will accept any incoming bytes whether intended as Latin-1 or not).
@lrhn I agree with that reasoning, I will close this PR, since this is already being discussed in dart-lang/http#175
PR for dart-lang/http#1331