Class $k.NetEntity
Abstract superclass of entities that are sent or received over the internet
- Defined in: NetEntity.js Extended by: $k.HttpResponse, $k.MailMessage, $k.HttpRequest
Constructor Attributes | Constructor Name and Description |
---|---|
Method Summary
Class Detail
$k.NetEntity()
Method Detail
-
attach(attachment)Attach a entity
- Parameters:
- {$k.NetEntity} attachment
- Throws:
- {$k.exception.TypeError}
- If the entity is not a valid attachment
-
Returns the attached entities
- Returns:
- {$k.NetEntity[]}
-
{string} base64String()Get the binay contents as base64-encoded string. Returns undefined if the contents is not binary
- Returns:
- {string}
-
{string} charset()Returns the charset
- Returns:
- {string}
-
{string} contentDisposition()Returns the content disposition
- Returns:
- {string}
-
{number} contentLength()Returns the content length
- Returns:
- {number}
-
{string} contentType()Returns the content type (only the media type part)
- Returns:
- {string}
-
{string} dataUrl()Returns the entity bytes as a data URL, or undefined if the entity is not binary
- Returns:
- {string}
- See:
- http://dataurl.net/#about
-
{string} debugString()Prints the entity, except binary contents, for debugging purposes
- Returns:
- {string}
-
{string} filename()Returns the filename part of the content disposition field
- Returns:
- {string}
-
{object} formData()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)
- Returns:
- {object}
- See:
- $k.NetEntity
-
{String} headerField(fieldName)Get the unparsed value of the field of the request header. Returns undefined if the field does not exist
- Parameters:
- {string} fieldName
- Returns:
- {String} The field value
-
{object} headerFields()Get all fields of the request header
- Returns:
- {object}
-
{boolean} isBinary()True if the entity has binary contents
- Returns:
- {boolean}
-
setCharset(charset)Set the charset
- Parameters:
- {string} charset
- Throws:
- {$k.exception.InvalidValue}
- If the charset is unknown
-
setContentDisposition(contentDisposition)Set the content disposition
- Parameters:
- {string} contentDisposition
-
setContentLength(length)Set the content length
- Parameters:
- {number} length
-
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
- Parameters:
- contents
- Contents object
- See:
- $k.Blob
- $k.TextDocument
-
setContentType(mediaType, charset)Set the content type
- Parameters:
- {string} mediaType
- Media type of the contents
- {string} charset Optional
- Charset of the contents
-
setFilename(filename)Set the filename part of the content disposition field
- Parameters:
- {string} filename
-
setHeaderField(fieldName, fieldValue)Set the value of the field of the request header
- Parameters:
- {string} fieldName
- fieldValue
- Throws:
- {$k.exception.TypeError}
- If the value does not match the type of the field
-
setText(text)Set the text as the body
- Parameters:
- {string} text
-
{string} text(charset)Get the contents as string
- Parameters:
- {string} charset
- Charset of the characters. Required for binary entities. Optional for text entities.
- Returns:
- {string}