Skip to content
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

NamedDataSource should implement EncodingAware #131

Closed
ben-manes opened this issue Mar 1, 2018 · 3 comments
Closed

NamedDataSource should implement EncodingAware #131

ben-manes opened this issue Mar 1, 2018 · 3 comments

Comments

@ben-manes
Copy link

When attaching a file, the content-type is inferred by MimeBodyPart by reading from the input stream. This occurs twice per attachment before the data is written out, resulting in 3 http calls. If the DataSource implements javax.mail.EncodingAware then this used if the result is non-null. When the file type is known, such as a pdf, this should avoid the extra hops. Unfortunately the given DataSource is decorated by NamedDataSource, so this optimization is not possible.

@bbottema
Copy link
Owner

bbottema commented Mar 3, 2018

What about this?

class NamedDataSource implements DataSource, EncodingAware {
	
	(..)
	
	@Override
	public String getEncoding() {
		return (this.dataSource instanceof EncodingAware) ? ((EncodingAware) this.dataSource).getEncoding() : null;
	}
}

@ben-manes
Copy link
Author

Yep, that is what I envisioned.

@bbottema
Copy link
Owner

bbottema commented Apr 7, 2018

Released in 5.0.2.

@bbottema bbottema added this to the 5.0.2 milestone Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants