Act upon HTTP_1_1_REQUIRED.

This is a minimal working concept of retrying a connection with HTTP/1.1
upon receiving an HTTP_1_1_REQUIRED error code on an HTTP/2 connection in a
GO_AWAY or RST_STREAM frame.  The change in
HttpNetworkTransaction::DoReadHeadersComplete() still needs to be refactored
into its own function in HttpNetworkConnection() at a minimum.

BUG=431306

Review URL: https://codereview.chromium.org/753583003

Cr-Commit-Position: refs/heads/master@{#310805}
diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc
index b4ef356..93c5740 100644
--- a/net/http/http_network_transaction.cc
+++ b/net/http/http_network_transaction.cc
@@ -746,6 +746,9 @@
     // Return OK and let the caller read the proxy's error page
     next_state_ = STATE_NONE;
     return OK;
+  } else if (result == ERR_HTTP_1_1_REQUIRED ||
+             result == ERR_PROXY_HTTP_1_1_REQUIRED) {
+    return HandleHttp11Required(result);
   }
 
   // Handle possible handshake errors that may have occurred if the stream
@@ -961,6 +964,11 @@
       return result;
   }
 
+  if (result == ERR_HTTP_1_1_REQUIRED ||
+      result == ERR_PROXY_HTTP_1_1_REQUIRED) {
+    return HandleHttp11Required(result);
+  }
+
   // ERR_CONNECTION_CLOSED is treated differently at this point; if partial
   // response headers were received, we do the best we can to make sense of it
   // and send it back up the stack.
@@ -1195,6 +1203,19 @@
   return OK;
 }
 
+int HttpNetworkTransaction::HandleHttp11Required(int error) {
+  DCHECK(error == ERR_HTTP_1_1_REQUIRED ||
+         error == ERR_PROXY_HTTP_1_1_REQUIRED);
+
+  if (error == ERR_HTTP_1_1_REQUIRED) {
+    HttpServerProperties::ForceHTTP11(&server_ssl_config_);
+  } else {
+    HttpServerProperties::ForceHTTP11(&proxy_ssl_config_);
+  }
+  ResetConnectionAndRequestForResend();
+  return OK;
+}
+
 void HttpNetworkTransaction::HandleClientAuthError(int error) {
   if (server_ssl_config_.send_client_cert &&
       (error == ERR_SSL_PROTOCOL_ERROR || IsClientCertificateError(error))) {