-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8b82ff1
commit f55d120
Showing
4 changed files
with
67 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as Remote from '../types/remote'; | ||
|
||
/** | ||
* Model of the HTTP Request I/O monad. | ||
* @param {Object} input Expected to be a map of configuration values. | ||
* @returns {Promise} Promise which resolves on completion. | ||
*/ | ||
export default function HTTP_REQUEST (input = {}) { | ||
const MAX_TIME_MS = 250; | ||
const request = this; | ||
const promise = new Promise((resolve, reject) => { | ||
const timer = setTimeout(() => { | ||
reject('Timeout!'); | ||
}, MAX_TIME_MS); | ||
|
||
const remote = new Remote({ | ||
authority: `${request.host}:${request.port}` | ||
}); | ||
|
||
const options = await remote._OPTIONS('/'); | ||
const result = await remote._GET(request.path); | ||
|
||
clearTimeout(timer); | ||
|
||
resolve({ | ||
request, options, result | ||
}); | ||
}); | ||
|
||
return promise; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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