JSHttpMessage


Properties

headers

An array of JSHeader objects. In a string context returns the raw headers (it may also be assigned a string which is parsed as the raw headers).

body

A string containing the body. This may be empty if the body hasn't been read yet (see readBody() and hasMoreBody). The body is automatically ungzipped or deflated if the header Content-Encoding is gzip or deflate (and automatically gzipped or deflated when a string is assigned).

hasMoreBody

A boolean value. True if the entire body is in memory (or if there is no body). read-only

contentLength

A best guess for the length of the body (taken from the Content-Length header, or the default for the request/response). If this is -1 the body will be read until the connection closes.

contentType

A best guess for the content-type. This is usually taken from the Content-Type header.

boundary

The boundary string for messages whose content type is multipart/*. May be null (or a random string) if the message is not a multipart message.

src

The source JSConnection for this message (i.e. the Connection from which this message was read). The properties of this connection are read-only.

dst

The destination JSConnection for this message (i.e. the Connection to which this message is to be written).

Methods

readBody()

Read the entire body into memory (if it hasn't already been read). This is a blocking operation, so for large bodies it may consume a lot of memory and cause a performance hit.

Example

// Read the body into memory
msg.readBody();
// Replace every occurrence of "OriginalRegexp" in the
// body by "New String"
msg.body = msg.body.replace(/OriginalRegexp/g, "New String");