Mmiscool wrote:I find it hard to belive that there is not an existing function to do this.
I'm not following you. The code above is quite straight forward, it is following the HTTP specs.
If you wish to "wrap" it into a function,of course, it can be done, as long as it handle the failures and success.