Skip to content
Draft
16 changes: 16 additions & 0 deletions wagon-providers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,20 @@ under the License.
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>jdk11</id>
<activation>
<jdk>[1.11,)</jdk>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really 1.11? If yes, then this is a bug in Maven.

</activation>
<dependencies>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
import org.apache.maven.wagon.resource.Resource;
import org.codehaus.plexus.util.StringUtils;

import javax.activation.MimetypesFileTypeMap;
Comment thread
chrisbeckey marked this conversation as resolved.
Outdated
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import java.io.Closeable;
Expand Down Expand Up @@ -119,6 +120,8 @@
public abstract class AbstractHttpClientWagon
extends StreamWagon
{
private static final MimetypesFileTypeMap FILE_TYPE_MAP = new MimetypesFileTypeMap();

final class WagonHttpEntity
extends AbstractHttpEntity
{
Expand All @@ -142,6 +145,19 @@ private WagonHttpEntity( final InputStream stream, final Resource resource, fina
{
this.source = source;
this.repeatable = true;
// 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
if ( getContentType() == null )
{
final String mimeType = SET_CONTENT_TYPE_FROM_FILE_EXTENSION
? FILE_TYPE_MAP.getContentType( source )
: null;
if ( mimeType != null && !mimeType.isEmpty() )
{
setContentType( mimeType );
}
}
}
else
{
Expand All @@ -152,6 +168,7 @@ private WagonHttpEntity( final InputStream stream, final Resource resource, fina
this.length = resource == null ? -1 : resource.getContentLength();

this.wagon = wagon;

}

public Resource getResource()
Expand Down Expand Up @@ -279,6 +296,13 @@ public boolean isStreaming()
private static final boolean SSL_ALLOW_ALL =
Boolean.valueOf( System.getProperty( "maven.wagon.http.ssl.allowall", "false" ) );

/**
* If enabled, then the content-type HTTP header will be set using the file extension to determine the type,
* <b>disabled by default</b>
* This flag is only effective when uploading from a File, not directly from a Stream.
*/
private static final boolean SET_CONTENT_TYPE_FROM_FILE_EXTENSION =
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether this should be a per-server config rather than global. In general, sys props are either globally or for a technical reason. WDYT?

Boolean.valueOf( System.getProperty( "maven.wagon.http.file.autocontenttype", "false" ) );

/**
* Maximum concurrent connections per distinct route.
Expand Down