diff --git a/pdns/dnsdistdist/doh3.cc b/pdns/dnsdistdist/doh3.cc index 640d0738fdfa..1a6150911071 100644 --- a/pdns/dnsdistdist/doh3.cc +++ b/pdns/dnsdistdist/doh3.cc @@ -298,7 +298,11 @@ static void h3_send_response(quiche_conn* quic_conn, quiche_h3_conn* conn, const }, }; quiche_h3_send_response(conn, quic_conn, - streamID, headers, 2, false); + streamID, headers, 2, len == 0); + + if (len == 0) { + return; + } size_t pos = 0; while (pos < len) { @@ -330,7 +334,12 @@ static void handleResponse(DOH3Frontend& frontend, H3Connection& conn, const uin else { ++frontend.d_errorResponses; } - h3_send_response(conn, streamID, statusCode, &response.at(0), response.size()); + if (response.empty()) { + quiche_conn_stream_shutdown(conn.d_conn.get(), streamID, QUICHE_SHUTDOWN_WRITE, static_cast(DOQ_Error_Codes::DOQ_UNSPECIFIED_ERROR)); + } + else { + h3_send_response(conn, streamID, statusCode, &response.at(0), response.size()); + } } static void fillRandom(PacketBuffer& buffer, size_t size) diff --git a/pdns/dnsdistdist/doq.cc b/pdns/dnsdistdist/doq.cc index e2fc597d132e..521314f6e507 100644 --- a/pdns/dnsdistdist/doq.cc +++ b/pdns/dnsdistdist/doq.cc @@ -271,17 +271,6 @@ class DOQCrossProtocolQuery : public CrossProtocolQuery std::shared_ptr DOQCrossProtocolQuery::s_sender = std::make_shared(); -/* from rfc9250 section-4.3 */ -enum class DOQ_Error_Codes : uint64_t -{ - DOQ_NO_ERROR = 0, - DOQ_INTERNAL_ERROR = 1, - DOQ_PROTOCOL_ERROR = 2, - DOQ_REQUEST_CANCELLED = 3, - DOQ_EXCESSIVE_LOAD = 4, - DOQ_UNSPECIFIED_ERROR = 5 -}; - static void handleResponse(DOQFrontend& frontend, Connection& conn, const uint64_t streamID, const PacketBuffer& response) { if (response.empty()) { diff --git a/pdns/dnsdistdist/doq.hh b/pdns/dnsdistdist/doq.hh index 64d080bfd113..efc50ef218f6 100644 --- a/pdns/dnsdistdist/doq.hh +++ b/pdns/dnsdistdist/doq.hh @@ -28,6 +28,7 @@ #include "iputils.hh" #include "libssl.hh" #include "noinitvector.hh" +#include "doq.hh" #include "stat_t.hh" #include "dnsdist-idstate.hh" @@ -36,6 +37,17 @@ struct DownstreamState; #ifdef HAVE_DNS_OVER_QUIC +/* from rfc9250 section-4.3 */ +enum class DOQ_Error_Codes : uint64_t +{ + DOQ_NO_ERROR = 0, + DOQ_INTERNAL_ERROR = 1, + DOQ_PROTOCOL_ERROR = 2, + DOQ_REQUEST_CANCELLED = 3, + DOQ_EXCESSIVE_LOAD = 4, + DOQ_UNSPECIFIED_ERROR = 5 +}; + struct DOQFrontend { DOQFrontend();