use LWP; You won't have to learn the intricacies of HTTP conversations.
I fail to see what's wrong with the user agent string you are getting in the log files. It's exactly the same string you passed to the HTTP server. Or am I missing something? Is that example line not from your log files?