You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2016/12/27 19:48:10 UTC
svn commit: r1776187 [11/21] - in /httpcomponents/httpclient/trunk: ./
httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/
httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/
httpclient5-cache/src/test/java/org/apache/h...
Modified: httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Executor.java Tue Dec 27 19:48:07 2016
@@ -27,6 +27,7 @@
package org.apache.hc.client5.http.fluent;
import java.io.IOException;
+import java.net.URISyntaxException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.TimeUnit;
@@ -141,7 +142,13 @@ public class Executor {
* @since 4.4
*/
public Executor auth(final String host, final Credentials creds) {
- return auth(HttpHost.create(host), creds);
+ final HttpHost httpHost;
+ try {
+ httpHost = HttpHost.create(host);
+ } catch (URISyntaxException ex) {
+ throw new IllegalArgumentException("Invalid host: " + host);
+ }
+ return auth(httpHost, creds);
}
public Executor authPreemptive(final HttpHost host) {
@@ -160,7 +167,13 @@ public class Executor {
* @since 4.4
*/
public Executor authPreemptive(final String host) {
- return authPreemptive(HttpHost.create(host));
+ final HttpHost httpHost;
+ try {
+ httpHost = HttpHost.create(host);
+ } catch (URISyntaxException ex) {
+ throw new IllegalArgumentException("Invalid host: " + host);
+ }
+ return authPreemptive(httpHost);
}
public Executor authPreemptiveProxy(final HttpHost proxy) {
@@ -179,7 +192,13 @@ public class Executor {
* @since 4.4
*/
public Executor authPreemptiveProxy(final String proxy) {
- return authPreemptiveProxy(HttpHost.create(proxy));
+ final HttpHost httpHost;
+ try {
+ httpHost = HttpHost.create(proxy);
+ } catch (URISyntaxException ex) {
+ throw new IllegalArgumentException("Invalid host: " + proxy);
+ }
+ return authPreemptiveProxy(httpHost);
}
public Executor auth(final Credentials cred) {
@@ -256,7 +275,7 @@ public class Executor {
* @since 4.4
*/
public static void closeIdleConnections() {
- CONNMGR.closeIdleConnections(0, TimeUnit.MICROSECONDS);
+ CONNMGR.closeIdle(0, TimeUnit.MICROSECONDS);
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Request.java Tue Dec 27 19:48:07 2016
@@ -30,6 +30,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
+import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
@@ -51,16 +52,20 @@ import org.apache.hc.client5.http.method
import org.apache.hc.client5.http.methods.HttpPost;
import org.apache.hc.client5.http.methods.HttpPut;
import org.apache.hc.client5.http.methods.HttpTrace;
-import org.apache.hc.client5.http.utils.URLEncodedUtils;
+import org.apache.hc.client5.http.methods.HttpUriRequestBase;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpHeaders;
import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpVersion;
import org.apache.hc.core5.http.NameValuePair;
-import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.io.entity.FileEntity;
+import org.apache.hc.core5.http.io.entity.InputStreamEntity;
import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.net.URLEncodedUtils;
public class Request {
@@ -68,7 +73,7 @@ public class Request {
public static final Locale DATE_LOCALE = Locale.US;
public static final TimeZone TIME_ZONE = TimeZone.getTimeZone("GMT");
- private final InternalHttpRequest request;
+ private final HttpUriRequestBase request;
private Boolean useExpectContinue;
private Integer socketTmeout;
private Integer connectTimeout;
@@ -77,83 +82,83 @@ public class Request {
private SimpleDateFormat dateFormatter;
public static Request create(final String methodName, final String uri) {
- return new Request(new InternalHttpRequest(methodName, URI.create(uri)));
+ return new Request(new HttpUriRequestBase(methodName, URI.create(uri)));
}
public static Request create(final String methodName, final URI uri) {
- return new Request(new InternalHttpRequest(methodName, uri));
+ return new Request(new HttpUriRequestBase(methodName, uri));
}
public static Request Get(final URI uri) {
- return new Request(new InternalHttpRequest(HttpGet.METHOD_NAME, uri));
+ return new Request(new HttpUriRequestBase(HttpGet.METHOD_NAME, uri));
}
public static Request Get(final String uri) {
- return new Request(new InternalHttpRequest(HttpGet.METHOD_NAME, URI.create(uri)));
+ return new Request(new HttpUriRequestBase(HttpGet.METHOD_NAME, URI.create(uri)));
}
public static Request Head(final URI uri) {
- return new Request(new InternalHttpRequest(HttpHead.METHOD_NAME, uri));
+ return new Request(new HttpUriRequestBase(HttpHead.METHOD_NAME, uri));
}
public static Request Head(final String uri) {
- return new Request(new InternalHttpRequest(HttpHead.METHOD_NAME, URI.create(uri)));
+ return new Request(new HttpUriRequestBase(HttpHead.METHOD_NAME, URI.create(uri)));
}
public static Request Post(final URI uri) {
- return new Request(new InternalHttpRequest(HttpPost.METHOD_NAME, uri));
+ return new Request(new HttpUriRequestBase(HttpPost.METHOD_NAME, uri));
}
public static Request Post(final String uri) {
- return new Request(new InternalHttpRequest(HttpPost.METHOD_NAME, URI.create(uri)));
+ return new Request(new HttpUriRequestBase(HttpPost.METHOD_NAME, URI.create(uri)));
}
public static Request Patch(final URI uri) {
- return new Request(new InternalHttpRequest(HttpPatch.METHOD_NAME, uri));
+ return new Request(new HttpUriRequestBase(HttpPatch.METHOD_NAME, uri));
}
public static Request Patch(final String uri) {
- return new Request(new InternalHttpRequest(HttpPatch.METHOD_NAME, URI.create(uri)));
+ return new Request(new HttpUriRequestBase(HttpPatch.METHOD_NAME, URI.create(uri)));
}
public static Request Put(final URI uri) {
- return new Request(new InternalHttpRequest(HttpPut.METHOD_NAME, uri));
+ return new Request(new HttpUriRequestBase(HttpPut.METHOD_NAME, uri));
}
public static Request Put(final String uri) {
- return new Request(new InternalHttpRequest(HttpPut.METHOD_NAME, URI.create(uri)));
+ return new Request(new HttpUriRequestBase(HttpPut.METHOD_NAME, URI.create(uri)));
}
public static Request Trace(final URI uri) {
- return new Request(new InternalHttpRequest(HttpTrace.METHOD_NAME, uri));
+ return new Request(new HttpUriRequestBase(HttpTrace.METHOD_NAME, uri));
}
public static Request Trace(final String uri) {
- return new Request(new InternalHttpRequest(HttpTrace.METHOD_NAME, URI.create(uri)));
+ return new Request(new HttpUriRequestBase(HttpTrace.METHOD_NAME, URI.create(uri)));
}
public static Request Delete(final URI uri) {
- return new Request(new InternalHttpRequest(HttpDelete.METHOD_NAME, uri));
+ return new Request(new HttpUriRequestBase(HttpDelete.METHOD_NAME, uri));
}
public static Request Delete(final String uri) {
- return new Request(new InternalHttpRequest(HttpDelete.METHOD_NAME, URI.create(uri)));
+ return new Request(new HttpUriRequestBase(HttpDelete.METHOD_NAME, URI.create(uri)));
}
public static Request Options(final URI uri) {
- return new Request(new InternalHttpRequest(HttpOptions.METHOD_NAME, uri));
+ return new Request(new HttpUriRequestBase(HttpOptions.METHOD_NAME, uri));
}
public static Request Options(final String uri) {
- return new Request(new InternalHttpRequest(HttpOptions.METHOD_NAME, URI.create(uri)));
+ return new Request(new HttpUriRequestBase(HttpOptions.METHOD_NAME, URI.create(uri)));
}
- Request(final InternalHttpRequest request) {
+ Request(final HttpUriRequestBase request) {
super();
this.request = request;
}
- HttpResponse internalExecute(
+ ClassicHttpResponse internalExecute(
final CloseableHttpClient client,
final HttpContext localContext) throws IOException {
final RequestConfig.Builder builder;
@@ -261,7 +266,7 @@ public class Request {
//// HTTP protocol parameter operations
public Request version(final HttpVersion version) {
- this.request.setProtocolVersion(version);
+ this.request.setVersion(version);
return this;
}
@@ -298,7 +303,11 @@ public class Request {
* @since 4.4
*/
public Request viaProxy(final String proxy) {
- this.proxy = HttpHost.create(proxy);
+ try {
+ this.proxy = HttpHost.create(proxy);
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException("Invalid host");
+ }
return this;
}
@@ -330,46 +339,46 @@ public class Request {
public Request bodyString(final String s, final ContentType contentType) {
final Charset charset = contentType != null ? contentType.getCharset() : null;
final byte[] raw = charset != null ? s.getBytes(charset) : s.getBytes();
- return body(new InternalByteArrayEntity(raw, contentType));
+ return body(new ByteArrayEntity(raw, contentType));
}
public Request bodyFile(final File file, final ContentType contentType) {
- return body(new InternalFileEntity(file, contentType));
+ return body(new FileEntity(file, contentType));
}
public Request bodyByteArray(final byte[] b) {
- return body(new InternalByteArrayEntity(b));
+ return body(new ByteArrayEntity(b));
}
/**
* @since 4.4
*/
public Request bodyByteArray(final byte[] b, final ContentType contentType) {
- return body(new InternalByteArrayEntity(b, contentType));
+ return body(new ByteArrayEntity(b, contentType));
}
public Request bodyByteArray(final byte[] b, final int off, final int len) {
- return body(new InternalByteArrayEntity(b, off, len));
+ return body(new ByteArrayEntity(b, off, len));
}
/**
* @since 4.4
*/
public Request bodyByteArray(final byte[] b, final int off, final int len, final ContentType contentType) {
- return body(new InternalByteArrayEntity(b, off, len, contentType));
+ return body(new ByteArrayEntity(b, off, len, contentType));
}
public Request bodyStream(final InputStream instream) {
- return body(new InternalInputStreamEntity(instream, -1, null));
+ return body(new InputStreamEntity(instream, -1, null));
}
public Request bodyStream(final InputStream instream, final ContentType contentType) {
- return body(new InternalInputStreamEntity(instream, -1, contentType));
+ return body(new InputStreamEntity(instream, -1, contentType));
}
@Override
public String toString() {
- return this.request.getRequestLine().toString();
+ return this.request.toString();
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Response.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Response.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Response.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Response.java Tue Dec 27 19:48:07 2016
@@ -31,21 +31,24 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import org.apache.hc.client5.http.protocol.ClientProtocolException;
import org.apache.hc.client5.http.protocol.HttpResponseException;
-import org.apache.hc.client5.http.sync.ResponseHandler;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpResponse;
-import org.apache.hc.core5.http.StatusLine;
-import org.apache.hc.core5.http.entity.ByteArrayEntity;
-import org.apache.hc.core5.http.entity.ContentType;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.io.ResponseHandler;
+import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
public class Response {
- private final HttpResponse response;
+ private final ClassicHttpResponse response;
private boolean consumed;
- Response(final HttpResponse response) {
+ Response(final ClassicHttpResponse response) {
super();
this.response = response;
}
@@ -87,6 +90,8 @@ public class Response {
assertNotConsumed();
try {
return handler.handleResponse(this.response);
+ } catch (HttpException ex) {
+ throw new ClientProtocolException(ex);
} finally {
dispose();
}
@@ -103,7 +108,7 @@ public class Response {
if (entity != null) {
final ByteArrayEntity byteArrayEntity = new ByteArrayEntity(
EntityUtils.toByteArray(entity));
- final ContentType contentType = ContentType.getOrDefault(entity);
+ final ContentType contentType = EntityUtils.getContentTypeOrDefault(entity);
byteArrayEntity.setContentType(contentType.toString());
this.response.setEntity(byteArrayEntity);
}
@@ -115,10 +120,9 @@ public class Response {
public void saveContent(final File file) throws IOException {
assertNotConsumed();
- final StatusLine statusLine = response.getStatusLine();
- if (statusLine.getStatusCode() >= 300) {
- throw new HttpResponseException(statusLine.getStatusCode(),
- statusLine.getReasonPhrase());
+ final int status = response.getCode();
+ if (status >= HttpStatus.SC_REDIRECTION) {
+ throw new HttpResponseException(status, response.getReasonPhrase());
}
try (FileOutputStream out = new FileOutputStream(file)) {
final HttpEntity entity = this.response.getEntity();
Modified: httpcomponents/httpclient/trunk/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/fluent/TestFluent.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/fluent/TestFluent.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/fluent/TestFluent.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/fluent/TestFluent.java Tue Dec 27 19:48:07 2016
@@ -33,16 +33,16 @@ import java.nio.charset.Charset;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.protocol.ClientProtocolException;
-import org.apache.hc.client5.http.sync.ResponseHandler;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
+import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.HttpResponse;
-import org.apache.hc.core5.http.entity.ContentType;
-import org.apache.hc.core5.http.entity.EntityUtils;
-import org.apache.hc.core5.http.entity.StringEntity;
import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.io.ResponseHandler;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.StringEntity;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.junit.After;
import org.junit.Assert;
@@ -58,8 +58,8 @@ public class TestFluent extends LocalSer
@Override
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final ClassicHttpRequest request,
+ final ClassicHttpResponse response,
final HttpContext context) throws HttpException, IOException {
response.setEntity(new StringEntity("All is well", ContentType.TEXT_PLAIN));
}
@@ -69,13 +69,13 @@ public class TestFluent extends LocalSer
@Override
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final ClassicHttpRequest request,
+ final ClassicHttpResponse response,
final HttpContext context) throws HttpException, IOException {
HttpEntity responseEntity = null;
final HttpEntity requestEntity = request.getEntity();
if (requestEntity != null) {
- final ContentType contentType = ContentType.getOrDefault(requestEntity);
+ final ContentType contentType = EntityUtils.getContentTypeOrDefault(requestEntity);
if (ContentType.TEXT_PLAIN.getMimeType().equals(contentType.getMimeType())) {
responseEntity = new StringEntity(
EntityUtils.toString(requestEntity), ContentType.TEXT_PLAIN);
@@ -164,7 +164,7 @@ public class TestFluent extends LocalSer
@Override
public Object handleResponse(
- final HttpResponse response) throws IOException {
+ final ClassicHttpResponse response) throws IOException {
return null;
}
Modified: httpcomponents/httpclient/trunk/httpclient5-osgi/pom.xml
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-osgi/pom.xml?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-osgi/pom.xml (original)
+++ httpcomponents/httpclient/trunk/httpclient5-osgi/pom.xml Tue Dec 27 19:48:07 2016
@@ -40,7 +40,7 @@
<packaging>bundle</packaging>
<properties>
- <httpcore.osgi.import.version>"5.0-alpha1"</httpcore.osgi.import.version>
+ <httpcore.osgi.import.version>"5.0-alpha2"</httpcore.osgi.import.version>
<log4j.osgi.import.version>"2.7"</log4j.osgi.import.version>
<pax.url.version>2.4.1</pax.url.version>
<pax.exam.version>4.5.0</pax.exam.version>
@@ -198,17 +198,7 @@
org.osgi.framework,
org.osgi.service.cm,
org.apache.logging.log4j;version=${log4j.osgi.import.version},
- org.apache.hc.core5.concurrent;version=${httpcore.osgi.import.version},
- org.apache.hc.core5.pool;version=${httpcore.osgi.import.version},
- org.apache.hc.core5.ssl;version=${httpcore.osgi.import.version},
- org.apache.hc.core5.util;version=${httpcore.osgi.import.version},
- org.apache.hc.core5.http;version=${httpcore.osgi.import.version},
- org.apache.hc.core5.http.config;version=${httpcore.osgi.import.version},
- org.apache.hc.core5.http.entity;version=${httpcore.osgi.import.version},
- org.apache.hc.core5.http.message;version=${httpcore.osgi.import.version},
- org.apache.hc.core5.http.io;version=${httpcore.osgi.import.version},
- org.apache.hc.core5.http.protocol;version=${httpcore.osgi.import.version},
- org.apache.hc.core5.http.impl.io;version=${httpcore.osgi.import.version},
+ org.apache.hc.core5.*;version=${httpcore.osgi.import.version},
net.sf.ehcache.*;resolution:=optional,
net.spy.memcached.*;resolution:=optional
</Import-Package>
Modified: httpcomponents/httpclient/trunk/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/MimeExportedIT.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/MimeExportedIT.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/MimeExportedIT.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-osgi/src/test/java/org/apache/hc/client5/http/osgi/impl/MimeExportedIT.java Tue Dec 27 19:48:07 2016
@@ -43,7 +43,7 @@ import org.apache.hc.client5.http.entity
import org.apache.hc.client5.http.entity.mime.StringBody;
import org.apache.hc.client5.http.methods.HttpPost;
import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.http.ContentType;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
Modified: httpcomponents/httpclient/trunk/httpclient5-win/src/examples/org/apache/hc/client5/http/examples/client/win/ClientWinAuth.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-win/src/examples/org/apache/hc/client5/http/examples/client/win/ClientWinAuth.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-win/src/examples/org/apache/hc/client5/http/examples/client/win/ClientWinAuth.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-win/src/examples/org/apache/hc/client5/http/examples/client/win/ClientWinAuth.java Tue Dec 27 19:48:07 2016
@@ -31,7 +31,7 @@ import org.apache.hc.client5.http.impl.s
import org.apache.hc.client5.http.impl.win.WinHttpClients;
import org.apache.hc.client5.http.methods.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
/**
* This example demonstrates how to create HttpClient pre-configured
@@ -52,11 +52,11 @@ public class ClientWinAuth {
try {
HttpGet httpget = new HttpGet("http://winhost/");
- System.out.println("Executing request " + httpget.getRequestLine());
+ System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
CloseableHttpResponse response = httpclient.execute(httpget);
try {
System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
+ System.out.println(response.getCode() + " " + response.getReasonPhrase());
EntityUtils.consume(response.getEntity());
} finally {
response.close();
Modified: httpcomponents/httpclient/trunk/httpclient5-win/src/main/java/org/apache/hc/client5/http/impl/win/WindowsNTLMSchemeFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-win/src/main/java/org/apache/hc/client5/http/impl/win/WindowsNTLMSchemeFactory.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-win/src/main/java/org/apache/hc/client5/http/impl/win/WindowsNTLMSchemeFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-win/src/main/java/org/apache/hc/client5/http/impl/win/WindowsNTLMSchemeFactory.java Tue Dec 27 19:48:07 2016
@@ -30,7 +30,8 @@ package org.apache.hc.client5.http.impl.
import org.apache.hc.client5.http.auth.AuthScheme;
import org.apache.hc.client5.http.auth.AuthSchemeProvider;
import org.apache.hc.client5.http.config.AuthSchemes;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.protocol.HttpContext;
/**
@@ -42,7 +43,7 @@ import org.apache.hc.core5.http.protocol
*
* @since 4.4
*/
-@Immutable
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
public class WindowsNTLMSchemeFactory implements AuthSchemeProvider {
private final String servicePrincipalName;
Modified: httpcomponents/httpclient/trunk/httpclient5-win/src/main/java/org/apache/hc/client5/http/impl/win/WindowsNegotiateScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-win/src/main/java/org/apache/hc/client5/http/impl/win/WindowsNegotiateScheme.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-win/src/main/java/org/apache/hc/client5/http/impl/win/WindowsNegotiateScheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-win/src/main/java/org/apache/hc/client5/http/impl/win/WindowsNegotiateScheme.java Tue Dec 27 19:48:07 2016
@@ -29,7 +29,6 @@ package org.apache.hc.client5.http.impl.
import java.security.Principal;
import org.apache.commons.codec.binary.Base64;
-import org.apache.hc.client5.http.RouteInfo;
import org.apache.hc.client5.http.auth.AuthChallenge;
import org.apache.hc.client5.http.auth.AuthScheme;
import org.apache.hc.client5.http.auth.AuthenticationException;
@@ -37,11 +36,10 @@ import org.apache.hc.client5.http.auth.B
import org.apache.hc.client5.http.auth.CredentialsProvider;
import org.apache.hc.client5.http.auth.MalformedChallengeException;
import org.apache.hc.client5.http.config.AuthSchemes;
-import org.apache.hc.client5.http.protocol.HttpClientContext;
-import org.apache.hc.core5.annotation.NotThreadSafe;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.protocol.HttpContext;
+import org.apache.hc.core5.net.URIAuthority;
import org.apache.hc.core5.util.Args;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -68,7 +66,6 @@ import com.sun.jna.ptr.IntByReference;
*
* @since 4.4
*/
-@NotThreadSafe
public class WindowsNegotiateScheme implements AuthScheme {
private final Logger log = LogManager.getLogger(getClass());
@@ -196,7 +193,7 @@ public class WindowsNegotiateScheme impl
throw new Win32Exception(rc);
}
- final String targetName = getServicePrincipalName(context);
+ final String targetName = getServicePrincipalName(request);
response = getToken(null, null, targetName);
} catch (final RuntimeException ex) {
failAuthCleanup();
@@ -213,7 +210,7 @@ public class WindowsNegotiateScheme impl
final byte[] continueTokenBytes = Base64.decodeBase64(challenge);
final SecBufferDesc continueTokenBuffer = new SecBufferDesc(
Sspi.SECBUFFER_TOKEN, continueTokenBytes);
- final String targetName = getServicePrincipalName(context);
+ final String targetName = getServicePrincipalName(request);
response = getToken(this.sspiContext, continueTokenBuffer, targetName);
} catch (final RuntimeException ex) {
failAuthCleanup();
@@ -236,23 +233,14 @@ public class WindowsNegotiateScheme impl
// at http://www.chromium.org/developers/design-documents/http-authentication). Here,
// I've chosen to use the host that has been provided in HttpHost so that I don't incur
// any additional DNS lookup cost.
- private String getServicePrincipalName(final HttpContext context) {
- final String spn;
+ private String getServicePrincipalName(final HttpRequest request) {
+ String spn = null;
if (this.servicePrincipalName != null) {
spn = this.servicePrincipalName;
} else {
- final HttpClientContext clientContext = HttpClientContext.adapt(context);
- final HttpHost target = clientContext.getTargetHost();
- if (target != null) {
- spn = "HTTP/" + target.getHostName();
- } else {
- final RouteInfo route = clientContext.getHttpRoute();
- if (route != null) {
- spn = "HTTP/" + route.getTargetHost().getHostName();
- } else {
- // Should not happen
- spn = null;
- }
+ final URIAuthority authority = request.getAuthority();
+ if (authority != null) {
+ spn = "HTTP/" + authority.getHostName();
}
}
if (this.log.isDebugEnabled()) {
Modified: httpcomponents/httpclient/trunk/httpclient5-win/src/main/java/org/apache/hc/client5/http/impl/win/WindowsNegotiateSchemeFactory.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-win/src/main/java/org/apache/hc/client5/http/impl/win/WindowsNegotiateSchemeFactory.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-win/src/main/java/org/apache/hc/client5/http/impl/win/WindowsNegotiateSchemeFactory.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-win/src/main/java/org/apache/hc/client5/http/impl/win/WindowsNegotiateSchemeFactory.java Tue Dec 27 19:48:07 2016
@@ -30,7 +30,8 @@ package org.apache.hc.client5.http.impl.
import org.apache.hc.client5.http.auth.AuthScheme;
import org.apache.hc.client5.http.auth.AuthSchemeProvider;
import org.apache.hc.client5.http.config.AuthSchemes;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.protocol.HttpContext;
/**
@@ -42,7 +43,7 @@ import org.apache.hc.core5.http.protocol
*
* @since 4.4
*/
-@Immutable
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
public class WindowsNegotiateSchemeFactory implements AuthSchemeProvider {
private final String servicePrincipalName;
Modified: httpcomponents/httpclient/trunk/httpclient5-win/src/test/java/org/apache/hc/client5/http/impl/win/TestWindowsNegotiateScheme.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-win/src/test/java/org/apache/hc/client5/http/impl/win/TestWindowsNegotiateScheme.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-win/src/test/java/org/apache/hc/client5/http/impl/win/TestWindowsNegotiateScheme.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-win/src/test/java/org/apache/hc/client5/http/impl/win/TestWindowsNegotiateScheme.java Tue Dec 27 19:48:07 2016
@@ -34,18 +34,18 @@ import org.apache.hc.client5.http.config
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClientBuilder;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHeaders;
import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.config.Registry;
import org.apache.hc.core5.http.config.RegistryBuilder;
-import org.apache.hc.core5.http.entity.EntityUtils;
import org.apache.hc.core5.http.io.HttpRequestHandler;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.protocol.HttpContext;
import org.junit.After;
import org.junit.Assume;
@@ -69,11 +69,11 @@ public class TestWindowsNegotiateScheme
@Override
public void handle(
- final HttpRequest request,
- final HttpResponse response,
+ final ClassicHttpRequest request,
+ final ClassicHttpResponse response,
final HttpContext context) throws HttpException, IOException {
response.addHeader(HttpHeaders.WWW_AUTHENTICATE, AuthSchemes.SPNEGO);
- response.setStatusCode(HttpStatus.SC_UNAUTHORIZED);
+ response.setCode(HttpStatus.SC_UNAUTHORIZED);
}
});
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientAbortMethod.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientAbortMethod.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientAbortMethod.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientAbortMethod.java Tue Dec 27 19:48:07 2016
@@ -29,7 +29,7 @@ package org.apache.hc.client5.http.examp
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
/**
@@ -41,10 +41,10 @@ public class ClientAbortMethod {
try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
HttpGet httpget = new HttpGet("http://httpbin.org/get");
- System.out.println("Executing request " + httpget.getURI());
+ System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
try (CloseableHttpResponse response = httpclient.execute(httpget)) {
System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
+ System.out.println(response.getCode() + " " + response.getReasonPhrase());
// Do not feel like reading the response body
// Call abort on the request object
httpget.abort();
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientAuthentication.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientAuthentication.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientAuthentication.java Tue Dec 27 19:48:07 2016
@@ -31,9 +31,9 @@ import org.apache.hc.client5.http.auth.U
import org.apache.hc.client5.http.impl.sync.BasicCredentialsProvider;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
/**
* A simple example that uses HttpClient to execute an HTTP request against
@@ -51,10 +51,10 @@ public class ClientAuthentication {
.build()) {
HttpGet httpget = new HttpGet("http://httpbin.org/basic-auth/user/passwd");
- System.out.println("Executing request " + httpget.getRequestLine());
+ System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
try (CloseableHttpResponse response = httpclient.execute(httpget)) {
System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
+ System.out.println(response.getCode() + " " + response.getReasonPhrase());
System.out.println(EntityUtils.toString(response.getEntity()));
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientChunkEncodedPost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientChunkEncodedPost.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientChunkEncodedPost.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientChunkEncodedPost.java Tue Dec 27 19:48:07 2016
@@ -31,11 +31,11 @@ import java.io.FileInputStream;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpPost;
-import org.apache.hc.core5.http.entity.ContentType;
-import org.apache.hc.core5.http.entity.EntityUtils;
-import org.apache.hc.core5.http.entity.InputStreamEntity;
+import org.apache.hc.core5.http.ContentType;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.InputStreamEntity;
/**
* Example how to use unbuffered chunk-encoded POST request.
@@ -63,10 +63,10 @@ public class ClientChunkEncodedPost {
httppost.setEntity(reqEntity);
- System.out.println("Executing request: " + httppost.getRequestLine());
+ System.out.println("Executing request " + httppost.getMethod() + " " + httppost.getUri());
try (CloseableHttpResponse response = httpclient.execute(httppost)) {
System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
+ System.out.println(response.getCode() + " " + response.getReasonPhrase());
System.out.println(EntityUtils.toString(response.getEntity()));
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java Tue Dec 27 19:48:07 2016
@@ -53,29 +53,28 @@ import org.apache.hc.client5.http.impl.s
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
import org.apache.hc.client5.http.io.ManagedHttpClientConnection;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
import org.apache.hc.client5.http.socket.PlainConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.Header;
-import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.ParseException;
import org.apache.hc.core5.http.config.ConnectionConfig;
-import org.apache.hc.core5.http.config.MessageConstraints;
+import org.apache.hc.core5.http.config.H1Config;
import org.apache.hc.core5.http.config.Registry;
import org.apache.hc.core5.http.config.RegistryBuilder;
import org.apache.hc.core5.http.config.SocketConfig;
-import org.apache.hc.core5.http.entity.EntityUtils;
-import org.apache.hc.core5.http.impl.DefaultHttpResponseFactory;
+import org.apache.hc.core5.http.impl.io.DefaultClassicHttpResponseFactory;
import org.apache.hc.core5.http.impl.io.DefaultHttpRequestWriterFactory;
import org.apache.hc.core5.http.io.HttpMessageParser;
import org.apache.hc.core5.http.io.HttpMessageParserFactory;
import org.apache.hc.core5.http.io.HttpMessageWriterFactory;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.hc.core5.http.message.BasicLineParser;
import org.apache.hc.core5.http.message.LineParser;
@@ -92,10 +91,10 @@ public class ClientConfiguration {
// Use custom message parser / writer to customize the way HTTP
// messages are parsed from and written out to the data stream.
- HttpMessageParserFactory<HttpResponse> responseParserFactory = new DefaultHttpResponseParserFactory() {
+ HttpMessageParserFactory<ClassicHttpResponse> responseParserFactory = new DefaultHttpResponseParserFactory() {
@Override
- public HttpMessageParser<HttpResponse> create(MessageConstraints constraints) {
+ public HttpMessageParser<ClassicHttpResponse> create(H1Config h1Config) {
LineParser lineParser = new BasicLineParser() {
@Override
@@ -108,18 +107,18 @@ public class ClientConfiguration {
}
};
- return new LenientHttpResponseParser(lineParser, DefaultHttpResponseFactory.INSTANCE, constraints);
+ return new LenientHttpResponseParser(lineParser, DefaultClassicHttpResponseFactory.INSTANCE, h1Config);
}
};
- HttpMessageWriterFactory<HttpRequest> requestWriterFactory = new DefaultHttpRequestWriterFactory();
+ HttpMessageWriterFactory<ClassicHttpRequest> requestWriterFactory = new DefaultHttpRequestWriterFactory();
// Use a custom connection factory to customize the process of
// initialization of outgoing HTTP connections. Beside standard connection
// configuration parameters HTTP connection factory can define message
// parser / writer routines to be employed by individual connections.
HttpConnectionFactory<HttpRoute, ManagedHttpClientConnection> connFactory = new ManagedHttpClientConnectionFactory(
- requestWriterFactory, responseParserFactory);
+ H1Config.DEFAULT, requestWriterFactory, responseParserFactory);
// Client HTTP connection objects when fully initialized can be bound to
// an arbitrary network socket. The process of network socket initialization,
@@ -167,7 +166,7 @@ public class ClientConfiguration {
connManager.setValidateAfterInactivity(1000);
// Create message constraints
- MessageConstraints messageConstraints = MessageConstraints.custom()
+ H1Config messageConstraints = H1Config.custom()
.setMaxHeaderCount(200)
.setMaxLineLength(2000)
.build();
@@ -176,7 +175,6 @@ public class ClientConfiguration {
.setMalformedInputAction(CodingErrorAction.IGNORE)
.setUnmappableInputAction(CodingErrorAction.IGNORE)
.setCharset(StandardCharsets.UTF_8)
- .setMessageConstraints(messageConstraints)
.build();
// Configure the connection manager to use connection configuration either
// by default or for a specific host.
@@ -228,12 +226,10 @@ public class ClientConfiguration {
context.setCookieStore(cookieStore);
context.setCredentialsProvider(credentialsProvider);
- System.out.println("executing request " + httpget.getURI());
+ System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
try (CloseableHttpResponse response = httpclient.execute(httpget, context)) {
- HttpEntity entity = response.getEntity();
-
System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
+ System.out.println(response.getCode() + " " + response.getReasonPhrase());
System.out.println(EntityUtils.toString(response.getEntity()));
// Once the request has been executed the local context can
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConnectionRelease.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConnectionRelease.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConnectionRelease.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConnectionRelease.java Tue Dec 27 19:48:07 2016
@@ -32,7 +32,7 @@ import java.io.InputStream;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
import org.apache.hc.core5.http.HttpEntity;
@@ -46,10 +46,10 @@ public class ClientConnectionRelease {
try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
HttpGet httpget = new HttpGet("http://httpbin.org/get");
- System.out.println("Executing request " + httpget.getRequestLine());
+ System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
try (CloseableHttpResponse response = httpclient.execute(httpget)) {
System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
+ System.out.println(response.getCode() + " " + response.getReasonPhrase());
// Get hold of the response entity
HttpEntity entity = response.getEntity();
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomContext.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomContext.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomContext.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomContext.java Tue Dec 27 19:48:07 2016
@@ -34,10 +34,10 @@ import org.apache.hc.client5.http.cookie
import org.apache.hc.client5.http.cookie.CookieStore;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
import org.apache.hc.client5.http.protocol.HttpClientContext;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
/**
* This example demonstrates the use of a local HTTP context populated with
@@ -56,12 +56,12 @@ public class ClientCustomContext {
localContext.setCookieStore(cookieStore);
HttpGet httpget = new HttpGet("http://httpbin.org/cookies");
- System.out.println("Executing request " + httpget.getRequestLine());
+ System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
// Pass local context as a parameter
try (CloseableHttpResponse response = httpclient.execute(httpget, localContext)) {
System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
+ System.out.println(response.getCode() + " " + response.getReasonPhrase());
List<Cookie> cookies = cookieStore.getCookies();
for (int i = 0; i < cookies.size(); i++) {
System.out.println("Local cookie: " + cookies.get(i));
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomPublicSuffixList.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomPublicSuffixList.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomPublicSuffixList.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomPublicSuffixList.java Tue Dec 27 19:48:07 2016
@@ -33,15 +33,14 @@ import org.apache.hc.client5.http.cookie
import org.apache.hc.client5.http.impl.cookie.RFC6265CookieSpecProvider;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
import org.apache.hc.client5.http.psl.PublicSuffixMatcher;
import org.apache.hc.client5.http.psl.PublicSuffixMatcherLoader;
import org.apache.hc.client5.http.ssl.DefaultHostnameVerifier;
-import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.config.Lookup;
import org.apache.hc.core5.http.config.RegistryBuilder;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
/**
* This example demonstrates how to use a custom public suffix list.
@@ -74,13 +73,11 @@ public class ClientCustomPublicSuffixLis
HttpGet httpget = new HttpGet("https://httpbin.org/get");
- System.out.println("executing request " + httpget.getRequestLine());
+ System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
try (CloseableHttpResponse response = httpclient.execute(httpget)) {
- HttpEntity entity = response.getEntity();
-
System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
+ System.out.println(response.getCode() + " " + response.getReasonPhrase());
System.out.println(EntityUtils.toString(response.getEntity()));
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomSSL.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomSSL.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomSSL.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomSSL.java Tue Dec 27 19:48:07 2016
@@ -32,12 +32,11 @@ import javax.net.ssl.SSLContext;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.TrustSelfSignedStrategy;
-import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.ssl.SSLContexts;
/**
@@ -64,13 +63,11 @@ public class ClientCustomSSL {
HttpGet httpget = new HttpGet("https://httpbin.org/");
- System.out.println("Executing request " + httpget.getRequestLine());
+ System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
try (CloseableHttpResponse response = httpclient.execute(httpget)) {
- HttpEntity entity = response.getEntity();
-
System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
+ System.out.println(response.getCode() + " " + response.getReasonPhrase());
System.out.println(EntityUtils.toString(response.getEntity()));
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientEvictExpiredConnections.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientEvictExpiredConnections.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientEvictExpiredConnections.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientEvictExpiredConnections.java Tue Dec 27 19:48:07 2016
@@ -31,9 +31,9 @@ import java.util.concurrent.TimeUnit;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.pool.PoolStats;
/**
@@ -61,11 +61,11 @@ public class ClientEvictExpiredConnectio
String requestURI = urisToGet[i];
HttpGet request = new HttpGet(requestURI);
- System.out.println("Executing request " + requestURI);
+ System.out.println("Executing request " + request.getMethod() + " " + request.getRequestUri());
try (CloseableHttpResponse response = httpclient.execute(request)) {
System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
+ System.out.println(response.getCode() + " " + response.getReasonPhrase());
EntityUtils.consume(response.getEntity());
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteProxy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteProxy.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteProxy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteProxy.java Tue Dec 27 19:48:07 2016
@@ -30,10 +30,10 @@ package org.apache.hc.client5.http.examp
import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
/**
* How to send a request via proxy.
@@ -53,11 +53,12 @@ public class ClientExecuteProxy {
HttpGet request = new HttpGet("/get");
request.setConfig(config);
- System.out.println("Executing request " + request.getRequestLine() + " to " + target + " via " + proxy);
+ System.out.println("Executing request " + request.getMethod() + " " + request.getUri() +
+ " via " + proxy);
try (CloseableHttpResponse response = httpclient.execute(target, request)) {
System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
+ System.out.println(response.getCode() + " " + response.getReasonPhrase());
System.out.println(EntityUtils.toString(response.getEntity()));
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java Tue Dec 27 19:48:07 2016
@@ -37,14 +37,14 @@ import org.apache.hc.client5.http.Connec
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.socket.ConnectionSocketFactory;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.config.Registry;
import org.apache.hc.core5.http.config.RegistryBuilder;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.protocol.HttpContext;
/**
@@ -69,10 +69,11 @@ public class ClientExecuteSOCKS {
HttpHost target = new HttpHost("httpbin.org", 80, "http");
HttpGet request = new HttpGet("/get");
- System.out.println("Executing request " + request + " to " + target + " via SOCKS proxy " + socksaddr);
+ System.out.println("Executing request " + request.getMethod() + " " + request.getUri() +
+ " via SOCKS proxy " + socksaddr);
try (CloseableHttpResponse response = httpclient.execute(target, request, context)) {
System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
+ System.out.println(response.getCode() + " " + response.getReasonPhrase());
System.out.println(EntityUtils.toString(response.getEntity()));
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientFormLogin.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientFormLogin.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientFormLogin.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientFormLogin.java Tue Dec 27 19:48:07 2016
@@ -33,12 +33,12 @@ import org.apache.hc.client5.http.cookie
import org.apache.hc.client5.http.cookie.Cookie;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
import org.apache.hc.client5.http.methods.HttpUriRequest;
import org.apache.hc.client5.http.methods.RequestBuilder;
import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
/**
* A example that demonstrates how HttpClient APIs can be used to perform
@@ -55,7 +55,7 @@ public class ClientFormLogin {
try (CloseableHttpResponse response1 = httpclient.execute(httpget)) {
HttpEntity entity = response1.getEntity();
- System.out.println("Login form get: " + response1.getStatusLine());
+ System.out.println("Login form get: " + response1.getCode() + " " + response1.getReasonPhrase());
EntityUtils.consume(entity);
System.out.println("Initial set of cookies:");
@@ -77,7 +77,7 @@ public class ClientFormLogin {
try (CloseableHttpResponse response2 = httpclient.execute(login)) {
HttpEntity entity = response2.getEntity();
- System.out.println("Login form get: " + response2.getStatusLine());
+ System.out.println("Login form get: " + response2.getCode() + " " + response2.getReasonPhrase());
EntityUtils.consume(entity);
System.out.println("Post logon cookies:");
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientMultiThreadedExecution.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientMultiThreadedExecution.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientMultiThreadedExecution.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientMultiThreadedExecution.java Tue Dec 27 19:48:07 2016
@@ -29,10 +29,10 @@ package org.apache.hc.client5.http.examp
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.protocol.BasicHttpContext;
import org.apache.hc.core5.http.protocol.HttpContext;
@@ -102,7 +102,7 @@ public class ClientMultiThreadedExecutio
@Override
public void run() {
try {
- System.out.println(id + " - about to get something from " + httpget.getURI());
+ System.out.println(id + " - about to get something from " + httpget.getUri());
try (CloseableHttpResponse response = httpClient.execute(httpget, context)) {
System.out.println(id + " - get executed");
// get the response body as an array of bytes
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientMultipartFormPost.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientMultipartFormPost.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientMultipartFormPost.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientMultipartFormPost.java Tue Dec 27 19:48:07 2016
@@ -33,11 +33,11 @@ import org.apache.hc.client5.http.entity
import org.apache.hc.client5.http.entity.mime.StringBody;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpPost;
+import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.entity.ContentType;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
/**
* Example how to use multipart/form encoded POST request.
@@ -64,10 +64,10 @@ public class ClientMultipartFormPost {
httppost.setEntity(reqEntity);
- System.out.println("executing request " + httppost.getRequestLine());
+ System.out.println("executing request " + httppost);
try (CloseableHttpResponse response = httpclient.execute(httppost)) {
System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
+ System.out.println(response);
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
System.out.println("Response content length: " + resEntity.getContentLength());
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientPreemptiveBasicAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientPreemptiveBasicAuthentication.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientPreemptiveBasicAuthentication.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientPreemptiveBasicAuthentication.java Tue Dec 27 19:48:07 2016
@@ -30,11 +30,11 @@ import org.apache.hc.client5.http.auth.U
import org.apache.hc.client5.http.impl.auth.BasicScheme;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
/**
* An example of HttpClient can be customized to authenticate
@@ -61,11 +61,11 @@ public class ClientPreemptiveBasicAuthen
HttpGet httpget = new HttpGet("http://httpbin.org/hidden-basic-auth/user/passwd");
- System.out.println("Executing request " + httpget.getRequestLine() + " to target " + target);
+ System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
for (int i = 0; i < 3; i++) {
try (CloseableHttpResponse response = httpclient.execute(httpget, localContext)) {
System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
+ System.out.println(response.getCode() + " " + response.getReasonPhrase());
System.out.println(EntityUtils.toString(response.getEntity()));
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientPreemptiveDigestAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientPreemptiveDigestAuthentication.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientPreemptiveDigestAuthentication.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientPreemptiveDigestAuthentication.java Tue Dec 27 19:48:07 2016
@@ -32,11 +32,11 @@ import org.apache.hc.client5.http.impl.a
import org.apache.hc.client5.http.impl.auth.DigestScheme;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
/**
* An example of HttpClient can be customized to authenticate
@@ -68,11 +68,11 @@ public class ClientPreemptiveDigestAuthe
HttpGet httpget = new HttpGet("http://httpbin.org/digest-auth/auth/user/passwd");
- System.out.println("Executing request " + httpget.getRequestLine() + " to target " + target);
+ System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
for (int i = 0; i < 3; i++) {
try (CloseableHttpResponse response = httpclient.execute(target, httpget, localContext)) {
System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
+ System.out.println(response.getCode() + " " + response.getReasonPhrase());
EntityUtils.consume(response.getEntity());
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientProxyAuthentication.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientProxyAuthentication.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientProxyAuthentication.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientProxyAuthentication.java Tue Dec 27 19:48:07 2016
@@ -32,10 +32,10 @@ import org.apache.hc.client5.http.config
import org.apache.hc.client5.http.impl.sync.BasicCredentialsProvider;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
/**
* A simple example that uses HttpClient to execute an HTTP request
@@ -62,11 +62,12 @@ public class ClientProxyAuthentication {
HttpGet httpget = new HttpGet("/basic-auth/user/passwd");
httpget.setConfig(config);
- System.out.println("Executing request " + httpget.getRequestLine() + " to " + target + " via " + proxy);
+ System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri() +
+ " via " + proxy);
try (CloseableHttpResponse response = httpclient.execute(target, httpget)) {
System.out.println("----------------------------------------");
- System.out.println(response.getStatusLine());
+ System.out.println(response.getCode() + " " + response.getReasonPhrase());
System.out.println(EntityUtils.toString(response.getEntity()));
}
}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithRequestFuture.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithRequestFuture.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithRequestFuture.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithRequestFuture.java Tue Dec 27 19:48:07 2016
@@ -38,10 +38,10 @@ import org.apache.hc.client5.http.impl.s
import org.apache.hc.client5.http.impl.sync.HttpRequestFutureTask;
import org.apache.hc.client5.http.methods.HttpGet;
import org.apache.hc.client5.http.protocol.HttpClientContext;
-import org.apache.hc.client5.http.sync.ResponseHandler;
import org.apache.hc.core5.concurrent.FutureCallback;
-import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.io.ResponseHandler;
public class ClientWithRequestFuture {
@@ -56,9 +56,9 @@ public class ClientWithRequestFuture {
// Because things are asynchronous, you must provide a ResponseHandler
ResponseHandler<Boolean> handler = new ResponseHandler<Boolean>() {
@Override
- public Boolean handleResponse(HttpResponse response) throws IOException {
+ public Boolean handleResponse(ClassicHttpResponse response) throws IOException {
// simply return true if the status was OK
- return response.getStatusLine().getStatusCode() == HttpStatus.SC_OK;
+ return response.getCode() == HttpStatus.SC_OK;
}
};
@@ -115,4 +115,4 @@ public class ClientWithRequestFuture {
System.out.println("It was ok? " + wasItOk4);
}
}
-}
\ No newline at end of file
+}
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithResponseHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithResponseHandler.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithResponseHandler.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithResponseHandler.java Tue Dec 27 19:48:07 2016
@@ -33,11 +33,12 @@ import org.apache.hc.client5.http.impl.s
import org.apache.hc.client5.http.impl.sync.HttpClients;
import org.apache.hc.client5.http.methods.HttpGet;
import org.apache.hc.client5.http.protocol.ClientProtocolException;
-import org.apache.hc.client5.http.sync.ResponseHandler;
+import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HttpEntity;
-import org.apache.hc.core5.http.HttpResponse;
+import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.ParseException;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.ResponseHandler;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
/**
* This example demonstrates the use of the {@link ResponseHandler} to simplify
@@ -49,16 +50,16 @@ public class ClientWithResponseHandler {
try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
HttpGet httpget = new HttpGet("http://httpbin.org/get");
- System.out.println("Executing request " + httpget.getRequestLine());
+ System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
// Create a custom response handler
ResponseHandler<String> responseHandler = new ResponseHandler<String>() {
@Override
public String handleResponse(
- final HttpResponse response) throws IOException {
- int status = response.getStatusLine().getStatusCode();
- if (status >= 200 && status < 300) {
+ final ClassicHttpResponse response) throws IOException {
+ int status = response.getCode();
+ if (status >= HttpStatus.SC_SUCCESS && status < HttpStatus.SC_REDIRECTION) {
HttpEntity entity = response.getEntity();
try {
return entity != null ? EntityUtils.toString(entity) : null;
Modified: httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/QuickStart.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/QuickStart.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/QuickStart.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/examples/org/apache/hc/client5/http/examples/QuickStart.java Tue Dec 27 19:48:07 2016
@@ -32,12 +32,12 @@ import java.util.List;
import org.apache.hc.client5.http.entity.UrlEncodedFormEntity;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClients;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
+import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.methods.HttpGet;
import org.apache.hc.client5.http.methods.HttpPost;
import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.NameValuePair;
-import org.apache.hc.core5.http.entity.EntityUtils;
+import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.message.BasicNameValuePair;
public class QuickStart {
@@ -53,7 +53,7 @@ public class QuickStart {
// connection cannot be safely re-used and will be shut down and discarded
// by the connection manager.
try (CloseableHttpResponse response1 = httpclient.execute(httpGet)) {
- System.out.println(response1.getStatusLine());
+ System.out.println(response1.getCode() + " " + response1.getReasonPhrase());
HttpEntity entity1 = response1.getEntity();
// do something useful with the response body
// and ensure it is fully consumed
@@ -67,7 +67,7 @@ public class QuickStart {
httpPost.setEntity(new UrlEncodedFormEntity(nvps));
try (CloseableHttpResponse response2 = httpclient.execute(httpPost)) {
- System.out.println(response2.getStatusLine());
+ System.out.println(response2.getCode() + " " + response2.getReasonPhrase());
HttpEntity entity2 = response2.getEntity();
// do something useful with the response body
// and ensure it is fully consumed
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectTimeoutException.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectTimeoutException.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectTimeoutException.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectTimeoutException.java Tue Dec 27 19:48:07 2016
@@ -32,7 +32,6 @@ import java.io.InterruptedIOException;
import java.net.InetAddress;
import java.util.Arrays;
-import org.apache.hc.core5.annotation.Immutable;
import org.apache.hc.core5.http.HttpHost;
/**
@@ -42,7 +41,6 @@ import org.apache.hc.core5.http.HttpHost
*
* @since 4.0
*/
-@Immutable
public class ConnectTimeoutException extends InterruptedIOException {
private static final long serialVersionUID = -4816682903149535989L;
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectionPoolTimeoutException.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectionPoolTimeoutException.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectionPoolTimeoutException.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/ConnectionPoolTimeoutException.java Tue Dec 27 19:48:07 2016
@@ -27,8 +27,6 @@
package org.apache.hc.client5.http;
-import org.apache.hc.core5.annotation.Immutable;
-
/**
* A timeout while waiting for an available connection
* from a connection manager.
@@ -36,7 +34,6 @@ import org.apache.hc.core5.annotation.Im
*
* @since 4.0
*/
-@Immutable
public class ConnectionPoolTimeoutException extends ConnectTimeoutException {
private static final long serialVersionUID = -7898874842020245128L;
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/HttpHostConnectException.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/HttpHostConnectException.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/HttpHostConnectException.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/HttpHostConnectException.java Tue Dec 27 19:48:07 2016
@@ -31,7 +31,6 @@ import java.net.ConnectException;
import java.net.InetAddress;
import java.util.Arrays;
-import org.apache.hc.core5.annotation.Immutable;
import org.apache.hc.core5.http.HttpHost;
/**
@@ -40,7 +39,6 @@ import org.apache.hc.core5.http.HttpHost
*
* @since 4.0
*/
-@Immutable
public class HttpHostConnectException extends ConnectException {
private static final long serialVersionUID = -3194482710275220224L;
Modified: httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5/src/main/java/org/apache/hc/client5/http/HttpRoute.java Tue Dec 27 19:48:07 2016
@@ -34,7 +34,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import org.apache.hc.core5.annotation.Immutable;
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.LangUtils;
@@ -44,7 +45,7 @@ import org.apache.hc.core5.util.LangUtil
*
* @since 4.0
*/
-@Immutable
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
public final class HttpRoute implements RouteInfo, Cloneable {
/** The target host to connect to. */