Skip to content

Commit 6958084

Browse files
author
Stephane Landelle
committed
Rename UriComponents into Uri, close AsyncHttpClient#691
1 parent cfdaece commit 6958084

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+292
-205
lines changed

api/src/main/java/org/asynchttpclient/ConnectionPoolKeyStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616
package org.asynchttpclient;
1717

18-
import org.asynchttpclient.uri.UriComponents;
18+
import org.asynchttpclient.uri.Uri;
1919

2020
public interface ConnectionPoolKeyStrategy {
2121

22-
String getKey(UriComponents uri, ProxyServer proxy);
22+
String getKey(Uri uri, ProxyServer proxy);
2323
}

api/src/main/java/org/asynchttpclient/DefaultConnectionPoolStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
*/
1616
package org.asynchttpclient;
1717

18-
import org.asynchttpclient.uri.UriComponents;
18+
import org.asynchttpclient.uri.Uri;
1919
import org.asynchttpclient.util.AsyncHttpProviderUtils;
2020

2121
public enum DefaultConnectionPoolStrategy implements ConnectionPoolKeyStrategy {
2222

2323
INSTANCE;
2424

2525
@Override
26-
public String getKey(UriComponents uri, ProxyServer proxyServer) {
26+
public String getKey(Uri uri, ProxyServer proxyServer) {
2727
String serverPart = AsyncHttpProviderUtils.getBaseUrl(uri);
2828
return proxyServer != null ? proxyServer.getUrl() + serverPart : serverPart;
2929
}

api/src/main/java/org/asynchttpclient/HttpResponseStatus.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,27 @@
1818

1919
import java.util.List;
2020

21-
import org.asynchttpclient.uri.UriComponents;
21+
import org.asynchttpclient.uri.Uri;
2222

2323
/**
2424
* A class that represent the HTTP response' status line (code + text)
2525
*/
2626
public abstract class HttpResponseStatus {
2727

28-
private final UriComponents uri;
28+
private final Uri uri;
2929
protected final AsyncHttpClientConfig config;
3030

31-
public HttpResponseStatus(UriComponents uri, AsyncHttpClientConfig config) {
31+
public HttpResponseStatus(Uri uri, AsyncHttpClientConfig config) {
3232
this.uri = uri;
3333
this.config = config;
3434
}
3535

3636
/**
37-
* Return the request {@link UriComponents}
37+
* Return the request {@link Uri}
3838
*
39-
* @return the request {@link UriComponents}
39+
* @return the request {@link Uri}
4040
*/
41-
public final UriComponents getUri() {
41+
public final Uri getUri() {
4242
return uri;
4343
}
4444

api/src/main/java/org/asynchttpclient/ProxyServerSelector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package org.asynchttpclient;
22

3-
import org.asynchttpclient.uri.UriComponents;
3+
import org.asynchttpclient.uri.Uri;
44

55
/**
66
* Selector for a proxy server
@@ -13,14 +13,14 @@ public interface ProxyServerSelector {
1313
* @param uri The URI to select a proxy server for.
1414
* @return The proxy server to use, if any. May return null.
1515
*/
16-
ProxyServer select(UriComponents uri);
16+
ProxyServer select(Uri uri);
1717

1818
/**
1919
* A selector that always selects no proxy.
2020
*/
2121
static final ProxyServerSelector NO_PROXY_SELECTOR = new ProxyServerSelector() {
2222
@Override
23-
public ProxyServer select(UriComponents uri) {
23+
public ProxyServer select(Uri uri) {
2424
return null;
2525
}
2626
};

api/src/main/java/org/asynchttpclient/Realm.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import static org.asynchttpclient.util.MiscUtils.isNonEmpty;
2020

21-
import org.asynchttpclient.uri.UriComponents;
21+
import org.asynchttpclient.uri.Uri;
2222
import org.asynchttpclient.util.StandardCharsets;
2323

2424
import java.nio.charset.Charset;
@@ -43,7 +43,7 @@ public class Realm {
4343
private final String qop;
4444
private final String nc;
4545
private final String cnonce;
46-
private final UriComponents uri;
46+
private final Uri uri;
4747
private final String methodName;
4848
private final boolean usePreemptiveAuth;
4949
private final String enc;
@@ -60,7 +60,7 @@ public enum AuthScheme {
6060
}
6161

6262
private Realm(AuthScheme scheme, String principal, String password, String realmName, String nonce, String algorithm, String response,
63-
String qop, String nc, String cnonce, UriComponents uri, String method, boolean usePreemptiveAuth, String ntlmDomain, String enc,
63+
String qop, String nc, String cnonce, Uri uri, String method, boolean usePreemptiveAuth, String ntlmDomain, String enc,
6464
String host, boolean messageType2Received, String opaque, boolean useAbsoluteURI, boolean omitQuery, boolean targetProxy) {
6565

6666
this.principal = principal;
@@ -136,7 +136,7 @@ public String getCnonce() {
136136
return cnonce;
137137
}
138138

139-
public UriComponents getUri() {
139+
public Uri getUri() {
140140
return uri;
141141
}
142142

@@ -275,7 +275,7 @@ public static class RealmBuilder {
275275
private String qop = "auth";
276276
private String nc = "00000001";
277277
private String cnonce = "";
278-
private UriComponents uri;
278+
private Uri uri;
279279
private String methodName = "GET";
280280
private boolean usePreemptive;
281281
private String ntlmDomain = System.getProperty("http.auth.ntlm.domain", "");
@@ -394,11 +394,11 @@ public RealmBuilder setNc(String nc) {
394394
return this;
395395
}
396396

397-
public UriComponents getUri() {
397+
public Uri getUri() {
398398
return uri;
399399
}
400400

401-
public RealmBuilder setUri(UriComponents uri) {
401+
public RealmBuilder setUri(Uri uri) {
402402
this.uri = uri;
403403
return this;
404404
}

api/src/main/java/org/asynchttpclient/Request.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import org.asynchttpclient.cookie.Cookie;
2020
import org.asynchttpclient.multipart.Part;
21-
import org.asynchttpclient.uri.UriComponents;
21+
import org.asynchttpclient.uri.Uri;
2222

2323
import java.io.File;
2424
import java.io.InputStream;
@@ -45,7 +45,7 @@ public interface Request {
4545
*/
4646
String getMethod();
4747

48-
UriComponents getURI();
48+
Uri getUri();
4949

5050
String getUrl();
5151

api/src/main/java/org/asynchttpclient/RequestBuilderBase.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import org.asynchttpclient.cookie.Cookie;
2121
import org.asynchttpclient.multipart.Part;
22-
import org.asynchttpclient.uri.UriComponents;
22+
import org.asynchttpclient.uri.Uri;
2323
import org.asynchttpclient.util.AsyncHttpProviderUtils;
2424
import org.asynchttpclient.util.QueryComputer;
2525
import org.slf4j.Logger;
@@ -42,11 +42,11 @@
4242
public abstract class RequestBuilderBase<T extends RequestBuilderBase<T>> {
4343
private final static Logger logger = LoggerFactory.getLogger(RequestBuilderBase.class);
4444

45-
private static final UriComponents DEFAULT_REQUEST_URL = UriComponents.create("http://localhost/");
45+
private static final Uri DEFAULT_REQUEST_URL = Uri.create("http://localhost/");
4646

4747
private static final class RequestImpl implements Request {
4848
private String method;
49-
private UriComponents uri;
49+
private Uri uri;
5050
private InetAddress address;
5151
private InetAddress localAddress;
5252
private FluentCaseInsensitiveStringsMap headers = new FluentCaseInsensitiveStringsMap();
@@ -75,7 +75,7 @@ public RequestImpl() {
7575
public RequestImpl(Request prototype) {
7676
if (prototype != null) {
7777
this.method = prototype.getMethod();
78-
this.uri = prototype.getURI();
78+
this.uri = prototype.getUri();
7979
this.address = prototype.getInetAddress();
8080
this.localAddress = prototype.getLocalAddress();
8181
this.headers = new FluentCaseInsensitiveStringsMap(prototype.getHeaders());
@@ -120,7 +120,7 @@ public InetAddress getLocalAddress() {
120120
}
121121

122122
@Override
123-
public UriComponents getURI() {
123+
public Uri getUri() {
124124
return uri;
125125
}
126126

@@ -289,10 +289,10 @@ protected RequestBuilderBase(Class<T> derived, Request prototype, QueryComputer
289289
}
290290

291291
public T setUrl(String url) {
292-
return setURI(UriComponents.create(url));
292+
return setUri(Uri.create(url));
293293
}
294294

295-
public T setURI(UriComponents uri) {
295+
public T setUri(Uri uri) {
296296
request.uri = uri;
297297
return derived.cast(this);
298298
}

api/src/main/java/org/asynchttpclient/Response.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.asynchttpclient;
1818

1919
import org.asynchttpclient.cookie.Cookie;
20-
import org.asynchttpclient.uri.UriComponents;
20+
import org.asynchttpclient.uri.Uri;
2121

2222
import java.io.IOException;
2323
import java.io.InputStream;
@@ -110,11 +110,11 @@ public interface Response {
110110
String getResponseBody() throws IOException;
111111

112112
/**
113-
* Return the request {@link UriComponents}. Note that if the request got redirected, the value of the {@link URI} will be the last valid redirect url.
113+
* Return the request {@link Uri}. Note that if the request got redirected, the value of the {@link Uri} will be the last valid redirect url.
114114
*
115-
* @return the request {@link UriComponents}.
115+
* @return the request {@link Uri}.
116116
*/
117-
UriComponents getUri();
117+
Uri getUri();
118118

119119
/**
120120
* Return the content-type header value.

api/src/main/java/org/asynchttpclient/SimpleAsyncHttpClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import org.asynchttpclient.resumable.ResumableIOExceptionFilter;
3131
import org.asynchttpclient.simple.HeaderMap;
3232
import org.asynchttpclient.simple.SimpleAHCTransferListener;
33-
import org.asynchttpclient.uri.UriComponents;
33+
import org.asynchttpclient.uri.Uri;
3434

3535
/**
3636
* Simple implementation of {@link AsyncHttpClient} and it's related builders ({@link AsyncHttpClientConfig},
@@ -282,7 +282,7 @@ private Future<Response> execute(RequestBuilder rb, BodyConsumer bodyConsumer, T
282282

283283
Request request = rb.build();
284284
ProgressAsyncHandler<Response> handler = new BodyConsumerAsyncHandler(bodyConsumer, throwableHandler, errorDocumentBehaviour,
285-
request.getURI(), listener);
285+
request.getUri(), listener);
286286

287287
if (resumeEnabled && request.getMethod().equals("GET") && bodyConsumer != null && bodyConsumer instanceof ResumableBodyConsumer) {
288288
ResumableBodyConsumer fileBodyConsumer = (ResumableBodyConsumer) bodyConsumer;
@@ -719,7 +719,7 @@ private final static class BodyConsumerAsyncHandler extends AsyncCompletionHandl
719719
private final BodyConsumer bodyConsumer;
720720
private final ThrowableHandler exceptionHandler;
721721
private final ErrorDocumentBehaviour errorDocumentBehaviour;
722-
private final UriComponents uri;
722+
private final Uri uri;
723723
private final SimpleAHCTransferListener listener;
724724

725725
private boolean accumulateBody = false;
@@ -728,7 +728,7 @@ private final static class BodyConsumerAsyncHandler extends AsyncCompletionHandl
728728
private long total = -1;
729729

730730
public BodyConsumerAsyncHandler(BodyConsumer bodyConsumer, ThrowableHandler exceptionHandler,
731-
ErrorDocumentBehaviour errorDocumentBehaviour, UriComponents uri, SimpleAHCTransferListener listener) {
731+
ErrorDocumentBehaviour errorDocumentBehaviour, Uri uri, SimpleAHCTransferListener listener) {
732732
this.bodyConsumer = bodyConsumer;
733733
this.exceptionHandler = exceptionHandler;
734734
this.errorDocumentBehaviour = errorDocumentBehaviour;
@@ -851,7 +851,7 @@ private void fireHeaders(HttpResponseHeaders headers) {
851851
}
852852
}
853853

854-
private void fireSent(UriComponents uri, long amount, long current, long total) {
854+
private void fireSent(Uri uri, long amount, long current, long total) {
855855
if (listener != null) {
856856
listener.onBytesSent(uri, amount, current, total);
857857
}

api/src/main/java/org/asynchttpclient/oauth/OAuthSignatureCalculator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.asynchttpclient.Request;
2323
import org.asynchttpclient.RequestBuilderBase;
2424
import org.asynchttpclient.SignatureCalculator;
25-
import org.asynchttpclient.uri.UriComponents;
25+
import org.asynchttpclient.uri.Uri;
2626
import org.asynchttpclient.util.Base64;
2727
import org.asynchttpclient.util.StandardCharsets;
2828
import org.asynchttpclient.util.UTF8UrlEncoder;
@@ -86,15 +86,15 @@ public OAuthSignatureCalculator(ConsumerKey consumerAuth, RequestToken userAuth)
8686
public void calculateAndAddSignature(Request request, RequestBuilderBase<?> requestBuilder) {
8787
String nonce = generateNonce();
8888
long timestamp = System.currentTimeMillis() / 1000L;
89-
String signature = calculateSignature(request.getMethod(), request.getURI(), timestamp, nonce, request.getFormParams(), request.getQueryParams());
89+
String signature = calculateSignature(request.getMethod(), request.getUri(), timestamp, nonce, request.getFormParams(), request.getQueryParams());
9090
String headerValue = constructAuthHeader(signature, nonce, timestamp);
9191
requestBuilder.setHeader(HEADER_AUTHORIZATION, headerValue);
9292
}
9393

9494
/**
9595
* Method for calculating OAuth signature using HMAC/SHA-1 method.
9696
*/
97-
public String calculateSignature(String method, UriComponents uri, long oauthTimestamp, String nonce,
97+
public String calculateSignature(String method, Uri uri, long oauthTimestamp, String nonce,
9898
List<Param> formParams, List<Param> queryParams) {
9999
StringBuilder signedText = new StringBuilder(100);
100100
signedText.append(method); // POST / GET etc (nothing to URL encode)

api/src/main/java/org/asynchttpclient/providers/ResponseBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import org.asynchttpclient.HttpResponseStatus;
99
import org.asynchttpclient.Response;
1010
import org.asynchttpclient.cookie.Cookie;
11-
import org.asynchttpclient.uri.UriComponents;
11+
import org.asynchttpclient.uri.Uri;
1212
import org.asynchttpclient.util.AsyncHttpProviderUtils;
1313

1414
import java.util.Collections;
@@ -51,7 +51,7 @@ public final String getStatusText() {
5151
}
5252

5353
@Override
54-
public final UriComponents getUri() {
54+
public final Uri getUri() {
5555
return status.getUri();
5656
}
5757

api/src/main/java/org/asynchttpclient/simple/SimpleAHCTransferListener.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515

1616
import org.asynchttpclient.SimpleAsyncHttpClient;
17-
import org.asynchttpclient.uri.UriComponents;
17+
import org.asynchttpclient.uri.Uri;
1818

1919
/**
2020
* A simple transfer listener for use with the {@link SimpleAsyncHttpClient}.
@@ -34,15 +34,15 @@ public interface SimpleAHCTransferListener {
3434
* @param statusCode the received status code.
3535
* @param statusText the received status text.
3636
*/
37-
void onStatus(UriComponents uri, int statusCode, String statusText);
37+
void onStatus(Uri uri, int statusCode, String statusText);
3838

3939
/**
4040
* This method is called after the response headers are received.
4141
*
4242
* @param uri the uri
4343
* @param headers the received headers, never {@code null}.
4444
*/
45-
void onHeaders(UriComponents uri, HeaderMap headers);
45+
void onHeaders(Uri uri, HeaderMap headers);
4646

4747
/**
4848
* This method is called when bytes of the responses body are received.
@@ -54,7 +54,7 @@ public interface SimpleAHCTransferListener {
5454
* @param total the total number of bytes to be transferred. This is taken
5555
* from the Content-Length-header and may be unspecified (-1).
5656
*/
57-
void onBytesReceived(UriComponents uri, long amount, long current, long total);
57+
void onBytesReceived(Uri uri, long amount, long current, long total);
5858

5959
/**
6060
* This method is called when bytes are sent.
@@ -66,7 +66,7 @@ public interface SimpleAHCTransferListener {
6666
* @param total the total number of bytes to be transferred. This is taken
6767
* from the Content-Length-header and may be unspecified (-1).
6868
*/
69-
void onBytesSent(UriComponents uri, long amount, long current, long total);
69+
void onBytesSent(Uri uri, long amount, long current, long total);
7070

7171
/**
7272
* This method is called when the request is completed.
@@ -75,6 +75,6 @@ public interface SimpleAHCTransferListener {
7575
* @param statusCode the received status code.
7676
* @param statusText the received status text.
7777
*/
78-
void onCompleted(UriComponents uri, int statusCode, String statusText);
78+
void onCompleted(Uri uri, int statusCode, String statusText);
7979
}
8080

0 commit comments

Comments
 (0)