3using System.Threading.Tasks;
18 : base(
"/.well-known/host-meta")
22 public override bool HandlesSubPaths =>
false;
23 public override bool UserSessions =>
false;
33 if (
string.IsNullOrEmpty(ContentType))
37 StringBuilder Xml =
new StringBuilder();
41 Xml.Append(
"<?xml version='1.0'?><XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>");
43 if (HttpsPorts.Length > 0 || HttpPorts.Length > 0)
45 AppendLink(Xml, HttpsPorts, HttpPorts,
Gateway.
Domain,
"urn:xmpp:alt-connections:xbosh",
"http",
"/http-bind");
46 AppendLink(Xml, HttpsPorts, HttpPorts,
Gateway.
Domain,
"urn:xmpp:alt-connections:websocket",
"ws",
"/xmpp-websocket");
51 Response.ContentType = ContentType;
52 return Response.
Write(Xml.ToString());
55 public static string BoshLink(
string Domain)
57 StringBuilder sb =
new StringBuilder();
61 AppendLink(sb, HttpsPorts, HttpPorts, Domain,
"http",
"/http-bind");
66 public static string WebSocketLink(
string Domain)
68 StringBuilder sb =
new StringBuilder();
72 AppendLink(sb, HttpsPorts, HttpPorts, Domain,
"ws",
"/xmpp-websocket");
77 private static void AppendLink(StringBuilder Xml,
int[] HttpsPorts,
int[] HttpPorts,
78 string Domain,
string Type,
string Protocol,
string Resource)
80 Xml.Append(
"<Link rel='");
82 Xml.Append(
"' href='");
83 AppendLink(Xml, HttpsPorts, HttpPorts, Domain, Protocol, Resource);
87 private static void AppendLink(StringBuilder Xml,
int[] HttpsPorts,
int[] HttpPorts,
88 string Domain,
string Protocol,
string Resource)
92 if (HttpsPorts.Length > 0)
100 Xml.Append(HttpsPorts[0].ToString());
111 Xml.Append(HttpPorts[0].
ToString());
115 Xml.Append(Resource);
static readonly string[] XmlContentTypes
XML content types.
const string DefaultContentType
Default content type for XML documents.
Static class managing the runtime environment of the IoT Gateway.
static CaseInsensitiveString Domain
Domain name.
static int[] GetConfigPorts(string Protocol)
Gets the port numbers defined for a given protocol in the configuration file.
Represents an HTTP request.
HttpRequestHeader Header
Request header.
Represets a response of an HTTP client request.
async Task Write(byte[] Data)
Returns binary data in the response.
Implements an HTTP server.
const int DefaultHttpPort
Default HTTP Port (80).
const int DefaultHttpsPort
Default HTTPS port (443).
Base class for all synchronous HTTP resources. A synchronous resource responds within the method hand...
The resource identified by the request is only capable of generating response entities which have con...
GET Interface for HTTP resources.
delegate string ToString(IElement Element)
Delegate for callback methods that convert an element value to a string.