I am writing a document and I have made it, so that on every even page, the header shows the current chapter, and on every odd page it shows the current section. But how can I show either the current chapter or the current section in the header, depending on the fact that the current page already belongs to a section or not?
\documentclass[a4paper, 12pt, twoside]{scrreprt}
\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{blindtext}
\usepackage[headsepline]{scrlayer-scrpage}
\pagestyle{scrheadings}
\clearpairofpagestyles
\rohead{\chaptername :\ \rightmark}
\lehead{\chaptername :\ \leftmark}
\automark[section]{chapter}
\ofoot[\pagemark]{\pagemark}
\begin{document}
\chapter{1}
\blindtext
\chapter{2}
\section{2.1}
\blindtext
\chapter{3}
\blindtext
\section{3.1}
\blindtext
\end{document}


