Remove unfinished h2c support (#7286)

This removes code for h2c support except the upgrade token. The token is needed
to recognize h2c and handle it as a normal request without Upgrade header.
diff --git a/proxy/ProxyTransaction.cc b/proxy/ProxyTransaction.cc
index 56c40b2..2ef8ad1 100644
--- a/proxy/ProxyTransaction.cc
+++ b/proxy/ProxyTransaction.cc
@@ -167,11 +167,6 @@
   upstream_outbound_options.f_outbound_transparent = flag;
 }
 
-void
-ProxyTransaction::set_h2c_upgrade_flag()
-{
-}
-
 int
 ProxyTransaction::get_transaction_priority_weight() const
 {
diff --git a/proxy/ProxyTransaction.h b/proxy/ProxyTransaction.h
index 9cd4af8..6ceb3c0 100644
--- a/proxy/ProxyTransaction.h
+++ b/proxy/ProxyTransaction.h
@@ -73,7 +73,6 @@
   virtual bool is_chunked_encoding_supported() const;
 
   virtual void set_proxy_ssn(ProxySession *set_proxy_ssn);
-  virtual void set_h2c_upgrade_flag();
 
   /// Non-Virtual Methods
   //
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index dc4214b..28ae236 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -1230,9 +1230,12 @@
       } else {
         TxnDebug("http_trans_upgrade", "Unable to upgrade connection to websockets, invalid headers (RFC 6455).");
       }
+    } else if (s->upgrade_token_wks == MIME_VALUE_H2C) {
+      // We need to recognize h2c to not handle it as an error.
+      // We just ignore the Upgrade header and respond to the request as though the Upgrade header field were absent.
+      s->is_upgrade_request = false;
+      return false;
     }
-
-    // TODO accept h2c token to start HTTP/2 session after TS-3498 is fixed
   } else {
     TxnDebug("http_trans_upgrade", "Transaction requested upgrade for unknown protocol: %s", upgrade_hdr_val);
   }
diff --git a/proxy/http2/Http2ClientSession.cc b/proxy/http2/Http2ClientSession.cc
index fb2650c..98577ca 100644
--- a/proxy/http2/Http2ClientSession.cc
+++ b/proxy/http2/Http2ClientSession.cc
@@ -226,45 +226,6 @@
   do_api_callout(TS_HTTP_SSN_START_HOOK);
 }
 
-void
-Http2ClientSession::set_upgrade_context(HTTPHdr *h)
-{
-  upgrade_context.req_header = new HTTPHdr();
-  upgrade_context.req_header->copy(h);
-
-  MIMEField *settings = upgrade_context.req_header->field_find(MIME_FIELD_HTTP2_SETTINGS, MIME_LEN_HTTP2_SETTINGS);
-  ink_release_assert(settings != nullptr);
-  int svlen;
-  const char *sv = settings->value_get(&svlen);
-
-  if (sv && svlen > 0) {
-    // Maybe size of data decoded by Base64URL is lower than size of encoded data.
-    unsigned char out_buf[svlen];
-    size_t decoded_len;
-    ats_base64_decode(sv, svlen, out_buf, svlen, &decoded_len);
-    for (size_t nbytes = 0; nbytes < decoded_len; nbytes += HTTP2_SETTINGS_PARAMETER_LEN) {
-      Http2SettingsParameter param;
-      if (!http2_parse_settings_parameter(make_iovec(out_buf + nbytes, HTTP2_SETTINGS_PARAMETER_LEN), param) ||
-          !http2_settings_parameter_is_valid(param)) {
-        // TODO ignore incoming invalid parameters and send suitable SETTINGS
-        // frame.
-      }
-      upgrade_context.client_settings.set(static_cast<Http2SettingsIdentifier>(param.id), param.value);
-    }
-  }
-
-  // Such intermediaries SHOULD also remove other connection-
-  // specific header fields, such as Keep-Alive, Proxy-Connection,
-  // Transfer-Encoding and Upgrade, even if they are not nominated by
-  // Connection.
-  upgrade_context.req_header->field_delete(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION);
-  upgrade_context.req_header->field_delete(MIME_FIELD_KEEP_ALIVE, MIME_LEN_KEEP_ALIVE);
-  upgrade_context.req_header->field_delete(MIME_FIELD_PROXY_CONNECTION, MIME_LEN_PROXY_CONNECTION);
-  upgrade_context.req_header->field_delete(MIME_FIELD_TRANSFER_ENCODING, MIME_LEN_TRANSFER_ENCODING);
-  upgrade_context.req_header->field_delete(MIME_FIELD_UPGRADE, MIME_LEN_UPGRADE);
-  upgrade_context.req_header->field_delete(MIME_FIELD_HTTP2_SETTINGS, MIME_LEN_HTTP2_SETTINGS);
-}
-
 // XXX Currently, we don't have a half-closed state, but we will need to
 // implement that. After we send a GOAWAY, there
 // are scenarios where we would like to complete the outstanding streams.
diff --git a/proxy/http2/Http2ClientSession.h b/proxy/http2/Http2ClientSession.h
index 0f1f64b..51a95b2 100644
--- a/proxy/http2/Http2ClientSession.h
+++ b/proxy/http2/Http2ClientSession.h
@@ -60,24 +60,6 @@
 
 size_t const HTTP2_HEADER_BUFFER_SIZE_INDEX = CLIENT_CONNECTION_FIRST_READ_BUFFER_SIZE_INDEX;
 
-// To support Upgrade: h2c
-struct Http2UpgradeContext {
-  Http2UpgradeContext() {}
-  ~Http2UpgradeContext()
-  {
-    if (req_header) {
-      req_header->clear();
-      delete req_header;
-    }
-  }
-
-  // Modified request header
-  HTTPHdr *req_header = nullptr;
-
-  // Decoded HTTP2-Settings Header Field
-  Http2ConnectionSettings client_settings;
-};
-
 class Http2ClientSession : public ProxySession
 {
 public:
@@ -115,7 +97,6 @@
   void decrement_current_active_client_connections_stat() override;
 
   void set_upgrade_context(HTTPHdr *h);
-  const Http2UpgradeContext &get_upgrade_context() const;
   void set_dying_event(int event);
   int get_dying_event() const;
   bool ready_to_free() const;
@@ -168,9 +149,6 @@
   History<HISTORY_DEFAULT_SIZE> _history;
   Milestones<Http2SsnMilestone, static_cast<size_t>(Http2SsnMilestone::LAST_ENTRY)> _milestones;
 
-  // For Upgrade: h2c
-  Http2UpgradeContext upgrade_context;
-
   VIO *write_vio                 = nullptr;
   int dying_event                = 0;
   bool kill_me                   = false;
@@ -192,12 +170,6 @@
 ///////////////////////////////////////////////
 // INLINE
 
-inline const Http2UpgradeContext &
-Http2ClientSession::get_upgrade_context() const
-{
-  return upgrade_context;
-}
-
 inline bool
 Http2ClientSession::ready_to_free() const
 {