Added check for had_headers flag before calling fetch_curL_header