Consolidate function that seperates headers and body that was used in 3 places. Also, add connection:close header to prevent long lag in connnection.