Packages

object httpMod

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. httpMod
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. class Agent extends Object with StObject

    An Agent is responsible for managing connection persistence and reuse for HTTP clients.

    An Agent is responsible for managing connection persistence and reuse for HTTP clients. It maintains a queue of pending requests for a given host and port, reusing a single socket connection for each until the queue is empty, at which time the socket is either destroyed or put into a pool where it is kept to be used again for requests to the same host and port. Whether it is destroyed or pooled depends on thekeepAlive option.

    Pooled connections have TCP Keep-Alive enabled for them, but servers may still close idle connections, in which case they will be removed from the pool and a new connection will be made when a new HTTP request is made for that host and port. Servers may also refuse to allow multiple requests over the same connection, in which case the connection will have to be remade for every request and cannot be pooled. The Agent will still make the requests to that server, but each one will occur over a new connection.

    When a connection is closed by the client or the server, it is removed from the pool. Any unused sockets in the pool will be unrefed so as not to keep the Node.js process running when there are no outstanding requests. (see socket.unref()).

    It is good practice, to destroy() an Agent instance when it is no longer in use, because unused sockets consume OS resources.

    Sockets are removed from an agent when the socket emits either a 'close' event or an 'agentRemove' event. When intending to keep one HTTP request open for a long time without keeping it in the agent, something like the following may be done:

    js http.get(options, (res) => { // Do stuff }).on('socket', (socket) => { socket.emit('agentRemove'); });

    An agent may also be used for an individual request. By providing{agent: false} as an option to the http.get() or http.request()functions, a one-time use Agent with default options will be used for the client connection.

    agent:false:

    js http.get({ hostname: 'localhost', port: 80, path: '/', agent: false // Create a new agent just for this one request }, (res) => { // Do stuff with response });

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

    v0.3.4

  2. trait AgentOptions extends Object with StObject
    Annotations
    @JSType() @native()
  3. class ClientRequest extends Object with StObject

    This object is created internally and returned from request.

    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

  4. trait ClientRequestArgs extends Object with StObject
    Annotations
    @JSType() @native()
  5. trait IncomingHttpHeaders extends Object with StObject with Dict[|[String, Array[String]]]
    Annotations
    @JSType() @native()
  6. 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.

    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

  7. trait InformationEvent extends Object with StObject
    Annotations
    @JSType() @native()
  8. type OutgoingHttpHeader = |[|[Double, String], Array[String]]
  9. type OutgoingHttpHeaders = StringDictionary[UndefOr[OutgoingHttpHeader]]
  10. type RequestListener = Function2[IncomingMessage, ServerResponse, Unit]
  11. class Server extends Object with StObject

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

    v0.1.17

  12. trait ServerOptions extends Object with StObject
    Annotations
    @JSType() @native()
  13. class ServerResponse extends Object with StObject

    This object is created internally by an HTTP server, not by the user.

    This object is created internally by an HTTP server, not by the user. It is passed as the second parameter to the 'request' event.

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

    v0.1.17

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. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  9. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  10. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  11. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  13. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  14. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  15. def toString(): String
    Definition Classes
    AnyRef → Any
  16. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  17. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  18. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  19. object AgentOptions
  20. object ClientRequestArgs
  21. object IncomingHttpHeaders
  22. object InformationEvent
  23. object ServerOptions

Deprecated Value Members

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

Inherited from AnyRef

Inherited from Any

Ungrouped