michael-o commented on a change in pull request #72:
URL: https://github.com/apache/maven-wagon/pull/72#discussion_r466554768
##########
File path:
wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.java
##########
@@ -169,6 +154,44 @@ private WagonHttpEntity( final InputStream stream, final
Resource resource, fina
this.wagon = wagon;
+ // if the autoset content flag is SET and the content type is blank
+ // then try to determine what the content type is and set it
+ if ( AUTOSET_CONTENT_TYPE && getContentType() == null )
+ {
+ try
+ {
+ autosetContentType();
+ }
+ catch ( IOException ioX )
+ {
+ if ( AUTOSET_CONTENT_TYPE_FATAL )
+ {
+ throw new TransferFailedException(
+ "Failed to determine content type, "
+ + " unset
'maven.wagon.http.autocontenttype.fatal' to allow continued processing",
+ ioX );
+ }
+ }
+ }
+ }
+
+ private void autosetContentType() throws IOException
+ {
+ // if the content-type has not been set then
+ // if the option flag is TRUE and the content type is determinable
from the file extension
+ // then set it from the file extension
+ final String mimeType = AUTOSET_CONTENT_TYPE
+ ? this.source != null
+ ? URLConnection.guessContentTypeFromName(
source.getName() )
+ : this.stream != null
+ ? URLConnection.guessContentTypeFromStream(
this.stream )
Review comment:
You cannot do this. This will consume a few magic bytes from the stream
making it useless. You can utilize this only with a pushback stream.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]