Move this method to HttpTool, perhaps? I just wrote similar logic while on-site with a customer, but it's in the customer's project currently.