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 2018/08/01 19:41:32 UTC

[juneau] branch master updated: Allow HttpResponse messages to be overridden.

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

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


The following commit(s) were added to refs/heads/master by this push:
     new adb3d10  Allow HttpResponse messages to be overridden.
adb3d10 is described below

commit adb3d10d36e9094769a39dac0973e14d361aed2c
Author: JamesBognar <ja...@apache.org>
AuthorDate: Wed Aug 1 15:41:17 2018 -0400

    Allow HttpResponse messages to be overridden.
---
 .../org/apache/juneau/rest/response/Accepted.java  | 18 ++++++++++++----
 .../juneau/rest/response/AlreadyReported.java      | 18 ++++++++++++----
 .../org/apache/juneau/rest/response/Continue.java  | 18 ++++++++++++----
 .../org/apache/juneau/rest/response/Created.java   | 18 ++++++++++++----
 .../apache/juneau/rest/response/EarlyHints.java    | 18 ++++++++++++----
 .../org/apache/juneau/rest/response/Found.java     | 22 +++++++++++--------
 .../response/{Created.java => HttpResponse.java}   | 25 +++++++++++++---------
 .../org/apache/juneau/rest/response/IMUsed.java    | 18 ++++++++++++----
 .../juneau/rest/response/MovedPermanently.java     | 23 ++++++++------------
 .../apache/juneau/rest/response/MultiStatus.java   | 18 ++++++++++++----
 .../juneau/rest/response/MultipleChoices.java      | 18 ++++++++++++----
 .../org/apache/juneau/rest/response/NoContent.java | 18 ++++++++++++----
 .../rest/response/NonAuthoritiveInformation.java   | 18 ++++++++++++----
 .../apache/juneau/rest/response/NotModified.java   | 18 ++++++++++++----
 .../java/org/apache/juneau/rest/response/Ok.java   | 18 ++++++++++++----
 .../juneau/rest/response/PartialContent.java       | 18 ++++++++++++----
 .../juneau/rest/response/PermanentRedirect.java    | 23 ++++++++------------
 .../apache/juneau/rest/response/Processing.java    | 18 ++++++++++++----
 .../apache/juneau/rest/response/ResetContent.java  | 18 ++++++++++++----
 .../org/apache/juneau/rest/response/SeeOther.java  | 23 ++++++++------------
 .../juneau/rest/response/SwitchingProtocols.java   | 18 ++++++++++++----
 .../juneau/rest/response/TemporaryRedirect.java    | 24 ++++++++-------------
 .../org/apache/juneau/rest/response/UseProxy.java  | 18 ++++++++++++----
 .../org/apache/juneau/rest/response/BasicTest.java | 10 +++++----
 24 files changed, 308 insertions(+), 148 deletions(-)

diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Accepted.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Accepted.java
index 5e391d7..a3d58a7 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Accepted.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Accepted.java
@@ -22,13 +22,23 @@ import org.apache.juneau.http.annotation.*;
  * The request might or might not be eventually acted upon, and may be disallowed when processing occurs.
  */
 @Response(code=202, example="'Accepted'")
