Class: Body

$.web. Body

$.web.Body represents the body of an HTTP request entity.

new Body()

Provides access to the data included in the body of the HTTP request entity.

Methods

asArrayBuffer() → {ArrayBuffer}

Returns the content of an HTTP request entity body as ArrayBuffer.
Returns:
The content of the HTTP request entity body as ArrayBuffer.
Type
ArrayBuffer

asString() → {string}

Returns the content of an HTTP request entity body as a string.
Returns:
The content of the HTTP request entity body as string.
Type
string

asWebRequest() → {$.web.WebRequest}

Returns the content of an HTTP request entity body as WebRequest.
See:
  • $.web.WebEntityResponse.setBody()
Throws:
Throws an error if the request entity body is not formatted according to the HTTP standard.
Returns:
The content of the HTTP request entity body as WebRequest.
Type
$.web.WebRequest
Example
// Handling of multipart requests and responses in xsjs files:
var i;
var n = $.request.entities.length;
var client = new $.net.http.Client();
for (i = 0; i < n; ++i) {
   var childRequest = $.request.entities[i].body.asWebRequest();
   client.request(childRequest, childRequest.headers.get("Host") + childRequest.path);
   var childResponse = client.getResponse();
   var responseEntity =  $.response.entities.create();
   responseEntity.setBody(childResponse);
}