refactored http scheme detection