Added support for custom header, cookie and an automatic mode