Fixed setting request header

Setting the request header before it the connection was opened caused an error in Chrome.