-public class Accepted {
+public class Accepted extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final Accepted INSTANCE = new Accepted();
 
-	@Override /* Object */
-	public String toString() {
-		return "Accepted";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public Accepted() {
+		this("Accepted");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public Accepted(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/AlreadyReported.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/AlreadyReported.java
index 9168864..304ab43 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/AlreadyReported.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/AlreadyReported.java
@@ -21,13 +21,23 @@ import org.apache.juneau.http.annotation.*;
  * The members of a DAV binding have already been enumerated in a preceding part of the (multistatus) response, and are not being included again.
  */
 @Response(code=208, example="'Already Reported'")
-public class AlreadyReported {
+public class AlreadyReported extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final AlreadyReported INSTANCE = new AlreadyReported();
 
-	@Override /* Object */
-	public String toString() {
-		return "Already Reported";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public AlreadyReported() {
+		this("Already Reported");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public AlreadyReported(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Continue.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Continue.java
index 9297d10..6e0e1bf 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Continue.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Continue.java
@@ -25,13 +25,23 @@ import org.apache.juneau.http.annotation.*;
  * The response 417 Expectation Failed indicates that the request should be repeated without the Expect header as it indicates that the server doesn't support expectations (this is the case, for example, of HTTP/1.0 servers).
  */
 @Response(code=100, example="'Continue'")
-public class Continue {
+public class Continue extends HttpResponse {
 
 	/** Reusable instance.*/
 	public static final Continue INSTANCE = new Continue();
 
-	@Override /* Object */
-	public String toString() {
-		return "Continue";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public Continue() {
+		this("Continue");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public Continue(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Created.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Created.java
index 44b2c40..f45ff71 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Created.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Created.java
@@ -21,13 +21,23 @@ import org.apache.juneau.http.annotation.*;
  * The request has been fulfilled, resulting in the creation of a new resource.
  */
 @Response(code=201, example="'Created'")
-public class Created {
+public class Created extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final Created INSTANCE = new Created();
 
-	@Override /* Object */
-	public String toString() {
-		return "Created";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public Created() {
+		this("Created");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public Created(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/EarlyHints.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/EarlyHints.java
index 80ff48f..5b9c860 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/EarlyHints.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/EarlyHints.java
@@ -21,13 +21,23 @@ import org.apache.juneau.http.annotation.*;
  * Used to return some response headers before final HTTP message.
  */
 @Response(code=103, example="'Early Hints'")
-public class EarlyHints {
+public class EarlyHints extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final EarlyHints INSTANCE = new EarlyHints();
 
-	@Override /* Object */
-	public String toString() {
-		return "Early Hints";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public EarlyHints() {
+		this("Early Hints");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public EarlyHints(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Found.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Found.java
index e9aa7f6..3f6a82c 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Found.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Found.java
@@ -27,7 +27,7 @@ import org.apache.juneau.http.annotation.*;
  * However, some Web applications and frameworks use the 302 status code as if it were the 303.
  */
 @Response(code=302, example="'Found'")
-public class Found {
+public class Found extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final Found INSTANCE = new Found();
@@ -35,24 +35,28 @@ public class Found {
 	private final URI location;
 
 	/**
-	 * Constructor.
+	 * Constructor using HTTP-standard message.
 	 */
 	public Found() {
-		this(null);
+		this("Found", null);
 	}
 
 	/**
-	 * Constructor.
-	 *
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
 	 * @param location <code>Location</code> header value.
 	 */
-	public Found(URI location) {
+	public Found(String message, URI location) {
+		super(message);
 		this.location = location;
 	}
 
-	@Override /* Object */
-	public String toString() {
-		return "Found";
+	/**
+	 * Constructor.
+	 * @param location <code>Location</code> header value.
+	 */
+	public Found(URI location) {
+		this("Found", location);
 	}
 
 	/**
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Created.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/HttpResponse.java
similarity index 82%
copy from juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Created.java
copy to juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/HttpResponse.java
index 44b2c40..59c0814 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Created.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/HttpResponse.java
@@ -12,22 +12,27 @@
 // ***************************************************************************************************************************
 package org.apache.juneau.rest.response;
 
-import org.apache.juneau.http.annotation.*;
-
 /**
- * Represents an <code>HTTP 201 Created</code> response.
+ * Superclass of all predefined responses in this package.
  *
  * <p>
- * The request has been fulfilled, resulting in the creation of a new resource.
+ * Consists simply of a simple string message.
  */
-@Response(code=201, example="'Created'")
-public class Created {
+public abstract class HttpResponse {
+
+	private final String message;
 
-	/** Reusable instance. */
-	public static final Created INSTANCE = new Created();
+	/**
+	 * Constructor.
+	 *
+	 * @param message Message to send as the response.
+	 */
+	protected HttpResponse(String message) {
+		this.message = message;
+	}
 
 	@Override /* Object */
 	public String toString() {
-		return "Created";
+		return message;
 	}
-}
\ No newline at end of file
+}
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/IMUsed.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/IMUsed.java
index 6ea392c..8ce2475 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/IMUsed.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/IMUsed.java
@@ -21,13 +21,23 @@ import org.apache.juneau.http.annotation.*;
  * The server has fulfilled a request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance.
  */
 @Response(code=226, example="'IM Used'")
-public class IMUsed {
+public class IMUsed extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final IMUsed INSTANCE = new IMUsed();
 
-	@Override /* Object */
-	public String toString() {
-		return "IM Used";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public IMUsed() {
+		this("IM Used");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public IMUsed(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/MovedPermanently.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/MovedPermanently.java
index 441e5f1..c03a363 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/MovedPermanently.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/MovedPermanently.java
@@ -23,7 +23,7 @@ import org.apache.juneau.http.annotation.*;
  * This and all future requests should be directed to the given URI.
  */
 @Response(code=301, example="'Moved Permanently'")
-public class MovedPermanently {
+public class MovedPermanently extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final MovedPermanently INSTANCE = new MovedPermanently();
@@ -31,33 +31,28 @@ public class MovedPermanently {
 	private final URI location;
 
 	/**
-	 * Constructor.
+	 * Constructor using HTTP-standard message.
 	 */
 	public MovedPermanently() {
-		this((URI)null);
+		this("Moved Permanently", null);
 	}
 
 	/**
-	 * Constructor.
-	 *
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
 	 * @param location <code>Location</code> header value.
 	 */
-	public MovedPermanently(URI location) {
+	public MovedPermanently(String message, URI location) {
+		super(message);
 		this.location = location;
 	}
 
 	/**
 	 * Constructor.
-	 *
 	 * @param location <code>Location</code> header value.
 	 */
-	public MovedPermanently(String location) {
-		this.location = URI.create(location);
-	}
-
-	@Override /* Object */
-	public String toString() {
-		return "Moved Permanently";
+	public MovedPermanently(URI location) {
+		this("Moved Permanently", location);
 	}
 
 	/**
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/MultiStatus.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/MultiStatus.java
index 284506e..ab69efb 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/MultiStatus.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/MultiStatus.java
@@ -21,13 +21,23 @@ import org.apache.juneau.http.annotation.*;
  * The message body that follows is by default an XML message and can contain a number of separate response codes, depending on how many sub-requests were made.
  */
 @Response(code=207, example="'Multi-Status'")
-public class MultiStatus {
+public class MultiStatus extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final MultiStatus INSTANCE = new MultiStatus();
 
-	@Override /* Object */
-	public String toString() {
-		return "Multi-Status";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public MultiStatus() {
+		this("Multi-Status");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public MultiStatus(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/MultipleChoices.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/MultipleChoices.java
index b005d57..05abe67 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/MultipleChoices.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/MultipleChoices.java
@@ -22,13 +22,23 @@ import org.apache.juneau.http.annotation.*;
  * For example, this code could be used to present multiple video format options, to list files with different filename extensions, or to suggest word-sense disambiguation.
  */
 @Response(code=300, example="'Multiple Choices'")
-public class MultipleChoices {
+public class MultipleChoices extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final MultipleChoices INSTANCE = new MultipleChoices();
 
-	@Override /* Object */
-	public String toString() {
-		return "Multiple Choices";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public MultipleChoices() {
+		this("Multiple Choices");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public MultipleChoices(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/NoContent.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/NoContent.java
index 9b933ca..2fc9608 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/NoContent.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/NoContent.java
@@ -21,13 +21,23 @@ import org.apache.juneau.http.annotation.*;
  * The server successfully processed the request and is not returning any content.
  */
 @Response(code=204, example="'No Content'")
-public class NoContent {
+public class NoContent extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final NoContent INSTANCE = new NoContent();
 
-	@Override /* Object */
-	public String toString() {
-		return "No Content";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public NoContent() {
+		this("No Content");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public NoContent(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/NonAuthoritiveInformation.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/NonAuthoritiveInformation.java
index 9448483..0e5bbe1 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/NonAuthoritiveInformation.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/NonAuthoritiveInformation.java
@@ -21,13 +21,23 @@ import org.apache.juneau.http.annotation.*;
  * The server is a transforming proxy (e.g. a Web accelerator) that received a 200 OK from its origin, but is returning a modified version of the origin's response.
  */
 @Response(code=203, example="'Non-Authoritative Information'")
-public class NonAuthoritiveInformation {
+public class NonAuthoritiveInformation extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final NonAuthoritiveInformation INSTANCE = new NonAuthoritiveInformation();
 
-	@Override /* Object */
-	public String toString() {
-		return "Non-Authoritative Information";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public NonAuthoritiveInformation() {
+		this("Non-Authoritative Information");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public NonAuthoritiveInformation(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/NotModified.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/NotModified.java
index 4cb078d..847c17b 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/NotModified.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/NotModified.java
@@ -22,13 +22,23 @@ import org.apache.juneau.http.annotation.*;
  * In such case, there is no need to retransmit the resource since the client still has a previously-downloaded copy.
  */
 @Response(code=304, example="'Not Modified'")
-public class NotModified {
+public class NotModified extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final NotModified INSTANCE = new NotModified();
 
-	@Override /* Object */
-	public String toString() {
-		return "Not Modified";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public NotModified() {
+		this("Not Modified");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public NotModified(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Ok.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Ok.java
index fc486b9..a60bdeb 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Ok.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Ok.java
@@ -23,15 +23,25 @@ import org.apache.juneau.http.annotation.*;
  * In a POST request, the response will contain an entity describing or containing the result of the action.
  */
 @Response(code=200, example="'OK'")
-public class Ok {
+public class Ok extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final Ok INSTANCE = new Ok();
 	/** Reusable instance. */
 	public static final Ok OK = new Ok();
 
-	@Override /* Object */
-	public String toString() {
-		return "OK";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public Ok() {
+		this("OK");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public Ok(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/PartialContent.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/PartialContent.java
index d5cdead..1e28bd8 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/PartialContent.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/PartialContent.java
@@ -22,13 +22,23 @@ import org.apache.juneau.http.annotation.*;
  * The range header is used by HTTP clients to enable resuming of interrupted downloads, or split a download into multiple simultaneous streams.
  */
 @Response(code=206, example="'Partial Content'")
-public class PartialContent {
+public class PartialContent extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final PartialContent INSTANCE = new PartialContent();
 
-	@Override /* Object */
-	public String toString() {
-		return "Partial Content";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public PartialContent() {
+		this("Partial Content");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public PartialContent(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/PermanentRedirect.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/PermanentRedirect.java
index 7f4d883..cbcc5fd 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/PermanentRedirect.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/PermanentRedirect.java
@@ -24,7 +24,7 @@ import org.apache.juneau.http.annotation.*;
  * So, for example, submitting a form to a permanently redirected resource may continue smoothly.
  */
 @Response(code=308, example="'Permanent Redirect'")
-public class PermanentRedirect {
+public class PermanentRedirect extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final PermanentRedirect INSTANCE = new PermanentRedirect();
@@ -32,33 +32,28 @@ public class PermanentRedirect {
 	private final URI location;
 
 	/**
-	 * Constructor.
+	 * Constructor using HTTP-standard message.
 	 */
 	public PermanentRedirect() {
-		this((URI)null);
+		this("Permanent Redirect", null);
 	}
 
 	/**
-	 * Constructor.
-	 *
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
 	 * @param location <code>Location</code> header value.
 	 */
-	public PermanentRedirect(String location) {
-		this.location = URI.create(location);
+	public PermanentRedirect(String message, URI location) {
+		super(message);
+		this.location = location;
 	}
 
 	/**
 	 * Constructor.
-	 *
 	 * @param location <code>Location</code> header value.
 	 */
 	public PermanentRedirect(URI location) {
-		this.location = location;
-	}
-
-	@Override /* Object */
-	public String toString() {
-		return "Permanent Redirect";
+		this("Permanent Redirect", location);
 	}
 
 	/**
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Processing.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Processing.java
index 3156368..127d960 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Processing.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/Processing.java
@@ -23,13 +23,23 @@ import org.apache.juneau.http.annotation.*;
  * This prevents the client from timing out and assuming the request was lost.
  */
 @Response(code=102, example="'Processing'")
-public class Processing {
+public class Processing extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final Processing INSTANCE = new Processing();
 
-	@Override /* Object */
-	public String toString() {
-		return "Processing";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public Processing() {
+		this("Processing");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public Processing(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/ResetContent.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/ResetContent.java
index 532137f..dab15b9 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/ResetContent.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/ResetContent.java
@@ -22,13 +22,23 @@ import org.apache.juneau.http.annotation.*;
  * Unlike a 204 response, this response requires that the requester reset the document view.
  */
 @Response(code=205, example="'Reset Content'")
-public class ResetContent {
+public class ResetContent extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final ResetContent INSTANCE = new ResetContent();
 
-	@Override /* Object */
-	public String toString() {
-		return "Reset Content";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public ResetContent() {
+		this("Reset Content");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public ResetContent(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/SeeOther.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/SeeOther.java
index 4d9d903..dcd6ff6 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/SeeOther.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/SeeOther.java
@@ -24,7 +24,7 @@ import org.apache.juneau.http.annotation.*;
  * When received in response to a POST (or PUT/DELETE), the client should presume that the server has received the data and should issue a new GET request to the given URI.
  */
 @Response(code=303, example="'See Other'")
-public class SeeOther {
+public class SeeOther extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final SeeOther INSTANCE = new SeeOther();
@@ -32,33 +32,28 @@ public class SeeOther {
 	private final URI location;
 
 	/**
-	 * Constructor.
+	 * Constructor using HTTP-standard message.
 	 */
 	public SeeOther() {
-		this((URI)null);
+		this("See Other", null);
 	}
 
 	/**
-	 * Constructor.
-	 *
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
 	 * @param location <code>Location</code> header value.
 	 */
-	public SeeOther(String location) {
-		this.location = URI.create(location);
+	public SeeOther(String message, URI location) {
+		super(message);
+		this.location = location;
 	}
 
 	/**
 	 * Constructor.
-	 *
 	 * @param location <code>Location</code> header value.
 	 */
 	public SeeOther(URI location) {
-		this.location = location;
-	}
-
-	@Override /* Object */
-	public String toString() {
-		return "See Other";
+		this("See Other", location);
 	}
 
 	/**
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/SwitchingProtocols.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/SwitchingProtocols.java
index 21c62e0..3f10922 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/SwitchingProtocols.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/SwitchingProtocols.java
@@ -21,13 +21,23 @@ import org.apache.juneau.http.annotation.*;
  * The requester has asked the server to switch protocols and the server has agreed to do so.
  */
 @Response(code=101, example="'Switching Protocols'")
-public class SwitchingProtocols {
+public class SwitchingProtocols extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final SwitchingProtocols INSTANCE = new SwitchingProtocols();
 
-	@Override /* Object */
-	public String toString() {
-		return "Switching Protocols";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public SwitchingProtocols() {
+		this("Switching Protocols");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public SwitchingProtocols(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/TemporaryRedirect.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/TemporaryRedirect.java
index 00037ba..fe6811d 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/TemporaryRedirect.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/TemporaryRedirect.java
@@ -25,7 +25,7 @@ import org.apache.juneau.http.annotation.*;
  * For example, a POST request should be repeated using another POST request.
  */
 @Response(code=307, example="'Temporary Redirect'")
-public class TemporaryRedirect {
+public class TemporaryRedirect extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final TemporaryRedirect INSTANCE = new TemporaryRedirect();
@@ -33,36 +33,30 @@ public class TemporaryRedirect {
 	private final URI location;
 
 	/**
-	 * Constructor.
+	 * Constructor using HTTP-standard message.
 	 */
 	public TemporaryRedirect() {
-		this((URI)null);
+		this("Temporary Redirect", null);
 	}
 
 	/**
-	 * Constructor.
-	 *
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
 	 * @param location <code>Location</code> header value.
 	 */
-	public TemporaryRedirect(String location) {
-		this.location = URI.create(location);
+	public TemporaryRedirect(String message, URI location) {
+		super(message);
+		this.location = location;
 	}
 
 	/**
 	 * Constructor.
-	 *
 	 * @param location <code>Location</code> header value.
 	 */
 	public TemporaryRedirect(URI location) {
-		this.location = location;
+		this("Temporary Redirect", location);
 	}
 
-	@Override /* Object */
-	public String toString() {
-		return "Temporary Redirect";
-	}
-
-
 	/**
 	 * @return <code>Location</code> header value.
 	 */
diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/UseProxy.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/UseProxy.java
index 19fb9ea..9f66724 100644
--- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/UseProxy.java
+++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/response/UseProxy.java
@@ -22,13 +22,23 @@ import org.apache.juneau.http.annotation.*;
  * Many HTTP clients (such as Mozilla and Internet Explorer) do not correctly handle responses with this status code, primarily for security reasons.
  */
 @Response(code=305, example="'Use Proxy'")
-public class UseProxy {
+public class UseProxy extends HttpResponse {
 
 	/** Reusable instance. */
 	public static final UseProxy INSTANCE = new UseProxy();
 
-	@Override /* Object */
-	public String toString() {
-		return "Use Proxy";
+	/**
+	 * Constructor using HTTP-standard message.
+	 */
+	public UseProxy() {
+		this("Use Proxy");
+	}
+
+	/**
+	 * Constructor using custom message.
+	 * @param message Message to send as the response.
+	 */
+	public UseProxy(String message) {
+		super(message);
 	}
 }
\ No newline at end of file
diff --git a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/response/BasicTest.java b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/response/BasicTest.java
index cbe5d74..376ba4f 100644
--- a/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/response/BasicTest.java
+++ b/juneau-rest/juneau-rest-server/src/test/java/org/apache/juneau/rest/response/BasicTest.java
@@ -12,6 +12,8 @@
 // ***************************************************************************************************************************
 package org.apache.juneau.rest.response;
 
+import java.net.*;
+
 import org.apache.juneau.rest.annotation.*;
 import org.apache.juneau.rest.mock.*;
 import org.junit.*;
@@ -148,10 +150,10 @@ public class BasicTest {
 
 	@RestResource
 	public static class B {
-		@RestMethod public MovedPermanently movedPermanently() { return new MovedPermanently("servlet:/foo"); }
-		@RestMethod public PermanentRedirect permanentRedirect() { return new PermanentRedirect("servlet:/foo"); }
-		@RestMethod public SeeOther seeOther() { return new SeeOther("servlet:/foo"); }
-		@RestMethod public TemporaryRedirect temporaryRedirect() { return new TemporaryRedirect("servlet:/foo"); }
+		@RestMethod public MovedPermanently movedPermanently() { return new MovedPermanently(URI.create("servlet:/foo")); }
+		@RestMethod public PermanentRedirect permanentRedirect() { return new PermanentRedirect(URI.create("servlet:/foo")); }
+		@RestMethod public SeeOther seeOther() { return new SeeOther(URI.create("servlet:/foo")); }
+		@RestMethod public TemporaryRedirect temporaryRedirect() { return new TemporaryRedirect(URI.create("servlet:/foo")); }
 	}
 
 	static MockRest b = MockRest.create(B.class);