SendHTTPResponse Method
Send the HTTP response.
Syntax
public void sendHTTPResponse(String connectionId, int statusCode, String statusDescription, byte[] responseData);
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);