In one of my web applications, customers are allowed to provide URLs that function as a “callback” or notification. (For example, when the WidgetCreated event happens, call http://customerdomain.com/widget.php?widgetid=101)
All we need to do is make the request; we don’t care about the response, for 2 reasons:
- It wastes our bandwidth and performance
- Worst case scenario, an abusive customer sends back a 1GB response to this request
How could I make the request, and download the first, say 1K, and then stop the download?
Make the request with HttpWebRequest and use the GetResponse method. Instead of reading the response stream, just
return.