MedusaRequest
Properties
aborted
booleanRequiredmessage.aborted
property will be true
if the request has been aborted.allowedProperties
string[]Requiredclosed
booleanRequiredtrue
after 'close'
has been emitted.complete
booleanRequiredmessage.complete
property will be true
if a complete HTTP message has been received and successfully parsed. This property is particularly useful as a means of determining if a client or server fully transmitted a message before a connection was terminated: js const req = http.request({ host: '127.0.0.1', port: 8080, method: 'POST', }, (res) => { res.resume(); res.on('end', () => { if (!res.complete) console.error( 'The connection was terminated while the message was still being sent'); }); });
message.socket
.destroyed
booleanRequiredtrue
after readable.destroy()
has been called.errors
string[]RequiredfilterableFields
Record<string, unknown>Requiredjs // Prints something like: // // { 'user-agent': 'curl/7.22.0', // host: '127.0.0.1:8000', // accept: '*' } console.log(request.headers);
Duplicates in raw headers are handled in the following ways, depending on the header name: * Duplicates of age
, authorization
, content-length
, content-type
,etag
, expires
, from
, host
, if-modified-since
, if-unmodified-since
,last-modified
, location
, max-forwards
, proxy-authorization
, referer
,retry-after
, server
, or user-agent
are discarded. To allow duplicate values of the headers listed above to be joined, use the option joinDuplicateHeaders
in request and createServer. See RFC 9110 Section 5.3 for more information. * set-cookie
is always an array. Duplicates are added to the array. * For duplicate cookie
headers, the values are joined together with ;
. * For all other headers, the values are joined together with ,
.message.headers
, but there is no join logic and the values are always arrays of strings, even for headers received just once. js // Prints something like: // // { 'user-agent': ['curl/7.22.0'], // host: ['127.0.0.1:8000'], // accept: ['*'] } console.log(request.headersDistinct);
httpVersion
stringRequired'1.1'
or '1.0'
. Also message.httpVersionMajor
is the first integer andmessage.httpVersionMinor
is the second.httpVersionMajor
numberRequiredhttpVersionMinor
numberRequiredincludes
Record<string, boolean>rawHeaders
string[]Requiredjs // Prints something like: // // [ 'user-agent', // 'this is invalid because there can be only one', // 'User-Agent', // 'curl/7.22.0', // 'Host', // '127.0.0.1:8000', // 'ACCEPT', // '*' ] console.log(request.rawHeaders);
rawTrailers
string[]Required'end'
event.readable
booleanRequiredtrue
if it is safe to call readable.read()
, which means the stream has not been destroyed or emitted 'error'
or 'end'
.readableAborted
booleanRequired'end'
.readableDidRead
booleanRequired'data'
has been emitted.encoding
of a given Readable
stream. The encoding
property can be set using the readable.setEncoding()
method.readableEnded
booleanRequiredtrue
when 'end'
event is emitted.readableFlowing
null | booleanRequiredReadable
stream as described in the Three states
section.readableHighWaterMark
numberRequiredhighWaterMark
passed when creating this Readable
.readableLength
numberRequiredhighWaterMark
.readableObjectMode
booleanRequiredobjectMode
of a given Readable
stream.net.Socket
object associated with the connection. With HTTPS support, use request.socket.getPeerCertificate()
to obtain the client's authentication details. This property is guaranteed to be an instance of the net.Socket
class, a subclass of stream.Duplex
, unless the user specified a socket type other than net.Socket
or internally nulled.statusCode
number404
.statusMessage
stringOK
or Internal Server Error
.'end'
event.message.trailers
, but there is no join logic and the values are always arrays of strings, even for headers received just once. Only populated at the 'end'
event.user
ObjectvalidatedBody
unknownRequiredMethods
[asyncDispose]
Calls readable.destroy()
with an AbortError
and returns a promise that fulfills when the stream is finished.
Returns
Promise
Promise<void>RequiredSince
v20.4.0
[asyncIterator]
Returns
[captureRejectionSymbol]
Parameters
Returns
void
void_construct
Parameters
Returns
void
void_destroy
Parameters
Returns
void
void_read
Parameters
size
numberRequiredReturns
void
voidaddListener
**addListener**(event, listener): [MedusaRequest](/references/js-client/internal/interfaces/internal.internal.MedusaRequest)
Event emitter The defined events on documents including:
- close
- data
- end
- error
- pause
- readable
- resume
Parameters
event
"close"Requiredlistener
() => voidRequiredReturns
**addListener**(event, listener): [MedusaRequest](/references/js-client/internal/interfaces/internal.internal.MedusaRequest)
Parameters
event
"data"Requiredlistener
(chunk: any) => voidRequiredReturns
**addListener**(event, listener): [MedusaRequest](/references/js-client/internal/interfaces/internal.internal.MedusaRequest)
Parameters
event
"end"Requiredlistener
() => voidRequiredReturns
**addListener**(event, listener): [MedusaRequest](/references/js-client/internal/interfaces/internal.internal.MedusaRequest)
Parameters
event
"error"RequiredReturns
**addListener**(event, listener): [MedusaRequest](/references/js-client/internal/interfaces/internal.internal.MedusaRequest)
Parameters
event
"pause"Requiredlistener
() => voidRequiredReturns
**addListener**(event, listener): [MedusaRequest](/references/js-client/internal/interfaces/internal.internal.MedusaRequest)
Parameters
event
"readable"Requiredlistener
() => voidRequiredReturns
**addListener**(event, listener): [MedusaRequest](/references/js-client/internal/interfaces/internal.internal.MedusaRequest)
Parameters
event
"resume"Requiredlistener
() => voidRequiredReturns
**addListener**(event, listener): [MedusaRequest](/references/js-client/internal/interfaces/internal.internal.MedusaRequest)
Parameters
event
string | symbolRequiredlistener
(...args: any[]) => voidRequiredReturns
asIndexedPairs
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.
Parameters
options
Pick<ArrayOptions, "signal">Returns
Since
v17.5.0
compose
Parameters
options
objectoptions.signal
AbortSignalRequiredReturns
T
TRequireddestroy
Calls destroy()
on the socket that received the IncomingMessage
. If error
is provided, an 'error'
event is emitted on the socket and error
is passed
as an argument to any listeners on the event.
Parameters
error
ErrorReturns
Since
v0.3.0
drop
This method returns a new stream with the first limit chunks dropped from the start.
Parameters
limit
numberRequiredoptions
Pick<ArrayOptions, "signal">Returns
Since
v17.5.0
emit
**emit**(event): boolean
Parameters
event
"close"RequiredReturns
boolean
boolean**emit**(event, chunk): boolean
Parameters
event
"data"Requiredchunk
anyRequired