Production of bosons in elastic and quasi-elastic ep collisions at HERA