-
Notifications
You must be signed in to change notification settings - Fork 134
New transport: apache5x #742
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
base: master
Are you sure you want to change the base?
Changes from all commits
df9537d
aea837b
50fd65e
4b2b4de
c0c2506
563706f
db1a23d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.apache.maven.resolver</groupId> | ||
<artifactId>maven-resolver</artifactId> | ||
<version>2.0.10-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>maven-resolver-transport-apache5x</artifactId> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. apache-httpclient5 |
||
|
||
<name>Maven Artifact Resolver Transport Apache 5.x</name> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is a bad name. Apache is, unfortunately, used synonymously for Apache HTTPd. Use the full name. |
||
<description>A transport implementation for repositories using http:// and https:// URLs.</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.maven.resolver</groupId> | ||
<artifactId>maven-resolver-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven.resolver</groupId> | ||
<artifactId>maven-resolver-spi</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven.resolver</groupId> | ||
<artifactId>maven-resolver-util</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents.client5</groupId> | ||
<artifactId>httpclient5</artifactId> | ||
<version>5.5</version> | ||
<exclusions> | ||
<exclusion> | ||
<!-- httpclient uses old codec --> | ||
<groupId>commons-codec</groupId> | ||
<artifactId>commons-codec</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents.core5</groupId> | ||
<artifactId>httpcore5</artifactId> | ||
<version>5.3.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents.core5</groupId> | ||
<artifactId>httpcore5-h2</artifactId> | ||
<version>5.3.4</version> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a property |
||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.inject</groupId> | ||
<artifactId>javax.inject</artifactId> | ||
<scope>provided</scope> | ||
<optional>true</optional> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-simple</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven.resolver</groupId> | ||
<artifactId>maven-resolver-test-util</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.maven.resolver</groupId> | ||
<artifactId>maven-resolver-test-http</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.eclipse.sisu</groupId> | ||
<artifactId>sisu-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.eclipse.aether.transport.apache5x; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import org.apache.hc.client5.http.HttpResponseException; | ||
import org.apache.hc.core5.http.ClassicHttpResponse; | ||
import org.apache.hc.core5.http.Header; | ||
import org.apache.hc.core5.http.HttpHeaders; | ||
import org.apache.hc.core5.http.ParseException; | ||
import org.apache.hc.core5.http.io.entity.EntityUtils; | ||
import org.eclipse.aether.spi.connector.transport.http.RFC9457.RFC9457Reporter; | ||
|
||
public class ApacheRFC9457Reporter extends RFC9457Reporter<ClassicHttpResponse, HttpResponseException> { | ||
public static final ApacheRFC9457Reporter INSTANCE = new ApacheRFC9457Reporter(); | ||
|
||
private ApacheRFC9457Reporter() {} | ||
|
||
@Override | ||
protected boolean isRFC9457Message(final ClassicHttpResponse response) { | ||
Header[] headers = response.getHeaders(HttpHeaders.CONTENT_TYPE); | ||
if (headers.length > 0) { | ||
String contentType = headers[0].getValue(); | ||
return hasRFC9457ContentType(contentType); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
protected int getStatusCode(final ClassicHttpResponse response) { | ||
return response.getCode(); | ||
} | ||
|
||
@Override | ||
protected String getReasonPhrase(final ClassicHttpResponse response) { | ||
String reasonPhrase = response.getReasonPhrase(); | ||
if (reasonPhrase == null || reasonPhrase.isEmpty()) { | ||
return ""; | ||
} | ||
int statusCode = getStatusCode(response); | ||
return reasonPhrase + " (" + statusCode + ")"; | ||
} | ||
|
||
@Override | ||
protected String getBody(final ClassicHttpResponse response) throws IOException { | ||
try { | ||
return EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); | ||
} catch (ParseException e) { | ||
throw new IOException(e); | ||
} | ||
} | ||
} |
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.
Same here