fix issue 1840
Merge pull request #338 from timrichardson/issue/1840

fix issue 1840, CAS failing due to redirect loop