code: public static HttpHeaders statusToTrailers(int code, @Nullable String message, boolean headersSent) {
          final HttpHeaders trailers;
          if (headersSent) {
              // Normal trailers.
              trailers = new DefaultHttpHeaders();
          } else {
              // Trailers only response
              trailers = new DefaultHttpHeaders(true, 3, true)
                      .status(HttpStatus.OK)
                      .set(HttpHeaderNames.CONTENT_TYPE, "application/grpc+proto");
          }
          trailers.add(GrpcHeaderNames.GRPC_STATUS, Integer.toString(code));
  
          if (message != null) {
              trailers.add(GrpcHeaderNames.GRPC_MESSAGE, StatusMessageEscaper.escape(message));
          }
  
          return trailers;
      }
docs: Converts the given gRPC status code, and optionally an error message, to headers. The headers will be
  either trailers-only or normal trailers based on {@code headersSent}, whether leading headers have
  already been sent to the client.