Product
Introducing Java Support in Socket
We're excited to announce that Socket now supports the Java programming language.
Interfaces for IO that make use of promises.
Q-IO now subsumes all of Q-HTTP and Q-FS.
File system API for Q promises with method signatures patterned after CommonJS/Fileystem/A but returning promises and promise streams.
Options is an optional object.
flags
: r
, w
, a
, b
, default of r
, not binarycharset
: default of utf-8
bufferSize
: in bytesmode
: UNIX permissionsbegin
first byte to read (defaults to zero)end
one past the last byte to read. end - begin == length
Open returns a promise for either a Reader or a Writer depending on the given flags.
Not yet implemented
Not yet implemented
The HTTP module resembles CommonJS/JSGI.
The http
module exports a Server
constructor.
listen(port)
stop()
The http
module exports a request
function that returns a promise
for a response.
The http
module exports a read
function, analogous to
Fs.read(path)
, but returning a promise for the contento of an OK HTTP
response.
url
.forEach
into proper response objects.undefined
, it returns undefined
. This is used as
a singal to the requester that the responder has taken control of
the response stream.A complete request object has the following properties.
url
the full URL of the request as a stringpath
the full path as a stringscriptName
the routed portion of the path, like ""
for
http://example.com/
if no routing has occurred.pathInfo
the part of the path that remains to be routed,
like /
for http://example.com
or http://example.com/
if no routing has occurred.version
the requested HTTP version as an array of strings.method
like "GET"
scheme
like "http:"
host
like "example.com"
port
the port number, like 80
remoteHost
remotePort
headers
corresponding values, possibly an array for multiple headers
of the same name.body
node
the wrapped Node request objectA complete response object has the following properties.
status
the HTTP status code as a number, like 200
.headers
body
an IO readeronclose
is an optional function that this library will call
when a response concludes.node
the wrapped Node response object.Headers are an object mapping lower-case header-names to corresponding values, possibly an array for multiple headers of the same name, for both requests and responses.
body is a representation of a readable stream, either for the content of a request or a response. It is implemented as a Q-IO reader.
forEach(callback)
callback(chunk)
function
Buffer
forEach
function for arrays of strings or buffers is
sufficient for user-provided bodiesforEach
function is the only necessary function for
bodies provided to this library.forEach
, bodies provided by this library
support the entire readable stream interface provided by
q-io
.read()
An HTTP application is a function that accepts a request and returns a
response. The request
function itself is an application.
Applications can be chained and combined to make advanced servers and
clients.
Reader instances have the following methods:
read()
forEach(callback)
close()
node
the underlying node readerAdditionally, the Reader
constructor has the following methods:
read(tream, charset)
accepts any foreachable and returns either a
buffer or a string if given a charset.join(buffers)
consolidates an array of buffers into a single
buffer. The buffers array is collapsed in place and the new first
and only buffer is returned.The reader
module exports a function that accepts a Node reader and
returns a Q reader.
Writer instances have the following methods:
write(content)
writes a chunk of content, either from a string or
a buffer.flush()
returns a promise to drain the outbound content all the
way to its destination.close()
destroy()
node
the underlying node writerThe writer
module exports a function that accepts a Node writer and
returns a Q writer.
Copyright 2009–2012 Kristopher Michael Kowal MIT License (enclosed)
FAQs
IO using Q promises
We found that q-io demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
We're excited to announce that Socket now supports the Java programming language.
Security News
Socket detected a malicious Python package impersonating a popular browser cookie library to steal passwords, screenshots, webcam images, and Discord tokens.
Security News
Deno 2.0 is now available with enhanced package management, full Node.js and npm compatibility, improved performance, and support for major JavaScript frameworks.