Archived Forum Post

Index of archived forum posts

Question:

Re-use an HTTP object, change a parameter, and re-send a POST

Jun 18 '12 at 10:32

Once I have sent an HTTP Post within a sql server procedure, I need to send a 2nd Post to the same target but with one or two changed parameters. I would prefer to do it inside the same procedure.

Does EXEC sp_OAMethod @http, 'SynchronousRequest', @resp OUT, @domain, @port, @ssl, @req also destroy the @http and @req objects? And if not, how can I delete one or more of the parameters, recreate them with different values, then resend the POST? Is there a 'DeleteParm' sort of method?

Or do I need to explicitly destroy and re-create everything from scratch again?

Thanks, Doug


Answer

The Chilkat HTTP object will keep the connection open if possible. If the HTTP response contains a "Connection: Close" header, then the server is telling the client that it should close the connection and that the next request should be on a new connection.

The Chilkat HTTP object automatically handles it. Whenever a method is called that requires an HTTP connection to a server, the object will automatically use the existing connection, or will automatically open a new connection if needed. Therefore, you should be able to simply call SynchronousRequest again on the same object instance.

If there is a problem, and you are using an older version, then best thing to do is to test with the very latest version.

If there is still a problem, you can force a new connection by calling http.CloseAllConnections().