ServerHttp2Stream
Properties
If false
then the stream will automatically end the writable side when the readable side ends. Set initially by the allowHalfOpen
constructor option, which defaults to true
.
This property shows the number of characters currently buffered to be written. See net.Socket.bufferSize
for details.
Set to true
if the END_STREAM
flag was set in the request or response HEADERS frame received, indicating that no additional data should be received and the readable side of the Http2Stream
will be closed.
True if headers were sent, false otherwise (read-only).
Read-only property mapped to the SETTINGS_ENABLE_PUSH
flag of the remote client's most recent SETTINGS
frame. Will be true
if the remote peer accepts push streams, false
otherwise. Settings are the same for every Http2Stream
in the same Http2Session
.
Returns whether the stream was destroyed or errored before emitting 'end'
.
Returns whether 'data'
has been emitted.
Getter for the property encoding
of a given Readable
stream. The encoding
property can be set using the {@link setEncoding} method.
Becomes true
when 'end'
event is emitted.
This property reflects the current state of a Readable
stream as described in the Three states section.
Returns the value of highWaterMark
passed when creating this Readable
.
This property contains the number of bytes (or objects) in the queue ready to be read. The value provides introspection data regarding the status of the highWaterMark
.
Getter for the property objectMode
of a given Readable
stream.
Set to true
if the Http2Stream
instance has been destroyed and is no longer usable.
Is true
if it is safe to call writable.write()
, which means the stream has not been destroyed, errored, or ended.
An object containing the outbound headers sent for this Http2Stream
.
An array of objects containing the outbound informational (additional) headers sent for this Http2Stream
.
An object containing the outbound trailers sent for this HttpStream
.
A reference to the Http2Session
instance that owns this Http2Stream
. The value will be undefined
after the Http2Stream
instance is destroyed.
Provides miscellaneous information about the current state of the Http2Stream
.
Number of times writable.uncork()
needs to be called in order to fully uncork the stream.
Is true
after writable.end()
has been called. This property does not indicate whether the data has been flushed, for this use writable.writableFinished
instead.
Is set to true
immediately before the 'finish'
event is emitted.
Return the value of highWaterMark
passed when creating this Writable
.
This property contains the number of bytes (or objects) in the queue ready to be written. The value provides introspection data regarding the status of the highWaterMark
.
Is true
if the stream's buffer has been full and stream will emit 'drain'
.
Getter for the property objectMode
of a given Writable
stream.
Functions
Sends an additional informational HEADERS
frame to the connected HTTP/2 peer.
Event emitter The defined events on documents including:
This method returns a new stream with chunks of the underlying stream paired with a counter in the form [index, chunk]
. The first index value is 0
and it increases by 1 for each chunk produced.
Destroy the stream. Optionally emit an 'error'
event, and emit a 'close'
event (unless emitClose
is set to false
). After this call, the readable stream will release any internal resources and subsequent calls to push()
will be ignored.
This method returns a new stream with the first limit chunks dropped from the start.
Calling the writable.end()
method signals that no more data will be written to the Writable
. The optional chunk
and encoding
arguments allow one final additional chunk of data to be written immediately before closing the stream.
Returns an array listing the events for which the emitter has registered listeners. The values in the array are strings or Symbol
s.
This method is similar to Array.prototype.every
and calls fn on each chunk in the stream to check if all awaited return values are truthy value for fn. Once an fn call on a chunk await
ed return value is falsy, the stream is destroyed and the promise is fulfilled with false
. If all of the fn calls on the chunks return a truthy value, the promise is fulfilled with true
.
This method allows filtering the stream. For each chunk in the stream the fn function will be called and if it returns a truthy value, the chunk will be passed to the result stream. If the fn function returns a promise - that promise will be await
ed.
This method is similar to Array.prototype.find
and calls fn on each chunk in the stream to find a chunk with a truthy value for fn. Once an fn call's awaited return value is truthy, the stream is destroyed and the promise is fulfilled with value for which fn returned a truthy value. If all of the fn calls on the chunks return a falsy value, the promise is fulfilled with undefined
.
This method returns a new stream by applying the given callback to each chunk of the stream and then flattening the result.
This method allows iterating a stream. For each chunk in the stream the fn function will be called. If the fn function returns a promise - that promise will be await
ed.
Returns the current max listener value for the EventEmitter
which is either set by emitter.setMaxListeners(n)
or defaults to {@link defaultMaxListeners}.
The iterator created by this method gives users the option to cancel the destruction of the stream if the for await...of
loop is exited by return
, break
, or throw
, or if the iterator should destroy the stream if the stream emitted an error during iteration.
This method allows mapping over the stream. The fn function will be called for every chunk in the stream. If the fn function returns a promise - that promise will be await
ed before being passed to the result stream.
Updates the priority for this Http2Stream
instance.
Initiates a push stream. The callback is invoked with the new Http2Stream
instance created for the push stream passed as the second argument, or an Error
passed as the first argument.
The readable.read()
method reads data out of the internal buffer and returns it. If no data is available to be read, null
is returned. By default, the data is returned as a Buffer
object unless an encoding has been specified using the readable.setEncoding()
method or the stream is operating in object mode.
This method calls fn on each chunk of the stream in order, passing it the result from the calculation on the previous element. It returns a promise for the final value of the reduction.
Initiates a response. When the options.waitForTrailers
option is set, the'wantTrailers'
event will be emitted immediately after queuing the last chunk of payload data to be sent. The http2stream.sendTrailers()
method can then be used to sent trailing header fields to the peer.
Initiates a response whose data is read from the given file descriptor. No validation is performed on the given file descriptor. If an error occurs while attempting to read data using the file descriptor, the Http2Stream
will be closed using an RST_STREAM
frame using the standard INTERNAL_ERROR
code.
Sends a regular file as the response. The path
must specify a regular file or an 'error'
event will be emitted on the Http2Stream
object.
Sends a trailing HEADERS
frame to the connected HTTP/2 peer. This method will cause the Http2Stream
to be immediately closed and must only be called after the 'wantTrailers'
event has been emitted. When sending a request or sending a response, the options.waitForTrailers
option must be set in order to keep the Http2Stream
open after the final DATA
frame so that trailers can be sent.
The writable.setDefaultEncoding()
method sets the default encoding
for a Writable
stream.
The readable.setEncoding()
method sets the character encoding for data read from the Readable
stream.
By default EventEmitter
s will print a warning if more than 10
listeners are added for a particular event. This is a useful default that helps finding memory leaks. The emitter.setMaxListeners()
method allows the limit to be modified for this specific EventEmitter
instance. The value can be set to Infinity
(or 0
) to indicate an unlimited number of listeners.
This method is similar to Array.prototype.some
and calls fn on each chunk in the stream until the awaited return value is true
(or any truthy value). Once an fn call on a chunk await
ed return value is truthy, the stream is destroyed and the promise is fulfilled with true
. If none of the fn calls on the chunks return a truthy value, the promise is fulfilled with false
.
This method returns a new stream with the first limit chunks.
This method allows easily obtaining the contents of a stream.
The readable.unpipe()
method detaches a Writable
stream previously attached using the {@link pipe} method.
Passing chunk
as null
signals the end of the stream (EOF) and behaves the same as readable.push(null)
, after which no more data can be written. The EOF signal is put at the end of the buffer and any buffered data will still be flushed.
Prior to Node.js 0.10, streams did not implement the entire node:stream
module API as it is currently defined. (See Compatibility
for more information.)
The writable.write()
method writes some data to the stream, and calls the supplied callback
once the data has been fully handled. If an error occurs, the callback
will be called with the error as its first argument. The callback
is called asynchronously and before 'error'
is emitted.