put HTTP requests in a tasks-queue to execute them sequentially but not too often
Install the module with:
npm install request-queue
The class for the HTTP request queue. Inherits from TasksQueue.
It hides the methods
RequestQueue depends on the following modules:
Set default options for the request.
request.defaults(). See also Encoding issue below.
Add scripts paths or URLs that are passed to jsdom.env as
Return an array of paths added with
Insert a request to the queue.
pushRequest(t, o) is equivalent to
addRequesr('tail', t, o).
unshiftRequest(t, o) is equivalent to
addRequesr('head', t, o).
where equals to 'head',
addRequest() prepends the request
to the head of the queue, otherwise it appends it to the
requestType is a string, used to distinguish the different
types of requests. Don't use strings that start with double colon
requestOptions are passed to
request(requestOptions, callback) that
does the actual http request.
requestType event is emitted when the response is retrieved
and the DOM construction is done. Listeners are called with three arguments:
request fails to work with encodings that are not supported by
request-queue uses iconv to solve that. It uses
the response header "content-type" to detect the encoding name. If no charset is
specified in "content-type" header, 'utf8' is used. Optionally you may
override the encoding, using
<your encoding> is used by iconv, while
is passed to
See examples directory
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
April 17, 2013. V. 0.0.2 Fixed encoding issue
April 1, 2013. V. 0.0.1. Basic functionality
Copyright (c) 2013 Andrei V. Toutoukine Licensed under the MIT license.