Fix headers being set before opening request