Factored header parsing code into separate function, added check to ensure 200 OK received