Packages

class IncomingMessage extends Object with StObject

An IncomingMessage object is created by Server or ClientRequest and passed as the first argument to the 'request' and 'response' event respectively. It may be used to access response status, headers and data.

Different from its socket value which is a subclass of stream.Duplex, theIncomingMessage itself extends stream.Readable and is created separately to parse and emit the incoming HTTP headers and payload, as the underlying socket may be reused multiple times in case of keep-alive.

Annotations
@JSType() @JSImport("http", "IncomingMessage") @native()
Since

v0.1.17

Linear Supertypes
StObject, Object, Any, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. IncomingMessage
  2. StObject
  3. Object
  4. Any
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new IncomingMessage(socket: Socket)
  2. new IncomingMessage()
    Attributes
    protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. var aborted: Boolean

    The message.aborted property will be true if the request has been aborted.

    The message.aborted property will be true if the request has been aborted.

    Since

    v10.1.0

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  7. var complete: Boolean

    The message.complete property will be true if a complete HTTP message has been received and successfully parsed.

    The message.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'); }); });

    Since

    v0.3.0

  8. def destroy(error: Error): Unit
  9. def destroy(): Unit

    Calls destroy() on the socket that received the IncomingMessage.

    Calls destroy() on the socket that received the IncomingMessage. If erroris provided, an 'error' event is emitted on the socket and error is passed as an argument to any listeners on the event.

    Since

    v0.3.0

  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  12. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  13. def hasOwnProperty(v: String): Boolean
    Definition Classes
    Object
  14. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  15. var headers: IncomingHttpHeaders

    The request/response headers object.

    The request/response headers object.

    Key-value pairs of header names and values. Header names are lower-cased.

    js // 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. * 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 ', '.

    Since

    v0.1.5

  16. var httpVersion: String

    In case of server request, the HTTP version sent by the client.

    In case of server request, the HTTP version sent by the client. In the case of client response, the HTTP version of the connected-to server. Probably either '1.1' or '1.0'.

    Also message.httpVersionMajor is the first integer andmessage.httpVersionMinor is the second.

    Since

    v0.1.1

  17. var httpVersionMajor: Double
  18. var httpVersionMinor: Double
  19. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  20. def isPrototypeOf(v: Object): Boolean
    Definition Classes
    Object
  21. var method: UndefOr[String]

    **Only valid for request obtained from Server.**

    **Only valid for request obtained from Server.**

    The request method as a string. Read only. Examples: 'GET', 'DELETE'.

    Since

    v0.1.1

  22. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  23. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  24. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  25. def propertyIsEnumerable(v: String): Boolean
    Definition Classes
    Object
  26. var rawHeaders: Array[String]

    The raw request/response headers list exactly as they were received.

    The raw request/response headers list exactly as they were received.

    The keys and values are in the same list. It is _not_ a list of tuples. So, the even-numbered offsets are key values, and the odd-numbered offsets are the associated values.

    Header names are not lowercased, and duplicates are not merged.

    js // 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);

    Since

    v0.11.6

  27. var rawTrailers: Array[String]

    The raw request/response trailer keys and values exactly as they were received.

    The raw request/response trailer keys and values exactly as they were received. Only populated at the 'end' event.

    Since

    v0.11.6

  28. def setTimeout(msecs: Double, callback: Function0[Unit]): IncomingMessage.this.type
  29. def setTimeout(msecs: Double): IncomingMessage.this.type

    Calls message.socket.setTimeout(msecs, callback).

    Calls message.socket.setTimeout(msecs, callback).

    Since

    v0.5.9

  30. var socket: Socket

    The net.Socket object associated with the connection.

    The 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.

    Since

    v0.3.0

  31. var statusCode: UndefOr[Double]

    **Only valid for response obtained from ClientRequest.**

    **Only valid for response obtained from ClientRequest.**

    The 3-digit HTTP response status code. E.G. 404.

    Since

    v0.1.1

  32. var statusMessage: UndefOr[String]

    **Only valid for response obtained from ClientRequest.**

    **Only valid for response obtained from ClientRequest.**

    The HTTP response status message (reason phrase). E.G. OK or Internal Server Error.

    Since

    v0.11.10

  33. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  34. def toLocaleString(): String
    Definition Classes
    Object
  35. def toString(): String
    Definition Classes
    AnyRef → Any
  36. var trailers: Dict[String]

    The request/response trailers object.

    The request/response trailers object. Only populated at the 'end' event.

    Since

    v0.3.0

  37. var url: UndefOr[String]

    **Only valid for request obtained from Server.**

    **Only valid for request obtained from Server.**

    Request URL string. This contains only the URL that is present in the actual HTTP request. Take the following request:

    http GET /status?name=ryan HTTP/1.1 Accept: text/plain

    To parse the URL into its parts:

    js new URL(request.url, http://${request.headers.host});

    When request.url is '/status?name=ryan' andrequest.headers.host is 'localhost:3000':

    console $ node > new URL(request.url, http://${request.headers.host}) URL { href: 'http://localhost:3000/status?name=ryan', origin: 'http://localhost:3000', protocol: 'http:', username: , password: , host: 'localhost:3000', hostname: 'localhost', port: '3000', pathname: '/status', search: '?name=ryan', searchParams: URLSearchParams { 'name' => 'ryan' }, hash: }

    Since

    v0.1.90

  38. def valueOf(): Any
    Definition Classes
    Object
  39. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  40. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  41. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. var connection: Socket

    Alias for message.socket.

    Alias for message.socket.

    Deprecated

    Since v16.0.0 - Use socket.

    Since

    v0.1.90

  2. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from StObject

Inherited from Object

Inherited from Any

Inherited from AnyRef

Inherited from Any

Ungrouped