-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Try using something simpler than request-stream
- Loading branch information
Richard Feldman
committed
Aug 20, 2018
1 parent
6a39d4a
commit a0fbb61
Showing
4 changed files
with
56 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
var http = require("http"); | ||
var https = require("https"); | ||
var parseUrl = require("url").parse; | ||
|
||
// Inspired by https://github.com/maxogden/request-stream | ||
|
||
module.exports = function request(url, opts) { | ||
var parsed = parseUrl(url); | ||
|
||
var finalOpts = Object.assign({ | ||
host: parsed.hostname, | ||
path: parsed.path, | ||
port: parsed.port | ||
}, opts); | ||
|
||
if (parsed.protocol === "https:") { | ||
return https.request(finalOpts); | ||
} else { | ||
return http.request(finalOpts); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters