Http sender device interface changes in 15.1

Version 15.1 changes the custom code interface of the Http sender device. In previous versions there were 2 methods exposed in the Http sender device:

public override void BeforeSendRequest(HttpRequestMessage request) { // called immediately before sending the request } public override void AfterResponseReceived(HttpResponseMessage response) { // called when a response is received (before optionally saving the results) }

This interface has been replaced with a single method:

public override async Task ProcessHttpRequestAsync(RequestContext request) { // before logic here await SendAsync(request, request.MessageContext, true); // after logic here }

You can place any logic to run before the http call above the SendAsync call, and any logic to run after the http call below the SendAsync call. The HttpRequestMessage object is no longer exposed. Instead, the methods used to convert the message context to the http request are overrideable as well as options exposed to allow more fine-tuned control over the send variables. The HttpResponseMessage object is exposed under the RequestContext object.

The following methods are available for overriding:

protected virtual MultipartFormDataContent GetMultipartContent(IMessageContext context, string payloadKey) { // converts the current message, and attachment(s) to a MultipartFormDataContent. The binary // portion (the attachment(s)) are included. } protected virtual FormUrlEncodedContent GetContent(IMessageContext context, string payloadKey) { // converts the current message object to a string and returns a FormUrlEncodedContent } protected virtual FormUrlEncodedContent GetContent(string message, string payloadKey) { // converts a string message and key to FormUrlEncodedContent } protected virtual HttpContent GetRAW(IMessageContext context) { // used when the sendType is set to raw. // If the context.message is a string, a StringContent is returned. // If the context.message is a IEnumerable<KeyValuePair<string, string>>, and FormUrlEncodedContent is returned. }