There's more...

It may seem odd that this does not also return the extension as part of the filename.  This is because we cannot assume that the content that we received actually matches the implied type from the extension.  It is more accurate to determine this using headers returned by the web server.  That's our next recipe.