mikeal/request — pull request #1067 by nemanjawork (2014-09-10 19:28:09+00:00)
Title: Alterations to support HTTPS requests in a browser environment when the library is loaded via browserify. 

The changes are minor and they are related to the fact that browserify does not resolve dynamic paths when building client-side browser javascript. So, when modules are loaded using the optional() module, they are loaded dynamically (their names were passed in) so browserify could not resolve the dependancies - since the resolution happens before runtime.

This minor fix uses the process package to determine if the environment running the module is in fact the browser, and if it is, we explicitly import modules rather than using the optional flag.

e.g.

https = optional('https')

became:

https = process.browser ? require('https') : optional('https')