Skip to content

Commit

Permalink
Updating apache httpclient to v5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ChGen committed Apr 1, 2024
1 parent 7150259 commit 7d0ba76
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 55 deletions.
6 changes: 3 additions & 3 deletions artipie-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
<version>v2.3.2+java8</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.14</version>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>${httpclient.version}</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import java.util.concurrent.CompletionException;
import java.util.concurrent.CompletionStage;
import java.util.stream.Collectors;
import org.apache.http.HttpStatus;
import org.apache.http.client.utils.URIBuilder;
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.net.URIBuilder;
import org.cqfn.rio.Buffers;
import org.cqfn.rio.stream.ReactiveInputStream;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import com.artipie.http.rs.RsWithBody;
import com.artipie.http.rs.RsWithStatus;
import com.google.common.collect.Iterables;
import org.apache.hc.core5.net.URIBuilder;

import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
Expand All @@ -22,7 +24,6 @@
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.http.client.utils.URIBuilder;
import org.reactivestreams.Publisher;

/**
Expand Down
4 changes: 2 additions & 2 deletions artipie-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,13 @@ SOFTWARE.
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>5.1.2</version>
<version>${httpclient.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5-fluent</artifactId>
<version>5.1.3</version>
<version>${httpclient.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@
import com.artipie.http.rq.RqParams;
import com.google.common.base.Strings;
import io.vavr.Tuple2;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.net.URIBuilder;
import org.ini4j.Wini;

import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObjectBuilder;
import java.io.IOException;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
Expand All @@ -24,11 +32,6 @@
import java.util.concurrent.CompletableFuture;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonObjectBuilder;
import org.apache.http.client.utils.URIBuilder;
import org.ini4j.Wini;

/**
* Conan /v1/conans/* REST APIs.
Expand Down Expand Up @@ -134,9 +137,13 @@ public CompletableFuture<RequestResult> getResult(final RequestLineFrom request,
if (tuple._2()) {
final URIBuilder builder = new URIBuilder();
builder.setScheme(ConansEntity.PROTOCOL);
builder.setHost(hostname);
builder.setPath(tuple._1());
result = Optional.of(builder.toString());
try {
builder.setHttpHost(HttpHost.create(hostname));
builder.setPath(tuple._1());
result = Optional.of(builder.toString());
} catch (URISyntaxException ex) {
throw new ArtipieIOException(ex);
}
}
return result;
}, builder -> builder.build().toString()
Expand Down Expand Up @@ -174,9 +181,13 @@ public CompletableFuture<RequestResult> getResult(final RequestLineFrom request,
if (tuple._2()) {
final URIBuilder builder = new URIBuilder();
builder.setScheme(ConansEntity.PROTOCOL);
builder.setHost(hostname);
builder.setPath(tuple._1());
result = Optional.of(builder.toString());
try {
builder.setHttpHost(HttpHost.create(hostname));
builder.setPath(tuple._1());
result = Optional.of(builder.toString());
} catch (URISyntaxException ex) {
throw new ArtipieIOException(ex);
}
}
return result;
}, builder -> builder.build().toString()
Expand Down Expand Up @@ -414,12 +425,16 @@ private CompletableFuture<String> checkPkg(final Matcher matcher, final String h
if (exist) {
final URIBuilder builder = new URIBuilder();
builder.setScheme(ConansEntity.PROTOCOL);
builder.setHost(hostname);
builder.setPath(key.string());
result = String.format(
"{ \"%1$s\": \"%2$s\"}", ConansEntity.CONAN_MANIFEST,
builder.toString()
);
try {
builder.setHttpHost(HttpHost.create(hostname));
builder.setPath(key.string());
result = String.format(
"{ \"%1$s\": \"%2$s\"}", ConansEntity.CONAN_MANIFEST,
builder.build()
);
} catch (URISyntaxException ex) {
throw new ArtipieIOException(ex);
}
} else {
result = "";
}
Expand Down Expand Up @@ -468,12 +483,16 @@ private CompletableFuture<String> checkPkg(final Matcher matcher, final String h
if (exist) {
final URIBuilder builder = new URIBuilder();
builder.setScheme(ConansEntity.PROTOCOL);
builder.setHost(hostname);
builder.setPath(key.string());
result = String.format(
"{\"%1$s\": \"%2$s\"}", ConansEntity.CONAN_MANIFEST,
builder.toString()
);
try {
builder.setHttpHost(HttpHost.create(hostname));
builder.setPath(key.string());
result = String.format(
"{\"%1$s\": \"%2$s\"}", ConansEntity.CONAN_MANIFEST,
builder.build()
);
} catch (URISyntaxException ex) {
throw new ArtipieIOException(ex);
}
} else {
result = "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@

import com.amihaiemil.eoyaml.YamlMapping;
import com.google.common.base.Strings;
import org.apache.hc.core5.net.URIBuilder;

import java.net.URI;
import java.net.URISyntaxException;
import java.util.Objects;
import org.apache.http.client.utils.URIBuilder;

/**
* Proxy settings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import org.apache.http.client.utils.URIBuilder;
import org.apache.hc.core5.net.URIBuilder;
import org.eclipse.jetty.client.AsyncRequestContent;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.Request;
Expand Down
6 changes: 0 additions & 6 deletions nuget-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ SOFTWARE.
<version>3.9.1</version>
</dependency>
<!-- Test scope -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.artipie</groupId>
<artifactId>vertx-server</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
import com.artipie.scheduling.ArtifactEvent;
import com.artipie.security.policy.PolicyByUsername;
import com.google.common.io.Resources;
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
import org.apache.hc.core5.http.HttpEntity;
import org.hamcrest.MatcherAssert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import io.reactivex.Flowable;
import java.io.ByteArrayOutputStream;
import java.net.URI;
Expand All @@ -28,11 +34,6 @@
import java.util.Queue;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.apache.http.HttpEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.hamcrest.MatcherAssert;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Tests for {@link NuGet}.
Expand Down Expand Up @@ -135,7 +136,7 @@ private Response putPackage(final byte[] pack) throws Exception {
new RequestLine(RqMethod.PUT, "/package").toString(),
new Headers.From(
new TestAuthentication.Header(),
new Header("Content-Type", entity.getContentType().getValue())
new Header("Content-Type", entity.getContentType())
),
Flowable.fromArray(ByteBuffer.wrap(sink.toByteArray()))
);
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ SOFTWARE.
<javax.json.version>1.1.4</javax.json.version>
<maven.compiler.release>17</maven.compiler.release>
<header.license>LICENSE.header</header.license>
<httpclient.version>5.3.1</httpclient.version>
</properties>
<distributionManagement>
<repository>
Expand Down
13 changes: 3 additions & 10 deletions pypi-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ SOFTWARE.
<name>pypi-adapter</name>
<url>https://github.com/artipie/pypi-adapter</url>
<properties>
<apache.httpcomponents.version>4.5.14</apache.httpcomponents.version>
<header.license>${project.basedir}/../LICENSE.header</header.license>
</properties>
<dependencies>
Expand Down Expand Up @@ -69,15 +68,9 @@ SOFTWARE.
</dependency>
<!-- Test -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>${apache.httpcomponents.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>${apache.httpcomponents.version}</version>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5</artifactId>
<version>${httpclient.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down

0 comments on commit 7d0ba76

Please sign in to comment.