new $k.NetEntity()
Abstract superclass of entities that are sent or received over the internet
Methods
attach(attachment)
Attach a entity
Name | Type | Description |
---|---|---|
attachment |
$k.NetEntity |
Throws:
Type | Description |
---|---|
$k.exception.TypeError | If the entity is not a valid attachment |
attachments() : Array.<$k.NetEntity>
Returns the attached entities
Returns:
Type | Description |
---|---|
Array.<$k.NetEntity> |
base64String() : string
Get the binay contents as base64-encoded string. Returns undefined if the contents is not binary
Returns:
Type | Description |
---|---|
string |
charset() : string
Returns the charset
Returns:
Type | Description |
---|---|
string |
contentDisposition() : string
Returns the content disposition
Returns:
Type | Description |
---|---|
string |
contentLength() : number
Returns the content length
Returns:
Type | Description |
---|---|
number |
contentType() : string
Returns the content type (only the media type part)
Returns:
Type | Description |
---|---|
string |
dataUrl() : string
Returns the entity bytes as a data URL, or undefined if the entity is not binary
Returns:
Type | Description |
---|---|
string |
debugString() : string
Prints the entity, except binary contents, for debugging purposes
Returns:
Type | Description |
---|---|
string |
filename() : string
Returns the filename part of the content disposition field
Returns:
Type | Description |
---|---|
string |
formData() : object
Get all form fields (multipart/form-data or application/x-www-form-urlencoded).
The property names correspond to the field names.
The property values are either strings (if the form is of type application/x-www-form-urlencoded) or NetEntities (multipart/form-data)
- See:
Returns:
Type | Description |
---|---|
object |
headerField(fieldName) : String
Get the value of the field of the request header. Returns undefined if the field does not exist
Name | Type | Description |
---|---|---|
fieldName |
string |
Returns:
Type | Description |
---|---|
String | The field value |
headerFields() : object
Get all fields of the request header. Field names are always lower case
Returns:
Type | Description |
---|---|
object |
isBinary() : boolean
True if the entity has binary contents
Returns:
Type | Description |
---|---|
boolean |
setCharset(charset)
Set the charset
Name | Type | Description |
---|---|---|
charset |
string |
Throws:
Type | Description |
---|---|
$k.exception.InvalidValue | If the charset is unknown |
setContentDisposition(contentDisposition)
Set the content disposition
Name | Type | Description |
---|---|---|
contentDisposition |
string |
setContentLength(length)
Set the content length
Name | Type | Description |
---|---|---|
length |
number |
setContents(contents)
Set the contents of the entity. Also sets the content type and filename if known.
The contents object can be a string, document ($k.TextDocument), a blob value ($k.Blob) or another NetEntity
Name | Type | Description |
---|---|---|
contents |
Contents object |
- See:
setContentType(mediaType, charset)
Set the content type
Name | Type | Description |
---|---|---|
mediaType |
string |
Media type of the contents |
charset |
string |
optional
Charset of the contents |
setFilename(filename)
Set the filename part of the content disposition field
Name | Type | Description |
---|---|---|
filename |
string |
setHeaderField(fieldName, fieldValue)
Set the value of the field of the request header
Name | Type | Description |
---|---|---|
fieldName |
string | |
fieldValue |
Throws:
Type | Description |
---|---|
$k.exception.TypeError | If the value does not match the type of the field |
setText(text)
Set the text as the body
Name | Type | Description |
---|---|---|
text |
string |
text(charset) : string
Get the contents as string
Name | Type | Description |
---|---|---|
charset |
string |
Charset of the characters. Required for binary entities. Optional for text entities. |
Returns:
Type | Description |
---|---|
string |