I was wondering, how fast the HTTPWebRequest is in comparision with a self-written parser for the HTTP-Response.
I know the HTTPWebRequest class is capable of using a persistent TCP connection with pipelining (pipelining is enabled by default). It’s also possible to set values for caching and compression.
The parsing of the response is probably never the bottleneck, but just for my curiosity: Does the HTTPWebRequest class produce “unnecessary” overhead?
Without knowing what the self-written parser is, it’s not possible to give a quantified answer to your question. That said, you might be able to write a parser that is quicker than
HTTPWebRequest, if (for example):If you can constrain the scenario, you may be able to outperform
HTTPWebRequestas it has to be able to handle any valid response, whereas a custom parser has to only be able to handle scenarios it’s expecting. That said, bear in mind that what you’re writing won’t then be a true HTTP response parser, rather something that handles a strict sub-set of valid responses.The only way you can tell if there’s any overhead which you can avoid is by writing your own (sub-set) parser and comparing its performance to that of the in-built one.