Add new header condition and fix minor bug in restcontroller