Packages

class ClientRequest extends Object with StObject

This object is created internally and returned from request. It represents an _in-progress_ request whose header has already been queued. The header is still mutable using the setHeader(name, value),getHeader(name), removeHeader(name) API. The actual header will be sent along with the first data chunk or when calling request.end().

To get the response, add a listener for 'response' to the request object.'response' will be emitted from the request object when the response headers have been received. The 'response' event is executed with one argument which is an instance of IncomingMessage.

During the 'response' event, one can add listeners to the response object; particularly to listen for the 'data' event.

If no 'response' handler is added, then the response will be entirely discarded. However, if a 'response' event handler is added, then the data from the response object **must** be consumed, either by calling response.read() whenever there is a 'readable' event, or by adding a 'data' handler, or by calling the .resume() method. Until the data is consumed, the 'end' event will not fire. Also, until the data is read it will consume memory that can eventually lead to a 'process out of memory' error.

For backward compatibility, res will only emit 'error' if there is an'error' listener registered.

Node.js does not check whether Content-Length and the length of the body which has been transmitted are equal or not.

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

v0.1.17

Linear Supertypes
StObject, Object, Any, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ClientRequest
  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 ClientRequest(url: String, cb: Function1[IncomingMessage, Unit])
  2. new ClientRequest(url: URL, cb: Function1[IncomingMessage, Unit])
  3. new ClientRequest(url: ClientRequestArgs, cb: Function1[IncomingMessage, Unit])
  4. new ClientRequest(url: String)
  5. new ClientRequest(url: URL)
  6. new ClientRequest(url: ClientRequestArgs)
  7. new ClientRequest()
    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 request.aborted property will be true if the request has been aborted.

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

    Since

    v0.11.14

  5. def addListener(event: Symbol, listener: Function1[Any, Unit]): ClientRequest.this.type
  6. def addListener(event: String, listener: Function1[Any, Unit]): ClientRequest.this.type
  7. def addListener_abort(event: abort, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("addListener")
  8. def addListener_close(event: close, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("addListener")
  9. def addListener_connect(event: connect, listener: Function3[IncomingMessage, Socket, Buffer, Unit]): ClientRequest.this.type
    Annotations
    @JSName("addListener")
  10. def addListener_continue(event: continue, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("addListener")
  11. def addListener_drain(event: drain, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("addListener")
  12. def addListener_error(event: error, listener: Function1[Error, Unit]): ClientRequest.this.type
    Annotations
    @JSName("addListener")
  13. def addListener_finish(event: finish, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("addListener")
  14. def addListener_information(event: information, listener: Function1[InformationEvent, Unit]): ClientRequest.this.type
    Annotations
    @JSName("addListener")
  15. def addListener_pipe(event: pipe, listener: Function1[Readable, Unit]): ClientRequest.this.type
    Annotations
    @JSName("addListener")
  16. def addListener_response(event: response, listener: Function1[IncomingMessage, Unit]): ClientRequest.this.type
    Annotations
    @JSName("addListener")
  17. def addListener_socket(event: socket, listener: Function1[Socket, Unit]): ClientRequest.this.type
    Annotations
    @JSName("addListener")
  18. def addListener_timeout(event: timeout, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("addListener")
  19. def addListener_unpipe(event: unpipe, listener: Function1[Readable, Unit]): ClientRequest.this.type
    Annotations
    @JSName("addListener")
  20. def addListener_upgrade(event: upgrade, listener: Function3[IncomingMessage, Socket, Buffer, Unit]): ClientRequest.this.type
    Annotations
    @JSName("addListener")
  21. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  22. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  23. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  24. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  25. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  26. def getRawHeaderNames(): Array[String]

    Returns an array containing the unique names of the current outgoing raw headers.

    Returns an array containing the unique names of the current outgoing raw headers. Header names are returned with their exact casing being set.

    js request.setHeader('Foo', 'bar'); request.setHeader('Set-Cookie', ['foo=bar', 'bar=baz']);

    const headerNames = request.getRawHeaderNames(); // headerNames === ['Foo', 'Set-Cookie']

    Since

    v15.13.0

  27. def hasOwnProperty(v: String): Boolean
    Definition Classes
    Object
  28. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  29. var host: String

    The request host.

    The request host.

    Since

    v14.5.0, v12.19.0

  30. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  31. def isPrototypeOf(v: Object): Boolean
    Definition Classes
    Object
  32. var method: String

    The request method.

    The request method.

    Since

    v0.1.97

  33. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  34. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  35. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  36. def on(event: Symbol, listener: Function1[Any, Unit]): ClientRequest.this.type
  37. def on(event: String, listener: Function1[Any, Unit]): ClientRequest.this.type
  38. def onSocket(socket: Socket): Unit
  39. def on_abort(event: abort, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("on")
  40. def on_close(event: close, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("on")
  41. def on_connect(event: connect, listener: Function3[IncomingMessage, Socket, Buffer, Unit]): ClientRequest.this.type
    Annotations
    @JSName("on")
  42. def on_continue(event: continue, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("on")
  43. def on_drain(event: drain, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("on")
  44. def on_error(event: error, listener: Function1[Error, Unit]): ClientRequest.this.type
    Annotations
    @JSName("on")
  45. def on_finish(event: finish, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("on")
  46. def on_information(event: information, listener: Function1[InformationEvent, Unit]): ClientRequest.this.type
    Annotations
    @JSName("on")
  47. def on_pipe(event: pipe, listener: Function1[Readable, Unit]): ClientRequest.this.type
    Annotations
    @JSName("on")
  48. def on_response(event: response, listener: Function1[IncomingMessage, Unit]): ClientRequest.this.type
    Annotations
    @JSName("on")
  49. def on_socket(event: socket, listener: Function1[Socket, Unit]): ClientRequest.this.type
    Annotations
    @JSName("on")
  50. def on_timeout(event: timeout, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("on")
  51. def on_unpipe(event: unpipe, listener: Function1[Readable, Unit]): ClientRequest.this.type
    Annotations
    @JSName("on")
  52. def on_upgrade(event: upgrade, listener: Function3[IncomingMessage, Socket, Buffer, Unit]): ClientRequest.this.type
    Annotations
    @JSName("on")
  53. def once(event: Symbol, listener: Function1[Any, Unit]): ClientRequest.this.type
  54. def once(event: String, listener: Function1[Any, Unit]): ClientRequest.this.type
  55. def once_abort(event: abort, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("once")
  56. def once_close(event: close, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("once")
  57. def once_connect(event: connect, listener: Function3[IncomingMessage, Socket, Buffer, Unit]): ClientRequest.this.type
    Annotations
    @JSName("once")
  58. def once_continue(event: continue, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("once")
  59. def once_drain(event: drain, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("once")
  60. def once_error(event: error, listener: Function1[Error, Unit]): ClientRequest.this.type
    Annotations
    @JSName("once")
  61. def once_finish(event: finish, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("once")
  62. def once_information(event: information, listener: Function1[InformationEvent, Unit]): ClientRequest.this.type
    Annotations
    @JSName("once")
  63. def once_pipe(event: pipe, listener: Function1[Readable, Unit]): ClientRequest.this.type
    Annotations
    @JSName("once")
  64. def once_response(event: response, listener: Function1[IncomingMessage, Unit]): ClientRequest.this.type
    Annotations
    @JSName("once")
  65. def once_socket(event: socket, listener: Function1[Socket, Unit]): ClientRequest.this.type
    Annotations
    @JSName("once")
  66. def once_timeout(event: timeout, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("once")
  67. def once_unpipe(event: unpipe, listener: Function1[Readable, Unit]): ClientRequest.this.type
    Annotations
    @JSName("once")
  68. def once_upgrade(event: upgrade, listener: Function3[IncomingMessage, Socket, Buffer, Unit]): ClientRequest.this.type
    Annotations
    @JSName("once")
  69. var path: String

    The request path.

    The request path.

    Since

    v0.4.0

  70. def prependListener(event: Symbol, listener: Function1[Any, Unit]): ClientRequest.this.type
  71. def prependListener(event: String, listener: Function1[Any, Unit]): ClientRequest.this.type
  72. def prependListener_abort(event: abort, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependListener")
  73. def prependListener_close(event: close, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependListener")
  74. def prependListener_connect(event: connect, listener: Function3[IncomingMessage, Socket, Buffer, Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependListener")
  75. def prependListener_continue(event: continue, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependListener")
  76. def prependListener_drain(event: drain, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependListener")
  77. def prependListener_error(event: error, listener: Function1[Error, Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependListener")
  78. def prependListener_finish(event: finish, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependListener")
  79. def prependListener_information(event: information, listener: Function1[InformationEvent, Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependListener")
  80. def prependListener_pipe(event: pipe, listener: Function1[Readable, Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependListener")
  81. def prependListener_response(event: response, listener: Function1[IncomingMessage, Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependListener")
  82. def prependListener_socket(event: socket, listener: Function1[Socket, Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependListener")
  83. def prependListener_timeout(event: timeout, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependListener")
  84. def prependListener_unpipe(event: unpipe, listener: Function1[Readable, Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependListener")
  85. def prependListener_upgrade(event: upgrade, listener: Function3[IncomingMessage, Socket, Buffer, Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependListener")
  86. def prependOnceListener(event: Symbol, listener: Function1[Any, Unit]): ClientRequest.this.type
  87. def prependOnceListener(event: String, listener: Function1[Any, Unit]): ClientRequest.this.type
  88. def prependOnceListener_abort(event: abort, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependOnceListener")
  89. def prependOnceListener_close(event: close, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependOnceListener")
  90. def prependOnceListener_connect(event: connect, listener: Function3[IncomingMessage, Socket, Buffer, Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependOnceListener")
  91. def prependOnceListener_continue(event: continue, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependOnceListener")
  92. def prependOnceListener_drain(event: drain, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependOnceListener")
  93. def prependOnceListener_error(event: error, listener: Function1[Error, Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependOnceListener")
  94. def prependOnceListener_finish(event: finish, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependOnceListener")
  95. def prependOnceListener_information(event: information, listener: Function1[InformationEvent, Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependOnceListener")
  96. def prependOnceListener_pipe(event: pipe, listener: Function1[Readable, Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependOnceListener")
  97. def prependOnceListener_response(event: response, listener: Function1[IncomingMessage, Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependOnceListener")
  98. def prependOnceListener_socket(event: socket, listener: Function1[Socket, Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependOnceListener")
  99. def prependOnceListener_timeout(event: timeout, listener: Function0[Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependOnceListener")
  100. def prependOnceListener_unpipe(event: unpipe, listener: Function1[Readable, Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependOnceListener")
  101. def prependOnceListener_upgrade(event: upgrade, listener: Function3[IncomingMessage, Socket, Buffer, Unit]): ClientRequest.this.type
    Annotations
    @JSName("prependOnceListener")
  102. def propertyIsEnumerable(v: String): Boolean
    Definition Classes
    Object
  103. var protocol: String

    The request protocol.

    The request protocol.

    Since

    v14.5.0, v12.19.0

  104. def setNoDelay(noDelay: Boolean): Unit
  105. def setNoDelay(): Unit

    Once a socket is assigned to this request and is connected socket.setNoDelay() will be called.

    Once a socket is assigned to this request and is connected socket.setNoDelay() will be called.

    Since

    v0.5.9

  106. def setSocketKeepAlive(enable: Unit, initialDelay: Double): Unit
  107. def setSocketKeepAlive(enable: Boolean, initialDelay: Double): Unit
  108. def setSocketKeepAlive(enable: Boolean): Unit
  109. def setSocketKeepAlive(): Unit

    Once a socket is assigned to this request and is connected socket.setKeepAlive() will be called.

    Once a socket is assigned to this request and is connected socket.setKeepAlive() will be called.

    Since

    v0.5.9

  110. def setTimeout(timeout: Double, callback: Function0[Unit]): ClientRequest.this.type
  111. def setTimeout(timeout: Double): ClientRequest.this.type

    Once a socket is assigned to this request and is connected socket.setTimeout() will be called.

    Once a socket is assigned to this request and is connected socket.setTimeout() will be called.

    timeout

    Milliseconds before a request times out.

    Since

    v0.5.9

  112. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  113. def toLocaleString(): String
    Definition Classes
    Object
  114. def toString(): String
    Definition Classes
    AnyRef → Any
  115. def valueOf(): Any
    Definition Classes
    Object
  116. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  117. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  118. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def abort(): Unit

    Marks the request as aborting.

    Marks the request as aborting. Calling this will cause remaining data in the response to be dropped and the socket to be destroyed.

    Deprecated

    Since v14.1.0,v13.14.0 - Use destroy instead.

    Since

    v0.3.8

  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