Suppress ArrayIndexOutOfBoundsException to allow retry login

Browser will not response after click log in button leaving both username and password blank.
BasicAuth Groovy version
User private method handle401() to avoid duplicated code.
Merge pull request #47 from panzhangwang/master

Some fixes to BasicAuth