sa_set_http_option system procedure

Permits a web service to set an HTTP option in the result.

Syntax
sa_set_http_option( 
optname, 
val 
 )
Arguments
  • optname   Use this CHAR(128) parameter to specify a string containing the name of one of the HTTP options.

  • val   Use this LONG VARCHAR parameter to specify the value to which the named option should be set.

Remarks

Use this procedure within statements or procedures that handle web services to set options within an HTTP result set.

The supported options are:

  • CharsetConversion   Use this option to control whether the result set is to be automatically converted from the character set of the database to the character set of the client. The only permitted values are ON and OFF. The default value is ON. See Using automatic character set conversion.

  • AcceptCharset   Use this option to specify the HTTP server preferences for the character sets used in an XML, SOAP, and HTTP web service. The syntax for this option conforms to the syntax used for the HTTP Accept-Charset request-header field specification in RFC2616 Hypertext Transfer Protocol. That is, permitted values are character set labels. For example, sa_set_http_option( 'AcceptCharset', 'UTF-8, Shift_JIS' ). You may also include a quality value (q) for a character set label, indicating the degree of preference. For example, sa_set_http_option( 'AcceptCharset', 'UTF-8; q=0.9, Shift_JIS' ).

    The final list of acceptable character sets is an intersection of the values in the client's Accept-Charset HTTP request-header field, and the values in the server AcceptCharset option. The quality values specified in the client request are respected such that the most preferred character set specified by the client is used when possible. Following are some possible scenarios for determining the list of acceptable character sets:

    • If the client request does not specify a Accept-Charset value, the server AcceptCharset option is used to determine the character set.
    • If the server AcceptCharset option is not specified, the client Accept-Charset request-header field value is used to determine the character set.
    • If neither the server AcceptCharset option, nor the client Accept-Charset request-header field, are specified, the database character set is used. For a SOAP request, the encoding used in the request is also used for the response.
    • If both the server AcceptCharset option, and the client Accept-Charset request-header field, are specified, then:
      1. If a match is found, that character set is used. If more than one match is found, the character set with the highest q-value in the client Accept-Charset request-header field is used.
      2. If no match is found, the character set specified in client's Accept-Charset request-header field is used.

    SQL Anywhere also allows you to specify a plus sign (+) to indicate the server preference for using the database character set if possible. For example, sa_set_http_option( 'AcceptCharset', 'UTF-8, +' ). When specified, if the list of character sets in the client Accept-Charset request-header field includes the database character set, that character set is automatically used, regardless of any quality values, and regardless of the order of matches found. This minimizes the need for character set conversion.

  • SessionId   Use this option to supply a name for an HTTP session. For example, sa_set_http_option( 'SessionId', 'my_app_session_1' ) sets the ID for an HTTP session to my_app_session_1. SessionId must be a non-NULL string. For more information about HTTP sessions, see Using HTTP sessions.

Permissions

None

Side effects

None

See also