-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add content type library #124
Conversation
lib/src/content_type.dart
Outdated
/// | ||
/// Returns [fallback] if [charset] is null or if no [Encoding] was found that | ||
/// corresponds to [charset]. | ||
Encoding encodingForCharset(String charset, [Encoding fallback = LATIN1]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we have ??
, it's probably simpler to just return null
if the encoding isn't found rather than having fallback
parameters.
lib/src/content_type.dart
Outdated
} | ||
|
||
/// Modifies the media [type]'s [encoding]. | ||
MediaType modifyEncoding(MediaType type, Encoding encoding) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be used anywhere, and I'm not sure it would be worth factoring out even if it were...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to use it when creating the content-type
header from a body and also its in the multipart stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just doesn't seem like it provides substantial value over just inlining the definition.
lib/src/message.dart
Outdated
return _contentLengthCache; | ||
var contentLengthHeader = getHeader(headers, 'content-length'); | ||
if (contentLengthHeader == null) return null; | ||
return _contentLengthCache = int.parse(contentLengthHeader); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally avoid using the return value of assignment expressions.
Consolidate content-type related code into a single library and start using it within
Message
.