3using System.Threading.Tasks;
34 public static bool IsLocal(
string Uri,
bool CheckExists)
36 if (!
System.Uri.TryCreate(Uri, UriKind.RelativeOrAbsolute, out Uri Parsed))
39 return IsLocal(Parsed, CheckExists);
58 public static bool IsLocal(Uri Uri,
bool CheckExists)
60 if (Uri.IsAbsoluteUri)
64 switch (Uri.Scheme.ToLower())
81 if (
string.Compare(Uri.Host,
"localhost",
true) != 0 &&
87 if (Array.IndexOf(Ports, Uri.Port) < 0)
106 Log.
Error(
"Attempt to check local resource failed with exception: " + ex.Message);
110 if (!
string.IsNullOrEmpty(SubPath))
112 if (!Resource.HandlesSubPaths)
129 public static async Task<ContentResponse>
GetAsync(Uri Uri, params KeyValuePair<string, string>[] Headers)
137 string ContentType = T.Item2;
138 byte[] Bin = T.Item3;
140 if (Code < 200 || Code >= 300)
152 public static Task<ContentStreamResponse>
GetTempStreamAsync(Uri Uri, params KeyValuePair<string, string>[] Headers)
172 string ContentType = T.Item2;
173 byte[] Bin = T.Item3;
175 if (Code < 200 || Code >= 300)
178 bool DestinationCreated =
false;
180 if (Destination is
null)
183 DestinationCreated =
true;
188 await Destination.
WriteAsync(Bin, 0, Bin.Length);
192 if (DestinationCreated)
Contains information about a response to a content request.
Contains information about a stream response to a content request.
Static class managing encoding and decoding of internet content.
static Task< ContentStreamResponse > GetTempStreamAsync(Uri Uri, params KeyValuePair< string, string >[] Headers)
Gets a (possibly big) resource, given its URI.
static Task< ContentResponse > DecodeAsync(string ContentType, byte[] Data, Encoding Encoding, KeyValuePair< string, string >[] Fields, Uri BaseUri)
Decodes an object.
static Task< ContentResponse > GetAsync(Uri Uri, params KeyValuePair< string, string >[] Headers)
Gets a resource, given its URI.
Static class managing the application event log. Applications and services log events on this static ...
static void Error(string Message, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, string StackTrace, params KeyValuePair< string, object >[] Tags)
Logs an error event.
Static class managing the runtime environment of the IoT Gateway.
static HttpServer HttpServer
HTTP Server
static bool IsDomain(string DomainOrHost, bool IncludeAlternativeDomains)
If a domain or host name represents the gateway.
static X509Certificate2 Certificate
Domain certificate.
Static class that gives access to local content published by the gateway, without having to perform r...
static bool IsLocal(Uri Uri)
Checks if a Uri is local to the gateway.
static async Task< ContentStreamResponse > GetTempStreamAsync(Uri Uri, TemporaryStream Destination, params KeyValuePair< string, string >[] Headers)
Gets a (possibly big) resource, given its URI.
static bool IsLocal(string Uri, bool CheckExists)
Checks if a Uri is local to the gateway.
static bool IsLocal(Uri Uri, bool CheckExists)
Checks if a Uri is local to the gateway.
static async Task< ContentResponse > GetAsync(Uri Uri, params KeyValuePair< string, string >[] Headers)
Gets a resource, given its URI.
static Task< ContentStreamResponse > GetTempStreamAsync(Uri Uri, params KeyValuePair< string, string >[] Headers)
Gets a (possibly big) resource, given its URI.
static bool IsLocal(string Uri)
Checks if a Uri is local to the gateway.
Base class of all HTTP Exceptions.
static string GetStatusMessage(int StatusCode)
Gets the default status message, given a status code.
Base class for all HTTP resources.
int[] OpenHttpPorts
HTTP Ports successfully opened.
bool TryGetResource(HttpRequest Request, out HttpResource Resource, out string SubPath)
Tries to get a resource from the server.
bool TryGetFileName(string LocalUrl, out string FileName)
Tries to get the full path of a file-based resource.
int[] OpenHttpsPorts
HTTPS Ports successfully opened.
async Task< Tuple< int, string, byte[]> > GET(string LocalUrl, SessionVariables Session)
Performs an internal GET operation.
Collection of session variables.
Manages a temporary stream. Contents is kept in-memory, if below a memory threshold,...
override void Dispose(bool disposing)
Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed res...
override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
Asynchronously writes a sequence of bytes to the current stream, advances the current position within...