moved the code in build_headers() to send()