SQL Server
SQL Server
Example: Http.HasRequestHeader method
Demonstrates theHasRequestHeader method.
Chilkat SQL Server Downloads
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @http int
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'X-CSRF-Token', 'Fetch'
DECLARE @b int
EXEC sp_OAMethod @http, 'HasRequestHeader', @b OUT, 'X-CSRF-Token'
IF @b = 1
BEGIN
PRINT 'X-CSRF-Token: Yes'
END
ELSE
BEGIN
PRINT 'X-CSRF-Token: No'
END
EXEC sp_OAMethod @http, 'HasRequestHeader', @b OUT, 'X-Something'
IF @b = 1
BEGIN
PRINT 'X-Something: Yes'
END
ELSE
BEGIN
PRINT 'X-Something: No'
END
-- The Accept and Accept-Encoding headers are default headers automatically added,
-- unless the application chooses to remove by calling RemoveRequestHeader for each.
EXEC sp_OAMethod @http, 'HasRequestHeader', @b OUT, 'Accept'
IF @b = 1
BEGIN
PRINT 'Accept: Yes'
END
ELSE
BEGIN
PRINT 'Accept: No'
END
-- Output:
-- X-CSRF-Token: Yes
-- X-Something: No
-- Accept: Yes
EXEC @hr = sp_OADestroy @http
END
GO