sendHTTPResponse (method)

Send the HTTP response.

Syntax

- (void)sendHTTPResponse:(int)connectionId :(int)statusCode :(NSString*)statusDescription :(NSData*)responseData;
public func sendHTTPResponse(_ connectionId: Int32, _ statusCode: Int32, _ statusDescription: String, _ responseData: Data) throws -> Void

Remarks

This method sends an HTTP response to the HTTP request identified by ConnectionId.

The response status code and description, as well as the response body, are sent to the client using this method. The ConnectionId value should be obtained from the HTTPRequest event.

StatusCode is the three digit HTTP status code to return, for instance 200.

StatusDescription is the text corresponding to the StatusCode. For instance OK.

ResponseBody specifies the body to be sent back to the client (if any).

Code Example (HTTP)


Azurerelaylistener listener = new Azurerelaylistener();
listener.AccessKey = "9oKRDwjl0s440MlLUi4qHxDL34j1FS6K3t5TRoJ216c=";
listener.AccessKeyName = "RootManageSharedAccessKey";
listener.NamespaceAddress = "myrelay.servicebus.windows.net";
listener.HybridConnection = "hc1";

listener.OnHTTPRequest += (s, e) => {
  Console.WriteLine("HTTP Request from " + e.RemoteAddress + ":" + e.RemotePort);
  Console.WriteLine("HTTP Method: " + e.RequestMethod);
  Console.WriteLine("HTTP Request: " + e.RequestData);
  myConnectionId = e.ConnectionId;
};

//Send a response using the ConnectionId value from the HTTPRequest event
listener.SendHTTPResponse(myConnectionId, 200, "OK", myResponseBody);

Copyright (c) 2022 /n software inc. - All rights reserved.
IPWorks MQ 2020 iOS Edition - Version 20.0 [Build 8155]