diff --git a/source/common/http/exception.h b/source/common/http/exception.h index 605ee293065f..0e952422c562 100644 --- a/source/common/http/exception.h +++ b/source/common/http/exception.h @@ -9,37 +9,6 @@ namespace Envoy { namespace Http { -/** - * Indicates a non-recoverable protocol error that should result in connection termination. - */ -class CodecProtocolException : public EnvoyException { -public: - CodecProtocolException(const std::string& message) : EnvoyException(message) {} -}; - -/** - * Raised when outbound frame queue flood is detected. - */ -class FrameFloodException : public CodecProtocolException { -public: - FrameFloodException(const std::string& message) : CodecProtocolException(message) {} -}; - -/** - * Raised when a response is received on a connection that did not send a request. In practice - * this can only happen on HTTP/1.1 connections. - */ -class PrematureResponseException : public EnvoyException { -public: - PrematureResponseException(Http::Code response_code) - : EnvoyException(""), response_code_(response_code) {} - - Http::Code responseCode() { return response_code_; } - -private: - const Http::Code response_code_; -}; - /** * Indicates a client (local) side error which should not happen. */ diff --git a/source/common/http/http1/codec_impl.cc b/source/common/http/http1/codec_impl.cc index 0d96e483ff8a..e0505d3265cd 100644 --- a/source/common/http/http1/codec_impl.cc +++ b/source/common/http/http1/codec_impl.cc @@ -538,14 +538,6 @@ bool ConnectionImpl::maybeDirectDispatch(Buffer::Instance& data) { return true; } -Http::Status ConnectionImpl::dispatch(Buffer::Instance& data) { - // TODO(#10878): Remove this wrapper when exception removal is complete. innerDispatch may either - // throw an exception or return an error status. The utility wrapper catches exceptions and - // converts them to error statuses. - return Utility::exceptionToStatus( - [&](Buffer::Instance& data) -> Http::Status { return innerDispatch(data); }, data); -} - Http::Status ClientConnectionImpl::dispatch(Buffer::Instance& data) { Http::Status status = ConnectionImpl::dispatch(data); if (status.ok() && data.length() > 0) { @@ -556,7 +548,7 @@ Http::Status ClientConnectionImpl::dispatch(Buffer::Instance& data) { return status; } -Http::Status ConnectionImpl::innerDispatch(Buffer::Instance& data) { +Http::Status ConnectionImpl::dispatch(Buffer::Instance& data) { // Add self to the Dispatcher's tracked object stack. ScopeTrackerScopeState scope(this, connection_.dispatcher()); ENVOY_CONN_LOG(trace, "parsing {} bytes", connection_, data.length()); diff --git a/source/common/http/http1/codec_impl.h b/source/common/http/http1/codec_impl.h index fff5b3be6647..f4c5e7d46f8e 100644 --- a/source/common/http/http1/codec_impl.h +++ b/source/common/http/http1/codec_impl.h @@ -321,15 +321,6 @@ class ConnectionImpl : public virtual Connection, return false; } - /** - * An inner dispatch call that executes the dispatching logic. While exception removal is in - * migration (#10878), this function may either throw an exception or return an error status. - * Exceptions are caught and translated to their corresponding statuses in the outer level - * dispatch. - * TODO(#10878): Remove this when exception removal is complete. - */ - Http::Status innerDispatch(Buffer::Instance& data); - /** * Dispatch a memory span. * @param slice supplies the start address. diff --git a/source/common/http/http2/codec_impl.cc b/source/common/http/http2/codec_impl.cc index 19719ef9044b..125a837ce814 100644 --- a/source/common/http/http2/codec_impl.cc +++ b/source/common/http/http2/codec_impl.cc @@ -647,14 +647,6 @@ void ConnectionImpl::onKeepaliveResponseTimeout() { } Http::Status ConnectionImpl::dispatch(Buffer::Instance& data) { - // TODO(#10878): Remove this wrapper when exception removal is complete. innerDispatch may either - // throw an exception or return an error status. The utility wrapper catches exceptions and - // converts them to error statuses. - return Http::Utility::exceptionToStatus( - [&](Buffer::Instance& data) -> Http::Status { return innerDispatch(data); }, data); -} - -Http::Status ConnectionImpl::innerDispatch(Buffer::Instance& data) { ScopeTrackerScopeState scope(this, connection_.dispatcher()); ENVOY_CONN_LOG(trace, "dispatching {} bytes", connection_, data.length()); // Make sure that dispatching_ is set to false after dispatching, even when @@ -1710,17 +1702,9 @@ ServerConnectionImpl::trackOutboundFrames(bool is_outbound_flood_monitored_contr } Http::Status ServerConnectionImpl::dispatch(Buffer::Instance& data) { - // TODO(#10878): Remove this wrapper when exception removal is complete. innerDispatch may either - // throw an exception or return an error status. The utility wrapper catches exceptions and - // converts them to error statuses. - return Http::Utility::exceptionToStatus( - [&](Buffer::Instance& data) -> Http::Status { return innerDispatch(data); }, data); -} - -Http::Status ServerConnectionImpl::innerDispatch(Buffer::Instance& data) { // Make sure downstream outbound queue was not flooded by the upstream frames. RETURN_IF_ERROR(protocol_constraints_.checkOutboundFrameLimits()); - return ConnectionImpl::innerDispatch(data); + return ConnectionImpl::dispatch(data); } absl::optional diff --git a/source/common/http/http2/codec_impl.h b/source/common/http/http2/codec_impl.h index 27544c8a19c9..1f73d14f423f 100644 --- a/source/common/http/http2/codec_impl.h +++ b/source/common/http/http2/codec_impl.h @@ -136,16 +136,6 @@ class ConnectionImpl : public virtual Connection, } } - /** - * An inner dispatch call that executes the dispatching logic. While exception removal is in - * migration (#10878), this function may either throw an exception or return an error status. - * Exceptions are caught and translated to their corresponding statuses in the outer level - * dispatch. - * This needs to be virtual so that ServerConnectionImpl can override. - * TODO(#10878): Remove this when exception removal is complete. - */ - virtual Http::Status innerDispatch(Buffer::Instance& data); - // ScopeTrackedObject void dumpState(std::ostream& os, int indent_level) const override; @@ -654,7 +644,6 @@ class ServerConnectionImpl : public ServerConnection, public ConnectionImpl { // ServerConnectionImpl objects is called only when processing data from the downstream client in // the ConnectionManagerImpl::onData method. Http::Status dispatch(Buffer::Instance& data) override; - Http::Status innerDispatch(Buffer::Instance& data) override; ServerConnectionCallbacks& callbacks_; diff --git a/source/common/http/utility.cc b/source/common/http/utility.cc index 6ba08a599446..eea1a216e6af 100644 --- a/source/common/http/utility.cc +++ b/source/common/http/utility.cc @@ -34,31 +34,6 @@ #include "nghttp2/nghttp2.h" namespace Envoy { -namespace Http { -namespace Utility { -Http::Status exceptionToStatus(std::function dispatch, - Buffer::Instance& data) { - Http::Status status; - TRY_NEEDS_AUDIT { - status = dispatch(data); - // TODO(#10878): Remove this when exception removal is complete. It is currently in migration, - // so dispatch may either return an error status or throw an exception. Soon we won't need to - // catch these exceptions, as all codec errors will be migrated to using error statuses that are - // returned from dispatch. - } - catch (FrameFloodException& e) { - status = bufferFloodError(e.what()); - } - catch (CodecProtocolException& e) { - status = codecProtocolError(e.what()); - } - catch (PrematureResponseException& e) { - status = prematureResponseError(e.what(), e.responseCode()); - } - return status; -} -} // namespace Utility -} // namespace Http namespace Http2 { namespace Utility { diff --git a/source/common/http/utility.h b/source/common/http/utility.h index 2af7e49e0a4b..9160f0b73025 100644 --- a/source/common/http/utility.h +++ b/source/common/http/utility.h @@ -24,12 +24,6 @@ namespace Envoy { namespace Http { namespace Utility { -// This is a wrapper around dispatch calls that may throw an exception or may return an error status -// while exception removal is in migration. -// TODO(#10878): Remove this. -Http::Status exceptionToStatus(std::function dispatch, - Buffer::Instance& data); - /** * Well-known HTTP ALPN values. */