You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2022/08/15 19:46:28 UTC

[juneau] branch jbFixRestNpe updated: PartList/HeaderList API improvements.

This is an automated email from the ASF dual-hosted git repository.

jamesbognar pushed a commit to branch jbFixRestNpe
in repository https://gitbox.apache.org/repos/asf/juneau.git


The following commit(s) were added to refs/heads/jbFixRestNpe by this push:
     new b9cd9fb8b PartList/HeaderList API improvements.
b9cd9fb8b is described below

commit b9cd9fb8b5bc9f4940dfdd7c9d4c8460cd24f9eb
Author: JamesBognar <ja...@salesforce.com>
AuthorDate: Mon Aug 15 15:45:30 2022 -0400

    PartList/HeaderList API improvements.
---
 .../java/org/apache/juneau/internal/IOUtils.java   | 29 ++++++++++
 juneau-doc/docs/Topics/12.juneau-rest-client.html  |  4 +-
 juneau-doc/src/main/javadoc/overview.html          |  4 +-
 .../juneau/examples/rest/SamplesMicroservice.java  |  2 +-
 .../apache/juneau/rest/test/TestMicroservice.java  |  2 +-
 .../org/apache/juneau/rest/client/RestClient.java  | 64 +++++++++++-----------
 .../java/org/apache/juneau/http/HttpEntities.java  | 16 +++---
 .../java/org/apache/juneau/http/HttpResources.java | 16 +++---
 .../{InputStreamEntity.java => StreamEntity.java}  | 18 +++---
 .../org/apache/juneau/http/header/HeaderList.java  | 14 ++++-
 .../java/org/apache/juneau/http/part/PartList.java | 14 ++++-
 .../apache/juneau/http/resource/BasicResource.java |  2 +-
 .../juneau/http/resource/ReaderResource.java       |  4 +-
 ...nputStreamResource.java => StreamResource.java} | 18 +++---
 .../juneau/http/resource/StringResource.java       |  4 +-
 .../apache/juneau/rest/mock/MockRestClient.java    |  6 +-
 .../juneau/http/SerializedHttpEntity_Test.java     |  2 +-
 .../org/apache/juneau/http/remote/Remote_Test.java |  8 +--
 .../client/RestClient_Config_RestClient_Test.java  |  4 +-
 19 files changed, 138 insertions(+), 93 deletions(-)

