Packages

class ServerResponse extends Object with StObject

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

Linear Supertypes
StObject, Object, Any, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ServerResponse
  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 ServerResponse(req: IncomingMessage)
  2. new ServerResponse()
    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. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def assignSocket(socket: Socket): Unit
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  7. def detachSocket(socket: Socket): Unit
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  10. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  11. def hasOwnProperty(v: String): Boolean
    Definition Classes
    Object
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. def isPrototypeOf(v: Object): Boolean
    Definition Classes
    Object
  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  17. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  18. def propertyIsEnumerable(v: String): Boolean
    Definition Classes
    Object
  19. var statusCode: Double

    When using implicit headers (not calling response.writeHead() explicitly), this property controls the status code that will be sent to the client when the headers get flushed.

    When using implicit headers (not calling response.writeHead() explicitly), this property controls the status code that will be sent to the client when the headers get flushed.

    js response.statusCode = 404;

    After response header was sent to the client, this property indicates the status code which was sent out.

    Since

    v0.4.0

  20. var statusMessage: String

    When using implicit headers (not calling response.writeHead() explicitly), this property controls the status message that will be sent to the client when the headers get flushed.

    When using implicit headers (not calling response.writeHead() explicitly), this property controls the status message that will be sent to the client when the headers get flushed. If this is left as undefined then the standard message for the status code will be used.

    js response.statusMessage = 'Not found';

    After response header was sent to the client, this property indicates the status message which was sent out.

    Since

    v0.11.8

  21. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  22. def toLocaleString(): String
    Definition Classes
    Object
  23. def toString(): String
    Definition Classes
    AnyRef → Any
  24. def valueOf(): Any
    Definition Classes
    Object
  25. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  26. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  27. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  28. def writeContinue(callback: Function0[Unit]): Unit
  29. def writeContinue(): Unit

    Sends a HTTP/1.1 100 Continue message to the client, indicating that the request body should be sent.

    Sends a HTTP/1.1 100 Continue message to the client, indicating that the request body should be sent. See the 'checkContinue' event onServer.

    Since

    v0.3.0

  30. def writeHead(statusCode: Double, statusMessage: Unit, headers: Array[OutgoingHttpHeader]): ServerResponse.this.type
  31. def writeHead(statusCode: Double, statusMessage: Unit, headers: OutgoingHttpHeaders): ServerResponse.this.type
  32. def writeHead(statusCode: Double, statusMessage: String, headers: Array[OutgoingHttpHeader]): ServerResponse.this.type
  33. def writeHead(statusCode: Double, statusMessage: String, headers: OutgoingHttpHeaders): ServerResponse.this.type
  34. def writeHead(statusCode: Double, statusMessage: String): ServerResponse.this.type
  35. def writeHead(statusCode: Double, headers: Array[OutgoingHttpHeader]): ServerResponse.this.type
  36. def writeHead(statusCode: Double, headers: OutgoingHttpHeaders): ServerResponse.this.type
  37. def writeHead(statusCode: Double): ServerResponse.this.type

    Sends a response header to the request.

    Sends a response header to the request. The status code is a 3-digit HTTP status code, like 404. The last argument, headers, are the response headers. Optionally one can give a human-readable statusMessage as the second argument.

    headers may be an Array where 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. The array is in the same format as request.rawHeaders.

    Returns a reference to the ServerResponse, so that calls can be chained.

    js const body = 'hello world'; response .writeHead(200, { 'Content-Length': Buffer.byteLength(body), 'Content-Type': 'text/plain' }) .end(body);

    This method must only be called once on a message and it must be called before response.end() is called.

    If response.write() or response.end() are called before calling this, the implicit/mutable headers will be calculated and call this function.

    When headers have been set with response.setHeader(), they will be merged with any headers passed to response.writeHead(), with the headers passed to response.writeHead() given precedence.

    If this method is called and response.setHeader() has not been called, it will directly write the supplied header values onto the network channel without caching internally, and the response.getHeader() on the header will not yield the expected result. If progressive population of headers is desired with potential future retrieval and modification, use response.setHeader() instead.

    js // Returns content-type = text/plain const server = http.createServer((req, res) => { res.setHeader('Content-Type', 'text/html'); res.setHeader('X-Foo', 'bar'); res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('ok'); });

    Content-Length is given in bytes, not characters. Use Buffer.byteLength() to determine the length of the body in bytes. Node.js does not check whether Content-Length and the length of the body which has been transmitted are equal or not.

    Attempting to set a header field name or value that contains invalid characters will result in a TypeError being thrown.

    Since

    v0.1.30

  38. def writeProcessing(): Unit

    Sends a HTTP/1.1 102 Processing message to the client, indicating that the request body should be sent.

    Sends a HTTP/1.1 102 Processing message to the client, indicating that the request body should be sent.

    Since

    v10.0.0

Deprecated Value Members

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