optimise response connection header check

Get the status code from the response once so we can use it to check the need
for the connection header later without parsing the string each time we need it.