scgi-stream
Simple SCGI client.
Overview
scgi-stream lets you talk to scgi-speaking services without having to go through an intermediate HTTP server.
Installation
Available via npm:
$ npm install scgi-stream
Or via git:
$ git clone git://github.com/deoxxa/scgi-stream.git node_modules/scgi-stream
API
request
Makes an SCGI request. Returns an SCGIRequest
object. Also does some wiring
for you so that the request returned will emit a response
event when the
response begins to arrive. See the example section below for more information on
how this works.
scgi;
var scgi = ; scgi;
Arguments
- options - an object specifying options for the request and response.
Available options are
stream
,host
,port
,path
,method
, andheaders
.stream
is optionally a stream object. Ifstream
is not specified,host
andport
, which are a string and a number respectively, will be used to construct a TCP socket.path
andmethod
are strings, andheaders
is an object with a predictable structure.
duplex
Makes an SCGI request. Returns a duplex stream that combines both the request
and response parts of the operation. The stream returned will emit the headers
event like a regular SCGIResponse
object, but will not emit a response
event.
scgi;
var scgi = ; processstdin;
Arguments
- options - same as the options for request
SCGIRequest
A duplex stream representing a request.
options;
var req = path: "/" headers: "content-type": "text/plain" ; req; req;
Arguments
- options - an object specifying options for the request. Available options
are
path
,method
, andheaders
.
SCGIResponse
A duplex stream that parses and represents a response. Emits a headers
event
when the headers for the stream have been parsed, then passes through all
following data.
options;
var res = ; socket; res;
Arguments
- options - an object with the typical
stream.Transform
options such ashighWaterMark
,objectMode
, etc.
Example
Also see example.js.
var scgi = ; var req = scgi; req; req;
License
3-clause BSD. A copy is included with the source.
Contact
- GitHub (deoxxa)
- Twitter (@deoxxa)
- ADN (@deoxxa)
- Email (deoxxa@fknsrs.biz)