Form Data Encoding

The Silk Performer Web API uses form definitions within the dclform section of BDL scripts to specify form data that is to be submitted and query strings to be appended to URLs.

Unsafe characters must be encoded within query strings and HTTP request bodies. To accommodate the various encoding strategies used by different browsers in different situations, Silk Performer allows for the specification of encoding types for form fields.

This is accomplished using the enhanced syntax for form definitions within BDL, which allows for the specification of attributes for forms and form fields.

Encoding Types

The encoding type ENCODE_FORM encodes unsafe characters according to the mime type application/x-www-form-url-encoded. Blank spaces are encoded with + symbols, unsafe characters are encoded by their hexadecimal values preceded by % symbols.

All popular browsers use this encoding type for form submissions, both for URL query strings (HTTP method GET) and HTTP request bodies (HTTP method POST).

The encoding type ENCODE_FORM is the default when no other encoding type is specified in scripts, and therefore does not have to be specified explicitly.

The encoding type ENCODE_ESCAPE encodes unsafe characters according to the escape JavaScript function. This encoding type is similar to ENCODE_FORM. The main difference is that blank spaces are encoded with %20 rather than +.

The encoding type ENCODE_BLANKS encodes blank spaces with %20. No other unsafe characters are encoded. Most popular browsers use this encoding type for the target URLs of links.

The encoding type ENCODE_NONE does not encode any characters. This encoding type is often used when JavaScript issues HTTP requests without using the escape function.

Examples

dclform
  AD_SERVER_PARAMS <ENCODE_NONE>:
    "~userpref"     := "12|34|56",
    "~requesttime"  := "01/01/2002";
  FORM_REDIR_LOGIN <ENCODE_NONE> :
    "~language"     := "EN",
    "~logingroup"   := "GUEST",
    "~transaction"  := "TEST",
    "~exitUrl"      := "http://www.myserver.com/goodbye.html";
  LOGIN_FORM_001:
    "username"      := "testuser",
    "password"      := "testpassword",
    "hash"          := "%u2e34!\"" <ENCODE_NONE>,
    "platform"      := "OS: Win2000, Browser: IE5.5" <ENCODE_BLANKS>;
  DOWNLOAD_WHITEPAPER <ENCODE_BLANKS>:
    "filename"      := "Context management.pdf",
    "version"       := "V99";
Note: The Silk Performer recorder automatically determines the most suitable encoding type and generates scripts accordingly. The recorder omits the encoding type ENCODE_FORM (the default) to make scripts more readable.