Ruby 1.9.2 friendly TCPSockets and DRY'd up process_headers method