Encodes a table of key-value pairs into a single URL-encoded string
Agent
Name | Type | Description |
---|---|---|
dataTable | Table |
The key-value pair(s) to be encoded
|
This method performs URL encoding, as defined in the RFC3986 specification, sections 2.1 to 2.3. The encoded form is often needed when the agent is interacting with web services: for instance, query strings in the URL of an HTTP GET request must be URL-encoded, in case they contain any of the ‘reserved’ characters:
{ " : / ? # @ ! $ & ' ( ) * + , ; = }
The table passed to the method as its parameter should contain key-value pairs, where the keys are strings and the values are either strings, integers or floats — or arrays of strings, integers or floats. Arrays may not be nested: more complex compound data should probably be sent in JSON format instead.
The corresponding decoding operation is http.urldecode().
As an example of how it would be used in practice, here’s some agent code that takes a table of data from an imp and encodes it for sending as if POST-ed by an HTML form.