new HttpRequest(url, methodopt, queryDataopt)
Creates a new request
Name | Type | Attributes | Description |
---|---|---|---|
url | string | HTTP(S) URL | |
method | string | <optional> | Request method (GET, POST etc.). If undefined, GET is used |
queryData | object | <optional> | Query data |
If the URL is invalid
A HTTP request
Extends
Methods
(static) current() → {$k.HttpRequest}
Returns the current incoming HttpRequest, or undefined if no request is active
Only supported in the following application environment(s): rest
- Since
- 5.4.0
- Type:
- $k.HttpRequest
(static) fromEncodedURL(url, methodopt, queryDataopt)
Creates a new request. THe URL must be already URL-encoded by the sender
Name | Type | Attributes | Description |
---|---|---|---|
url | string | HTTP(S) URL | |
method | string | <optional> | Request method (GET, POST etc.). If undefined, GET is used |
queryData | object | <optional> | Query data |
- Version
- Experimental feature, might be removed at any time
- Since
- 5.3.2
If the URL is invalid
attach(attachment)
Attach a entity
Name | Type | Description |
---|---|---|
attachment | $k.NetEntity |
- Inherited From
If the entity is not a valid attachment
attachments() → {Array.<$k.NetEntity>}
Returns the attached entities
- Inherited From
- Type:
- Array.<$k.NetEntity>
base64String() → {string}
Get the binay contents as base64-encoded string. Returns undefined if the contents is not binary
- Inherited From
- Type:
- string
charset() → {string}
Returns the charset
- Inherited From
- Type:
- string
contentDisposition() → {string}
Returns the content disposition
- Inherited From
- Type:
- string
contentLength() → {number}
Returns the content length
- Inherited From
- Type:
- number
contentType() → {string}
Returns the content type (only the media type part)
- Inherited From
- Type:
- string
cookies() → {object}
Returns the cookies as an object. The name of a property is the cookie name
- Type:
- object
dataUrl() → {string}
Returns the entity bytes as a data URL, or undefined if the entity is not binary
- Inherited From
- Type:
- string
debugString() → {string}
Prints the entity, except binary contents, for debugging purposes
- Inherited From
- Type:
- string
filename() → {string}
Returns the filename part of the content disposition field
- Inherited From
- Type:
- 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)
- Inherited From
- See
- Type:
- 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 |
- Inherited From
The field value
- Type:
- string
headerFields() → {object}
Get all fields of the request header. Field names are always lower case
- Inherited From
- Type:
- object
isBinary() → {boolean}
True if the entity has binary contents
- Inherited From
- Type:
- boolean
method() → {string}
Returns the requests HTTP method
HTTP method value of this request
- Type:
- string
queryData() → {object}
Returns the query data of the request as an object. If the request method is GET, then this is equivalent to urlQueryData(). For other methods it returns application/x-www-form-urlencoded key/value pairs
- Type:
- object
removeHeaderField(fieldName)
Removes the field of the request heade
Name | Type | Description |
---|---|---|
fieldName | string |
- Since
- 5.0.3
- Inherited From
setCharset(charset)
Set the charset
Name | Type | Description |
---|---|---|
charset | string |
- Inherited From
If the charset is unknown
setContentDisposition(contentDisposition)
Set the content disposition
Name | Type | Description |
---|---|---|
contentDisposition | string |
- Inherited From
setContentLength(length)
Set the content length
Name | Type | Description |
---|---|---|
length | number |
- Inherited From
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 |
- Inherited From
setContentType(mediaType, charsetopt)
Set the content type
Name | Type | Attributes | Description |
---|---|---|---|
mediaType | string | Media type of the contents | |
charset | string | <optional> | Charset of the contents |
- Inherited From
setFilename(filename)
Set the filename part of the content disposition field
Name | Type | Description |
---|---|---|
filename | string |
- Inherited From
setFormData(formData)
Sets the url-encoded form data of the request
Name | Type | Description |
---|---|---|
formData | object |
setHeaderField(fieldName, fieldValue)
Set the value of the field of the request header
Name | Type | Description |
---|---|---|
fieldName | string | |
fieldValue |
- Inherited From
If the value does not match the type of the field
setQueryData(queryData)
Sets the query data of the URI. Each property is added as a query parameter (key=value). If the value of a property is an arry, then a key=value pair is added for each array element.
Name | Type | Description |
---|---|---|
queryData | object |
setText(text)
Set the text as the body
Name | Type | Description |
---|---|---|
text | string |
- Inherited From
setUrl(url)
Sets the URL
Name | Type | Description |
---|---|---|
url | string |
If the URL is not valid
text(charsetopt) → {string}
Get the contents as string
Name | Type | Attributes | Description |
---|---|---|---|
charset | string | <optional> | Charset of the characters. Required for binary entities. Optional for text entities. |
- Inherited From
- Type:
- string
url() → {string}
Returns the full URL
- Type:
- string
urlQueryData() → {object}
Returns the URL query data of the URI as an object. Each key=value pair is added as a property. If a key appears more than once, then the value is an array with all elements
- Type:
- object