This class will generate GET or POST headers for you - very quickly and without the speed decrease of concatenating strings - there is absolutely no concatenation in this class.
StringBuilder and string.Format have both been proven to be faster than concatenation, and when you're generating headers, you need this speed.
http://pastebin.com/f34b0e695
Parameters:
string file - File (i.e. "/index.phtml")
string host - Host (i.e. "www.neopets.com")
string referer - The referring web page, cannot be left blank
string customUserAgent - a custom user agent to use instead of FF 3.5.4
bool gzip - Whether to accept a gzip response
string cookies - Any cookies to be sent with the request
string postData (POST only) - Post Data to send (i.e. "username=neocodex&password=neocodex")
Usage:
var headerGenerator = new HTTPHeaderGenerator(); var requestHeaders = headerGenerator.CreateGETHeaders("/index.phtml", "www.neopets.com", "http://www.google.co.uk", "*custom user agent*", false, "");
Oh - I tested this with a StopWatch() in C# - and it came back with a timing of 0 milliseconds. I assume I've broken into the microsecond barrier here, so you can guess that it's pretty fast