HTTP Request Header Management

HTTP request headers can be added, changed, or removed with the HEADER clause of the CREATE PROCEDURE and CREATE FUNCTION statements. You suppress an HTTP request header by referencing the name. You add or change an HTTP request header value by placing a colon after the header name following by the value. Header value specifications are optional.

For example, execute the following SQL statement in the web client database to create a procedure named SomeOperation2 that sends requests to the specified URL that puts restrictions on HTTP request headers:

CREATE PROCEDURE SomeOperation2()
    URL 'HTTP://localhost:8082/dbname/SampleWebService'
    TYPE 'HTTP:GET'
    HEADER 'SOAPAction\nDate\nFrom:\nCustomAlias:John Doe';

In this example, the Date header, which is automatically generated by SAP Sybase IQ, is suppressed. The From header is included but is not assigned a value. A new header named CustomAlias is included in the HTTP request and is assigned the value of John Doe. The GET request looks similar to the following:

GET /dbname/SampleWebService HTTP/1.0
ASA-Id: e88a416e24154682bf81694feaf03052
User-Agent: SybaseIQ/16.0.0.3600
Accept-Charset: windows-1252, UTF-8, *
From: 
Host: localhost:8082
Connection: close
CustomAlias: John Doe

Folding of long header values is supported, provided that one or more white spaces immediately follow the \n.

The following example illustrates long header value support:

CREATE PROCEDURE SomeOperation3()
    URL 'HTTP://localhost:8082/dbname/SampleWebService'
    TYPE 'HTTP:POST'
    HEADER 'heading1: This long value\n is really long for a header.\n 
    heading2:shortvalue';

The POST request looks similar to the following:

POST /dbname/SampleWebService HTTP/1.0
ASA-Id: e88a416e24154682bf81694feaf03052
User-Agent: SybaseIQ/16.0.0.3600
Accept-Charset: windows-1252, UTF-8, *
Date: Fri, 03 Feb 2012 15:26:04 GMT
heading1: This long value is really long for a header.     heading2:shortvalue
Host: localhost:8082
Connection: close
Content-Type: application/x-www-form-urlencoded; charset=windows-1252
Content-Length: 0
Note: You must set the SOAPAction HTTP request header to the given SOAP service URI as specified in the WSDL when creating a SOAP function or procedure.

Automatically generated HTTP request headers

Modifying automatically generated headers can have unexpected results. The following HTTP request headers should not be modified without precaution:

HTTP header Description
Accept-Charset Always automatically generated. Changing or deleting this header may result in unexpected data conversion errors.
ASA-Id Always automatically generated. This header ensures that the client application does not connect to itself to prevent deadlock.
Authorization Automatically generated when URL contains credentials. Changing or deleting this header may result in failure of the request. Only BASIC authorization is supported. User and password information should only be included when connecting via HTTPS.
Connection Connection: close, is always automatically generated. Client applications do not support persistent connections. The connection could hang if changed.
Host Always automatically generated. HTTP/1.1 servers are required to respond with 400 Bad Request if an HTTP/1.1 client does not provide a Host header.
Transfer-Encoding Automatically generated when posting a request in chunk mode. Removing this header or deleting the chunked value will result in failure when the client is using CHUNK mode.
Content-Length Automatically generated when posting a request and not in chunk mode. This header is required to tell the server the content length of the body. If the content length is wrong the connection may hang or data loss could occur.