Http: fix generation of the custom readonly message

The use of custom HTTP status line is deprecated and has been removed
in Jetty since v9.4.21 (see [1]). The custom message when Gerrit
is read-only must be provided as response body.

Adapt the Git/HTTP tests accordingly, as JGit does not read the response
body if the status code is not 200 and therefore there is no way
to get the custom message anymore over the Git protocol.

[1]: https://github.com/eclipse/jetty.project/issues/4154

Bug: Issue 12146
Change-Id: I6ae10605fefa470d283492bb85147332f1438d0d
diff --git a/src/main/java/com/googlesource/gerrit/plugins/readonly/ReadOnly.java b/src/main/java/com/googlesource/gerrit/plugins/readonly/ReadOnly.java
index f0ffbbd..30f8904 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/readonly/ReadOnly.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/readonly/ReadOnly.java
@@ -71,7 +71,9 @@
         && request instanceof HttpServletRequest
         && response instanceof HttpServletResponse
         && shouldBlock((HttpServletRequest) request)) {
-      ((HttpServletResponse) response).sendError(SC_SERVICE_UNAVAILABLE, config.message());
+      HttpServletResponse httpResponse = (HttpServletResponse) response;
+      httpResponse.setStatus(SC_SERVICE_UNAVAILABLE);
+      httpResponse.getWriter().println(config.message());
       return;
     }
     chain.doFilter(request, response);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/readonly/AbstractReadOnlyTest.java b/src/test/java/com/googlesource/gerrit/plugins/readonly/AbstractReadOnlyTest.java
index 43cc3a3..d680abd 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/readonly/AbstractReadOnlyTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/readonly/AbstractReadOnlyTest.java
@@ -122,16 +122,16 @@
   @UseLocalDisk
   @UseSsh
   public void pushBySshIsRejectedWhenReadOnly() throws Exception {
-    pushForReview(true);
+    pushForReview(true, "READ ONLY");
   }
 
   @Test
   @UseLocalDisk
   public void pushByHttpIsRejectedWhenReadOnly() throws Exception {
-    pushForReview(false);
+    pushForReview(false, "Service Unavailable");
   }
 
-  private void pushForReview(boolean ssh) throws Exception {
+  private void pushForReview(boolean ssh, String expectedMessage) throws Exception {
     String url = ssh ? adminSshSession.getUrl() : admin.getHttpUrl(server);
     if (!ssh) {
       CredentialsProvider.setDefault(
@@ -150,7 +150,7 @@
       pushTo("refs/for/master");
       fail("expected TransportException");
     } catch (TransportException e) {
-      assertThat(e).hasMessageThat().contains("READ ONLY");
+      assertThat(e).hasMessageThat().contains(expectedMessage);
     }
 
     // Disable read-only