substack/http-browserify — pull request #64 by tschaub (2014-09-02 23:56:57+00:00)
Title: Respect protocol

When the first arg to `http.request` is a string, it is passed to `url.parse`. This returns an object with a `protocol` property (and no `scheme`). In this case, the `protocol` is ignored (in favor of `window.location.protocol.split(':')[0]`).

The first change here respects the `protocol` if it is provided. The second change makes it so `Request` expects a `protocol` instead of `scheme`. I can rework either if needed.

Where this issue arose for me was in a site using https when I needed to (temporarily) access a resource via http. I provided a http URL to `http.get` and it generated a https URL based on `window.location.protocol` (instead of respecting the protocol from `url.parse`).