Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/floatdrop/reque
PassThrough stream, that handles http(s) requests and have some sweet methods
https://github.com/floatdrop/reque
Last synced: 22 days ago
JSON representation
PassThrough stream, that handles http(s) requests and have some sweet methods
- Host: GitHub
- URL: https://github.com/floatdrop/reque
- Owner: floatdrop
- Created: 2014-11-18T10:34:36.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-11-18T15:15:25.000Z (about 10 years ago)
- Last Synced: 2024-12-03T10:42:29.745Z (about 1 month ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# reque [![Build Status](https://travis-ci.org/floatdrop/reque.svg?branch=master)](https://travis-ci.org/floatdrop/reque)
> Simplified way to handle ClientRequest objects on redirects and timeouts
[![jaltoid](https://cloud.githubusercontent.com/assets/365089/5086026/b45e412c-6f39-11e4-847f-2c07bc2a4874.jpg)](http://www.youtube.com/watch?v=qgJjqwmhN28)
## Usage
```js
var Reque = require('reque');
var reque = new Reque();// Get request
reque
.request(req) // emits `request` event
.timeout(30 * 1000); // sets timeout value// Some time later
reque.request(req); // emits `redirect` event
```## API
### Reque()
Returns instance of PassThrough `Stream`.
Creates `Reque` object, that will count redirects.
### Reque.request(req)
Stores ClientRequest object `req`. Emits `request` on first call.
If it was already called `redirect` event will be emitted.
### Reque.timeout(time, [callback])
Sets timeout for every request, that passed to `request` method. Calls `callback` on timeout.
If `callback` is omitted, then `error` event will be fired.