diff --git a/juneau-core/juneau-common/src/main/java/org/apache/juneau/internal/IOUtils.java b/juneau-core/juneau-common/src/main/java/org/apache/juneau/internal/IOUtils.java
index 3110b0183..09537ea45 100644
--- a/juneau-core/juneau-common/src/main/java/org/apache/juneau/internal/IOUtils.java
+++ b/juneau-core/juneau-common/src/main/java/org/apache/juneau/internal/IOUtils.java
@@ -409,6 +409,35 @@ public final class IOUtils {
 	// Reading utilities.
 	//-----------------------------------------------------------------------------------------------------------------
 
+	/**
+	 * Pipes the specified object to the specified output stream.
+	 *
+	 * @param in
+	 * 	The input byte array.
+	 * 	<br>Can be <jk>null</jk> or any of the following types:
+	 * 	<ul>
+	 * 		<li>{@link Reader}
+	 * 		<li>{@link InputStream}
+	 * 		<li>{@link File}
+	 * 		<li>byte array.
+	 * 	</ul>
+	 * @return The input converted to a string.
+	 * @throws IOException If thrown from output stream.
+	 */
+	public static String read(Object in) throws IOException {
+		if (in == null)
+			return null;
+		if (in instanceof Reader)
+			return read((Reader)in);
+		if (in instanceof InputStream)
+			return read((InputStream)in);
+		if (in instanceof File)
+			return read((File)in);
+		if (in instanceof byte[])
+			return read((byte[])in);
+		throw new RuntimeException("Invalid type passed to read:  " + in.getClass().getName());
+	}
+
 	/**
 	 * Reads the specified byte array containing UTF-8 into a string.
 	 *
diff --git a/juneau-doc/docs/Topics/12.juneau-rest-client.html b/juneau-doc/docs/Topics/12.juneau-rest-client.html
index cbb24575b..4086d4c10 100644
--- a/juneau-doc/docs/Topics/12.juneau-rest-client.html
+++ b/juneau-doc/docs/Topics/12.juneau-rest-client.html
@@ -114,13 +114,13 @@ specific language governing permissions and limitations under the License.
 	</p>
 	<p>
 		Clients are typically created with a root URI so that relative URIs can be used when making requests.
-		This is done using the {@link oajrc.RestClient.Builder#rootUri(Object)} method.
+		This is done using the {@link oajrc.RestClient.Builder#rootUrl(Object)} method.
 	</p>
 	
 	<h5 class='figure'>Example:</h5>
 	<p class='bjava'>
 		|	<jc>// Create a client where all URIs are relative to localhost.</jc>
-		|	RestClient <jv>client</jv> = RestClient.<jsm>create</jsm>().json().rootUri(<js>"http://localhost:10000"</js>).build();
+		|	RestClient <jv>client</jv> = RestClient.<jsm>create</jsm>().json().rootUrl(<js>"http://localhost:10000"</js>).build();
 		|
 		|	<jc>// Use relative paths.</jc>
 		|	String <jv>content</jv> = <jv>client</jv>.get(<js>"/subpath"</js>).run().getContent().asString();
diff --git a/juneau-doc/src/main/javadoc/overview.html b/juneau-doc/src/main/javadoc/overview.html
index a8457add7..a282d8d80 100644
--- a/juneau-doc/src/main/javadoc/overview.html
+++ b/juneau-doc/src/main/javadoc/overview.html
@@ -15818,7 +15818,7 @@
 			<ul class='javatreec'>
 				<li class='jc'>{@link org.apache.juneau.http.entity.ByteArrayEntity}
 				<li class='jc'>{@link org.apache.juneau.http.entity.FileEntity}
-				<li class='jc'>{@link org.apache.juneau.http.entity.InputStreamEntity}
+				<li class='jc'>{@link org.apache.juneau.http.entity.StreamEntity}
 				<li class='jc'>{@link org.apache.juneau.http.entity.ReaderEntity}
 				<li class='jc'>{@link org.apache.juneau.http.entity.SerializedEntity}
 				<li class='jc'>{@link org.apache.juneau.http.entity.StringEntity}
@@ -15884,7 +15884,7 @@
 				<ul class='javatreec'>
 					<li class='jc'>{@link org.apache.juneau.http.resource.ByteArrayResource}
 					<li class='jc'>{@link org.apache.juneau.http.resource.FileResource}
-					<li class='jc'>{@link org.apache.juneau.http.resource.InputStreamResource}
+					<li class='jc'>{@link org.apache.juneau.http.resource.StreamResource}
 					<li class='jc'>{@link org.apache.juneau.http.resource.ReaderResource}
 					<li class='jc'>{@link org.apache.juneau.http.resource.StringResource}
 				</ul>
diff --git a/juneau-examples/juneau-examples-rest-jetty-ftest/src/test/java/org/apache/juneau/examples/rest/SamplesMicroservice.java b/juneau-examples/juneau-examples-rest-jetty-ftest/src/test/java/org/apache/juneau/examples/rest/SamplesMicroservice.java
index 6e7ebb245..a5c816903 100644
--- a/juneau-examples/juneau-examples-rest-jetty-ftest/src/test/java/org/apache/juneau/examples/rest/SamplesMicroservice.java
+++ b/juneau-examples/juneau-examples-rest-jetty-ftest/src/test/java/org/apache/juneau/examples/rest/SamplesMicroservice.java
@@ -83,7 +83,7 @@ public class SamplesMicroservice {
 	 */
 	public static RestClient.Builder client() {
 		try {
-			return RestClient.create().rootUri(microserviceURI);
+			return RestClient.create().rootUrl(microserviceURI);
 		} catch (Exception e) {
 			throw new RuntimeException(e);
 		}
diff --git a/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/TestMicroservice.java b/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/TestMicroservice.java
index 640b02d2e..7d70096ac 100644
--- a/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/TestMicroservice.java
+++ b/juneau-microservice/juneau-microservice-ftest/src/test/java/org/apache/juneau/rest/test/TestMicroservice.java
@@ -104,7 +104,7 @@ public class TestMicroservice {
 			final StatusLine[] currentResponse = new StatusLine[1];
 			RestClient.Builder rc = RestClient.create()
 				.json()
-				.rootUri(microserviceURI)
+				.rootUrl(microserviceURI)
 				.noTrace();
 			rc.retryHandler(
 					new HttpRequestRetryHandler() {
diff --git a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
index 1740c8374..1cf51cc0e 100644
--- a/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
+++ b/juneau-rest/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java
@@ -170,12 +170,12 @@ import org.apache.juneau.xml.*;
  *
  * <p>
  * Clients are typically created with a root URI so that relative URIs can be used when making requests.
- * This is done using the {@link Builder#rootUri(Object)} method.
+ * This is done using the {@link Builder#rootUrl(Object)} method.
  *
  * <h5 class='figure'>Example:</h5>
  * <p class='bjava'>
  * 	<jc>// Create a client where all URIs are relative to localhost.</jc>
- * 	RestClient <jv>client</jv> = RestClient.<jsm>create</jsm>().json().rootUri(<js>"http://localhost:5000"</js>).build();
+ * 	RestClient <jv>client</jv> = RestClient.<jsm>create</jsm>().json().rootUrl(<js>"http://localhost:5000"</js>).build();
  *
  * 	<jc>// Use relative paths.</jc>
  * 	String <jv>body</jv> = <jv>client</jv>.get(<js>"/subpath"</js>).run().getContent().asString();
@@ -1011,7 +1011,7 @@ import org.apache.juneau.xml.*;
  *
  * 		<jd>/** Optionally override to customize requests when they're created (e.g. add headers to each request). </jd>
  * 		<ja>@Override</ja>
- * 		<jk>protected void</jk> request(RestOperation) {...}
+ * 		<jk>protected</jk> RestRequest request(RestOperation) {...}
  *
  * 		<jd>/** Optionally override to implement your own call handling. </jd>
  * 		<ja>@Override</ja>
@@ -1090,7 +1090,7 @@ public class RestClient extends BeanContextable implements HttpClient, Closeable
 
 		private boolean pooled;
 
-		String rootUri;
+		String rootUrl;
 		boolean skipEmptyHeaderData, skipEmptyFormData, skipEmptyQueryData, executorServiceShutdownOnClose, ignoreErrors, keepHttpClientOpen, detectLeaks,
 			logToConsole;
 		Logger logger;
@@ -3860,7 +3860,7 @@ public class RestClient extends BeanContextable implements HttpClient, Closeable
 		 * 	<jc>// Create a client that uses UON format by default for HTTP parts.</jc>
 		 * 	RestClient <jv>client</jv> = RestClient
 		 * 		.<jsm>create</jsm>()
-		 * 		.rootUri(<js>"http://localhost:10000/foo"</js>)
+		 * 		.rootUrl(<js>"http://localhost:10000/foo"</js>)
 		 * 		.build();
 		 *
 		 * 	Bar <jv>bar</jv> = <jv>client</jv>
@@ -3876,16 +3876,16 @@ public class RestClient extends BeanContextable implements HttpClient, Closeable
 		 * @return This object.
 		 */
 		@FluentSetter
-		public Builder rootUri(Object value) {
+		public Builder rootUrl(Object value) {
 			String s = stringify(value);
 			if (! isEmpty(s))
 				s = s.replaceAll("\\/$", "");
 			if (isEmpty(s))
-				rootUri = null;
+				rootUrl = null;
 			else if (s.indexOf("://") == -1)
-				throw new BasicRuntimeException("Invalid rootUri value: ''{0}''.  Must be a valid absolute URL.", value);
+				throw new BasicRuntimeException("Invalid rootUrl value: ''{0}''.  Must be a valid absolute URL.", value);
 			else
-				rootUri = s;
+				rootUrl = s;
 			return this;
 		}
 
@@ -3899,7 +3899,7 @@ public class RestClient extends BeanContextable implements HttpClient, Closeable
 		 * @return The root URI defined for this client.
 		 */
 		public String getRootUri() {
-			return rootUri;
+			return rootUrl;
 		}
 
 		/**
@@ -6325,7 +6325,7 @@ public class RestClient extends BeanContextable implements HttpClient, Closeable
 	final HttpPartSerializer partSerializer;
 	final HttpPartParser partParser;
 	private final RestCallHandler callHandler;
-	private final String rootUri;
+	private final String rootUrl;
 	private volatile boolean isClosed = false;
 	private final StackTraceElement[] creationStack;
 	private final Logger logger;
@@ -6375,7 +6375,7 @@ public class RestClient extends BeanContextable implements HttpClient, Closeable
 		skipEmptyHeaderData = builder.skipEmptyHeaderData;
 		skipEmptyQueryData = builder.skipEmptyQueryData;
 		skipEmptyFormData = builder.skipEmptyFormData;
-		rootUri = builder.rootUri;
+		rootUrl = builder.rootUrl;
 		errorCodes = builder.errorCodes;
 		connectionManager = builder.connectionManager;
 		console = builder.console != null ? builder.console : System.err;
@@ -7184,7 +7184,7 @@ public class RestClient extends BeanContextable implements HttpClient, Closeable
 			throw new RestCallException(null, null, "RestClient.close() has already been called.  This client cannot be reused.  Closed location stack trace can be displayed by setting the system property 'org.apache.juneau.rest.client2.RestClient.trackCreation' to true.");
 		}
 
-		RestRequest req = createRequest(toURI(op.getUri(), rootUri), op.getMethod(), op.hasContent());
+		RestRequest req = createRequest(toURI(op.getUri(), rootUrl), op.getMethod(), op.hasContent());
 
 		onCallInit(req);
 
@@ -7233,7 +7233,7 @@ public class RestClient extends BeanContextable implements HttpClient, Closeable
 	 * The URI to the REST interface is based on the following values:
 	 * <ul>
 	 * 	<li>The {@link Remote#path() @Remote(path)} annotation on the interface (<c>remote-path</c>).
-	 * 	<li>The {@link Builder#rootUri(Object) rootUri} on the client (<c>root-url</c>).
+	 * 	<li>The {@link Builder#rootUrl(Object) rootUrl} on the client (<c>root-url</c>).
 	 * 	<li>The fully-qualified class name of the interface (<c>class-name</c>).
 	 * </ul>
 	 *
@@ -7269,14 +7269,14 @@ public class RestClient extends BeanContextable implements HttpClient, Closeable
 	 * 	<jc>// Resolves to "http://hostname/resturi/myinterface2"</jc>
 	 * 	MyInterface2 <jv>interface2</jv> = RestClient
 	 * 		.<jsm>create</jsm>()
-	 * 		.rootUri(<js>"http://hostname/resturi"</js>)
+	 * 		.rootUrl(<js>"http://hostname/resturi"</js>)
 	 * 		.build()
 	 * 		.getRemote(MyInterface2.<jk>class</jk>);
 	 *
 	 * 	<jc>// Resolves to "http://hostname/resturi/org.apache.foo.MyInterface3"</jc>
 	 * 	MyInterface3 <jv>interface3</jv> = RestClient
 	 * 		.<jsm>create</jsm>()
-	 * 		.rootUri(<js>"http://hostname/resturi"</js>)
+	 * 		.rootUrl(<js>"http://hostname/resturi"</js>)
 	 * 		.build()
 	 * 		.getRemote(MyInterface3.<jk>class</jk>);
 	 * </p>
@@ -7309,11 +7309,11 @@ public class RestClient extends BeanContextable implements HttpClient, Closeable
 	 *
 	 * @param <T> The interface to create a proxy for.
 	 * @param interfaceClass The interface to create a proxy for.
-	 * @param rootUri The URI of the REST interface.
+	 * @param rootUrl The URI of the REST interface.
 	 * @return The new proxy interface.
 	 */
-	public <T> T getRemote(Class<T> interfaceClass, Object rootUri) {
-		return getRemote(interfaceClass, rootUri, null, null);
+	public <T> T getRemote(Class<T> interfaceClass, Object rootUrl) {
+		return getRemote(interfaceClass, rootUrl, null, null);
 	}
 
 	/**
@@ -7325,18 +7325,18 @@ public class RestClient extends BeanContextable implements HttpClient, Closeable
 
 	 * @param <T> The interface to create a proxy for.
 	 * @param interfaceClass The interface to create a proxy for.
-	 * @param rootUri The URI of the REST interface.
+	 * @param rootUrl The URI of the REST interface.
 	 * @param serializer The serializer used to serialize POJOs to the body of the HTTP request.
 	 * @param parser The parser used to parse POJOs from the body of the HTTP response.
 	 * @return The new proxy interface.
 	 */
 	@SuppressWarnings({ "unchecked" })
-	public <T> T getRemote(final Class<T> interfaceClass, Object rootUri, final Serializer serializer, final Parser parser) {
+	public <T> T getRemote(final Class<T> interfaceClass, Object rootUrl, final Serializer serializer, final Parser parser) {
 
-		if (rootUri == null)
-			rootUri = this.rootUri;
+		if (rootUrl == null)
+			rootUrl = this.rootUrl;
 
-		final String restUrl2 = trimSlashes(emptyIfNull(rootUri));
+		final String restUrl2 = trimSlashes(emptyIfNull(rootUrl));
 
 		return (T)Proxy.newProxyInstance(
 			interfaceClass.getClassLoader(),
@@ -7488,7 +7488,7 @@ public class RestClient extends BeanContextable implements HttpClient, Closeable
 	 * The URI to the REST interface is based on the following values:
 	 * <ul>
 	 * 	<li>The {@link Remote#path() @Remote(path)} annotation on the interface (<c>remote-path</c>).
-	 * 	<li>The {@link Builder#rootUri(Object) rootUri} on the client (<c>root-url</c>).
+	 * 	<li>The {@link Builder#rootUrl(Object) rootUrl} on the client (<c>root-url</c>).
 	 * 	<li>The fully-qualified class name of the interface (<c>class-name</c>).
 	 * </ul>
 	 *
@@ -7559,9 +7559,9 @@ public class RestClient extends BeanContextable implements HttpClient, Closeable
 			RrpcInterfaceMeta rm = new RrpcInterfaceMeta(interfaceClass, "");
 			String path = rm.getPath();
 			if (path.indexOf("://") == -1) {
-				if (isEmpty(rootUri))
+				if (isEmpty(rootUrl))
 					throw new RemoteMetadataException(interfaceClass, "Root URI has not been specified.  Cannot construct absolute path to remote interface.");
-				path = trimSlashes(rootUri) + '/' + path;
+				path = trimSlashes(rootUrl) + '/' + path;
 			}
 			uri = path;
 		}
@@ -8124,7 +8124,7 @@ public class RestClient extends BeanContextable implements HttpClient, Closeable
 
 	private Pattern absUrlPattern = Pattern.compile("^\\w+\\:\\/\\/.*");
 
-	URI toURI(Object x, String rootUri) throws RestCallException {
+	URI toURI(Object x, String rootUrl) throws RestCallException {
 		try {
 			if (x instanceof URI)
 				return (URI)x;
@@ -8133,11 +8133,11 @@ public class RestClient extends BeanContextable implements HttpClient, Closeable
 			if (x instanceof URIBuilder)
 				return ((URIBuilder)x).build();
 			String s = x == null ? "" : x.toString();
-			if (rootUri != null && ! absUrlPattern.matcher(s).matches()) {
+			if (rootUrl != null && ! absUrlPattern.matcher(s).matches()) {
 				if (s.isEmpty())
-					s = rootUri;
+					s = rootUrl;
 				else {
-					StringBuilder sb = new StringBuilder(rootUri);
+					StringBuilder sb = new StringBuilder(rootUrl);
 					if (! s.startsWith("/"))
 						sb.append('/');
 					sb.append(s);
@@ -8236,6 +8236,6 @@ public class RestClient extends BeanContextable implements HttpClient, Closeable
 			.append("partParser", partParser)
 			.append("partSerializer", partSerializer)
 			.append("queryData", queryData)
-			.append("rootUri", rootUri);
+			.append("rootUrl", rootUrl);
 	}
 }
diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/HttpEntities.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/HttpEntities.java
index a6c6dfc8f..c52895b5b 100644
--- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/HttpEntities.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/HttpEntities.java
@@ -188,28 +188,28 @@ public class HttpEntities {
 	}
 
 	/**
-	 * Creates a new {@link InputStreamEntity} builder.
+	 * Creates a new {@link StreamEntity} builder.
 	 *
 	 * <p>
 	 * Assumes no content type.
 	 *
 	 * @param content The entity content.  Can be <jk>null</jk>.
-	 * @return A new {@link InputStreamEntity} builder.
+	 * @return A new {@link StreamEntity} builder.
 	 */
-	public static final HttpEntityBuilder<InputStreamEntity> streamEntity(InputStream content) {
-		return InputStreamEntity.create().content(content);
+	public static final HttpEntityBuilder<StreamEntity> streamEntity(InputStream content) {
+		return StreamEntity.create().content(content);
 	}
 
 	/**
-	 * Creates a new {@link InputStreamEntity} builder.
+	 * Creates a new {@link StreamEntity} builder.
 	 *
 	 * @param content The entity content.  Can be <jk>null</jk>.
 	 * @param contentType The entity content type, or <jk>null</jk> if not specified.
 	 * @param length The content length, or <c>-1</c> if not known.
-	 * @return A new {@link InputStreamEntity} builder.
+	 * @return A new {@link StreamEntity} builder.
 	 */
-	public static final HttpEntityBuilder<InputStreamEntity> streamEntity(InputStream content, long length, ContentType contentType) {
-		return InputStreamEntity.create().content(content).contentLength(length).contentType(contentType);
+	public static final HttpEntityBuilder<StreamEntity> streamEntity(InputStream content, long length, ContentType contentType) {
+		return StreamEntity.create().content(content).contentLength(length).contentType(contentType);
 	}
 
 	/**
diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/HttpResources.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/HttpResources.java
index 90a47c5df..59789d335 100644
--- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/HttpResources.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/HttpResources.java
@@ -126,28 +126,28 @@ public class HttpResources {
 	}
 
 	/**
-	 * Creates a new {@link InputStreamResource} builder.
+	 * Creates a new {@link StreamResource} builder.
 	 *
 	 * <p>
 	 * Assumes no content type.
 	 *
 	 * @param content The entity content.  Can be <jk>null</jk>.
-	 * @return A new {@link InputStreamResource} builder.
+	 * @return A new {@link StreamResource} builder.
 	 */
-	public static final HttpResourceBuilder<InputStreamResource> streamResource(InputStream content) {
-		return InputStreamResource.create().content(content);
+	public static final HttpResourceBuilder<StreamResource> streamResource(InputStream content) {
+		return StreamResource.create().content(content);
 	}
 
 	/**
-	 * Creates a new {@link InputStreamResource} builder.
+	 * Creates a new {@link StreamResource} builder.
 	 *
 	 * @param content The entity content.  Can be <jk>null</jk>.
 	 * @param contentType The entity content type, or <jk>null</jk> if not specified.
 	 * @param length The content length, or <c>-1</c> if not known.
-	 * @return A new {@link InputStreamResource} builder.
+	 * @return A new {@link StreamResource} builder.
 	 */
-	public static final HttpResourceBuilder<InputStreamResource> streamResource(InputStream content, long length, ContentType contentType) {
-		return InputStreamResource.create().content(content).contentLength(length).contentType(contentType);
+	public static final HttpResourceBuilder<StreamResource> streamResource(InputStream content, long length, ContentType contentType) {
+		return StreamResource.create().content(content).contentLength(length).contentType(contentType);
 	}
 
 	/**
diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/entity/InputStreamEntity.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/entity/StreamEntity.java
similarity index 85%
rename from juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/entity/InputStreamEntity.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/entity/StreamEntity.java
index 2adef54dc..b6828847a 100644
--- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/entity/InputStreamEntity.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/entity/StreamEntity.java
@@ -25,19 +25,19 @@ import java.io.*;
  * 	<li class='extlink'>{@source}
  * </ul>
  */
-public class InputStreamEntity extends BasicHttpEntity {
+public class StreamEntity extends BasicHttpEntity {
 
 	private final InputStream content;
 	private final long maxLength;
 	private final byte[] cache;
 
 	/**
-	 * Creates a new {@link InputStreamEntity} builder.
+	 * Creates a new {@link StreamEntity} builder.
 	 *
-	 * @return A new {@link InputStreamEntity} builder.
+	 * @return A new {@link StreamEntity} builder.
 	 */
-	public static HttpEntityBuilder<InputStreamEntity> create() {
-		return new HttpEntityBuilder<>(InputStreamEntity.class);
+	public static HttpEntityBuilder<StreamEntity> create() {
+		return new HttpEntityBuilder<>(StreamEntity.class);
 	}
 
 	/**
@@ -46,7 +46,7 @@ public class InputStreamEntity extends BasicHttpEntity {
 	 * @param builder The entity builder.
 	 * @throws IOException If stream could not be read.
 	 */
-	public InputStreamEntity(HttpEntityBuilder<?> builder) throws IOException {
+	public StreamEntity(HttpEntityBuilder<?> builder) throws IOException {
 		super(builder);
 		content = contentOrElse(EMPTY_INPUT_STREAM);
 		cache = builder.cached ? readBytes(content) : null;
@@ -54,12 +54,12 @@ public class InputStreamEntity extends BasicHttpEntity {
 	}
 
 	/**
-	 * Creates a new {@link InputStreamEntity} builder initialized with the contents of this entity.
+	 * Creates a new {@link StreamEntity} builder initialized with the contents of this entity.
 	 *
-	 * @return A new {@link InputStreamEntity} builder initialized with the contents of this entity.
+	 * @return A new {@link StreamEntity} builder initialized with the contents of this entity.
 	 */
 	@Override /* BasicHttpEntity */
-	public HttpEntityBuilder<InputStreamEntity> copy() {
+	public HttpEntityBuilder<StreamEntity> copy() {
 		return new HttpEntityBuilder<>(this);
 	}
 
diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/HeaderList.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/HeaderList.java
index c26f008b4..6bfc7db6b 100644
--- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/HeaderList.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/header/HeaderList.java
@@ -1150,7 +1150,7 @@ public class HeaderList extends ControlledArrayList<Header>{
 	 * 	<br>Can be <jk>null</jk>.
 	 * 	<br><jk>null</jk> entries are ignored.
 	 */
-	protected HeaderList(boolean modifiable, List<Header> headers) {
+	public HeaderList(boolean modifiable, List<Header> headers) {
 		super(modifiable, headers);
 		caseSensitive = false;
 	}
@@ -1163,7 +1163,7 @@ public class HeaderList extends ControlledArrayList<Header>{
 	 * 	The headers to add to the list.
 	 * 	<br><jk>null</jk> entries are ignored.
 	 */
-	protected HeaderList(boolean modifiable, Header...headers) {
+	public HeaderList(boolean modifiable, Header...headers) {
 		super(modifiable, Arrays.asList(headers));
 		caseSensitive = false;
 	}
@@ -1173,11 +1173,19 @@ public class HeaderList extends ControlledArrayList<Header>{
 	 *
 	 * @param modifiable Whether this list should be modifiable.
 	 */
-	protected HeaderList(boolean modifiable) {
+	public HeaderList(boolean modifiable) {
 		super(modifiable);
 		caseSensitive = false;
 	}
 
+	/**
+	 * Default constructor.
+	 */
+	public HeaderList() {
+		super(true);
+		caseSensitive = false;
+	}
+
 	/**
 	 * Returns a builder initialized with the contents of this bean.
 	 *
diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/part/PartList.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/part/PartList.java
index db0300d93..6bb00b919 100644
--- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/part/PartList.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/part/PartList.java
@@ -1132,7 +1132,7 @@ public class PartList extends ControlledArrayList<NameValuePair> {
 	 * 	<br>Can be <jk>null</jk>.
 	 * 	<br><jk>null</jk> entries are ignored.
 	 */
-	protected PartList(boolean modifiable, List<NameValuePair> parts) {
+	public PartList(boolean modifiable, List<NameValuePair> parts) {
 		super(modifiable, parts);
 		caseInsensitive = false;
 	}
@@ -1145,7 +1145,7 @@ public class PartList extends ControlledArrayList<NameValuePair> {
 	 * 	The parts to add to the list.
 	 * 	<br><jk>null</jk> entries are ignored.
 	 */
-	protected PartList(boolean modifiable, NameValuePair...parts) {
+	public PartList(boolean modifiable, NameValuePair...parts) {
 		super(modifiable, Arrays.asList(parts));
 		caseInsensitive = false;
 	}
@@ -1155,11 +1155,19 @@ public class PartList extends ControlledArrayList<NameValuePair> {
 	 *
 	 * @param modifiable Whether this list should be modifiable.
 	 */
-	protected PartList(boolean modifiable) {
+	public PartList(boolean modifiable) {
 		super(modifiable);
 		caseInsensitive = false;
 	}
 
+	/**
+	 * Default constructor.
+	 */
+	public PartList() {
+		super(true);
+		caseInsensitive = false;
+	}
+
 	/**
 	 * Returns a builder initialized with the contents of this bean.
 	 *
diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/BasicResource.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/BasicResource.java
index bff2bfa2e..204335041 100644
--- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/BasicResource.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/BasicResource.java
@@ -78,7 +78,7 @@ public class BasicResource implements HttpResource {
 	 * @throws IOException Rethrown from {@link HttpEntity#getContent()}.
 	 */
 	public BasicResource(HttpResponse response) throws IOException {
-		this(create(null, InputStreamEntity.class).copyFrom(response));
+		this(create(null, StreamEntity.class).copyFrom(response));
 	}
 
 	/**
diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/ReaderResource.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/ReaderResource.java
index 60210e1e9..6499663f2 100644
--- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/ReaderResource.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/ReaderResource.java
@@ -26,9 +26,9 @@ import org.apache.juneau.http.entity.*;
 public class ReaderResource extends BasicResource {
 
 	/**
-	 * Creates a new {@link InputStreamResource} builder.
+	 * Creates a new {@link ReaderResource} builder.
 	 *
-	 * @return A new {@link InputStreamResource} builder.
+	 * @return A new {@link ReaderResource} builder.
 	 */
 	public static HttpResourceBuilder<ReaderResource> create() {
 		return new HttpResourceBuilder<>(ReaderResource.class, ReaderEntity.class);
diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/InputStreamResource.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/StreamResource.java
similarity index 76%
rename from juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/InputStreamResource.java
rename to juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/StreamResource.java
index 69fbce676..569894a89 100644
--- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/InputStreamResource.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/StreamResource.java
@@ -23,15 +23,15 @@ import org.apache.juneau.http.entity.*;
  * 	<li class='extlink'>{@source}
  * </ul>
  */
-public class InputStreamResource extends BasicResource {
+public class StreamResource extends BasicResource {
 
 	/**
-	 * Creates a new {@link InputStreamResource} builder.
+	 * Creates a new {@link StreamResource} builder.
 	 *
-	 * @return A new {@link InputStreamResource} builder.
+	 * @return A new {@link StreamResource} builder.
 	 */
-	public static HttpResourceBuilder<InputStreamResource> create() {
-		return new HttpResourceBuilder<>(InputStreamResource.class, InputStreamEntity.class);
+	public static HttpResourceBuilder<StreamResource> create() {
+		return new HttpResourceBuilder<>(StreamResource.class, StreamEntity.class);
 	}
 
 	/**
@@ -39,17 +39,17 @@ public class InputStreamResource extends BasicResource {
 	 *
 	 * @param builder The resource builder.
 	 */
-	public InputStreamResource(HttpResourceBuilder<?> builder) {
+	public StreamResource(HttpResourceBuilder<?> builder) {
 		super(builder);
 	}
 
 	/**
-	 * Creates a new {@link InputStreamResource} builder initialized with the contents of this entity.
+	 * Creates a new {@link StreamResource} builder initialized with the contents of this entity.
 	 *
-	 * @return A new {@link InputStreamResource} builder initialized with the contents of this entity.
+	 * @return A new {@link StreamResource} builder initialized with the contents of this entity.
 	 */
 	@Override /* BasicResource */
-	public HttpResourceBuilder<InputStreamResource> copy() {
+	public HttpResourceBuilder<StreamResource> copy() {
 		return new HttpResourceBuilder<>(this);
 	}
 }
diff --git a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/StringResource.java b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/StringResource.java
index b86c88129..582df4757 100644
--- a/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/StringResource.java
+++ b/juneau-rest/juneau-rest-common/src/main/java/org/apache/juneau/http/resource/StringResource.java
@@ -25,9 +25,9 @@ import org.apache.juneau.http.entity.*;
 public class StringResource extends BasicResource {
 
 	/**
-	 * Creates a new {@link InputStreamResource} builder.
+	 * Creates a new {@link StringResource} builder.
 	 *
-	 * @return A new {@link InputStreamResource} builder.
+	 * @return A new {@link StringResource} builder.
 	 */
 	public static HttpResourceBuilder<StringResource> create() {
 		return new HttpResourceBuilder<>(StringResource.class, StringEntity.class);
diff --git a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockRestClient.java b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockRestClient.java
index bf9c24c61..45678faaf 100644
--- a/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockRestClient.java
+++ b/juneau-rest/juneau-rest-mock/src/main/java/org/apache/juneau/rest/mock/MockRestClient.java
@@ -1597,8 +1597,8 @@ public class MockRestClient extends RestClient implements HttpClientConnection {
 		}
 
 		@Override /* GENERATED - org.apache.juneau.rest.client.RestClient.Builder */
-		public Builder rootUri(Object value) {
-			super.rootUri(value);
+		public Builder rootUrl(Object value) {
+			super.rootUrl(value);
 			return this;
 		}
 
@@ -1887,7 +1887,7 @@ public class MockRestClient extends RestClient implements HttpClientConnection {
 			rootUrl = rootUrl + emptyIfNull(contextPath) + emptyIfNull(servletPath);
 
 			builder.servletPath = servletPath;
-			builder.rootUri(rootUrl);
+			builder.rootUrl(rootUrl);
 			return builder;
 		} catch (Exception e) {
 			throw new ConfigException(e, "Could not initialize MockRestClient");
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/SerializedHttpEntity_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/SerializedHttpEntity_Test.java
index ff3e61c4f..9f5f39588 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/SerializedHttpEntity_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/http/SerializedHttpEntity_Test.java
@@ -118,6 +118,6 @@ public class SerializedHttpEntity_Test {
 	}
 
 	private RestClient checkHeaderClient(String header) {
-		return MockRestClient.create(A.class).rootUri("http://localhost/checkHeader").simpleJson().header("Check",header).ignoreErrors().build();
+		return MockRestClient.create(A.class).rootUrl("http://localhost/checkHeader").simpleJson().header("Check",header).ignoreErrors().build();
 	}
 }
diff --git a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_Test.java b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_Test.java
index 2f2655e8d..aae253a64 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/http/remote/Remote_Test.java
@@ -475,7 +475,7 @@ public class Remote_Test {
 
 	@Test
 	public void e01_rrpcBasic() throws Exception {
-		E1 x = client(E.class).rootUri("http://localhost/proxy").build().getRrpcInterface(E1.class);
+		E1 x = client(E.class).rootUrl("http://localhost/proxy").build().getRrpcInterface(E1.class);
 
 		assertEquals("foo",x.echo("foo"));
 	}
@@ -487,7 +487,7 @@ public class Remote_Test {
 
 	@Test
 	public void e03_rrpc_noRestUrl() throws Exception {
-		E3 x = client(E.class).rootUri("http://localhost").build().getRrpcInterface(E3.class);
+		E3 x = client(E.class).rootUrl("http://localhost").build().getRrpcInterface(E3.class);
 		assertEquals("foo",x.echo("foo"));
 	}
 
@@ -498,7 +498,7 @@ public class Remote_Test {
 
 	@Test
 	public void e04_rrpc_fullPathOnRemotePath() throws Exception {
-		E4 x = client(E.class).rootUri("").build().getRrpcInterface(E4.class);
+		E4 x = client(E.class).rootUrl("").build().getRrpcInterface(E4.class);
 		assertEquals("foo",x.echo("foo"));
 	}
 
@@ -742,6 +742,6 @@ public class Remote_Test {
 	}
 
 	private static <T> T plainRemote(Class<?> c, Class<T> r, String rootUrl) {
-		return MockRestClient.create(c).rootUri(rootUrl).build().getRemote(r);
+		return MockRestClient.create(c).rootUrl(rootUrl).build().getRemote(r);
 	}
 }
diff --git a/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Config_RestClient_Test.java b/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Config_RestClient_Test.java
index 83a65f6b7..f0e4c288d 100644
--- a/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Config_RestClient_Test.java
+++ b/juneau-utest/src/test/java/org/apache/juneau/rest/client/RestClient_Config_RestClient_Test.java
@@ -476,8 +476,8 @@ public class RestClient_Config_RestClient_Test {
 
 	@Test
 	public void a13_toString() throws Exception {
-		String s = client().rootUri("https://foo").build().toString();
-		assertTrue(s.contains("rootUri: 'https://foo'"));
+		String s = client().rootUrl("https://foo").build().toString();
+		assertTrue(s.contains("rootUrl: 'https://foo'"));
 	}
 
 	@Test