5using System.Threading.Tasks;
23 private readonly
string userVariable;
24 private readonly
string[] userPrivileges;
35 params
string[] UserPrivileges)
39 this.webServer = WebServer;
40 this.userVariable = UserVariable;
41 this.userPrivileges = UserPrivileges;
68 int i = s.IndexOf(
'/');
73 bool Forbidden =
false;
84 if (Session is
null ||
86 !(v.ValueObject is
IUser User))
92 foreach (
string Privilege
in this.userPrivileges)
94 if (!User.HasPrivilege(Privilege))
129 if (!(Data.
Decoded is
string[][] Records) || !
this.HasColumns(Records, 2))
136 if (!(Accept is
null) && !Accept.
IsAcceptable(
"multipart/mixed"))
142 this.Process(Request, Response, Records);
145 private bool HasColumns(
string[][] Records,
int Nr)
147 foreach (
string[] Record
in Records)
149 if (Record.Length != Nr)
160 Uri OrgUri =
new Uri(Request.
Header.
GetURL(
false,
false));
161 List<EmbeddedContent> Items =
new List<EmbeddedContent>();
162 StringBuilder Header =
new StringBuilder();
165 foreach (
string[] Record
in Records)
169 if (!Uri.TryCreate(OrgUri, Record[0], out Uri ItemUri))
175 if (ItemUri.Scheme != OrgUri.Scheme || ItemUri.Authority != OrgUri.Authority)
184 new KeyValuePair<string, string>(
"Retry-After",
"300")));
187 string ResourcePath = ItemUri.LocalPath;
188 if (!this.webServer.TryGetResource(ref ResourcePath, out
HttpResource Resource, out
string SubPath) ||
195 using MemoryStream ms =
new MemoryStream();
196 StringBuilder sb =
new StringBuilder();
201 sb.Append(ItemUri.PathAndQuery);
202 sb.AppendLine(
" HTTP/1.1");
207 sb.AppendLine(Host.
Value);
210 if (!(Referer is
null))
212 sb.Append(
"Referer: ");
213 sb.AppendLine(Referer.
Value);
216 sb.Append(
"Accept: ");
217 sb.AppendLine(Record[1]);
230 this.webServer.RequestReceived(Request2, Request.
RemoteEndPoint, Resource, SubPath);
231 await GetMethod.GET(Request2, Response2);
235 byte[] Bin = ms.ToArray();
241 Raw = Encoding.ASCII.GetBytes(Convert.ToBase64String(Bin)),
248 byte[] Bin = Encoding.UTF8.GetBytes(ex.Message);
253 Raw = Encoding.ASCII.GetBytes(Convert.ToBase64String(Bin)),
260 byte[] Bin = Encoding.UTF8.GetBytes(ex.Message);
265 Raw = Encoding.ASCII.GetBytes(Convert.ToBase64String(Bin)),
Contains information about a response to a content request.
bool HasError
If an error occurred.
object Decoded
Decoded object.
Exception Error
Error response.
Represents content embedded in other content.
Represents mixed content, encoded with multipart/mixed
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
The server understood the request, but is refusing to fulfill it. Authorization will not help and the...
Base class for all asynchronous HTTP resources. An asynchronous resource responds outside of the meth...
Base class of all HTTP Exceptions.
int StatusCode
HTTP Status Code.
string Value
HTTP Field Value
Represents an HTTP request.
HttpRequestHeader Header
Request header.
string RemoteEndPoint
Remote end-point.
bool HasData
If the request has data.
SessionVariables Session
Contains session states, if the resource requires sessions, or null otherwise.
string LocalEndPoint
Local end-point.
async Task< ContentResponse > DecodeDataAsync()
Decodes data sent in request.
Base class for all HTTP resources.
static string GetSessionId(HttpRequest Request, HttpResponse Response)
Gets the session ID used for a request.
const string HttpSessionID
The Cookie Key for HTTP Session Identifiers: "HttpSessionID"
string ResourceName
Name of resource.
Represets a response of an HTTP client request.
async Task SendResponse()
Sends the response back to the client. If the resource is synchronous, there's no need to call this m...
string ContentType
The Content-Type entity-header field indicates the media type of the entity-body sent to the recipien...
int StatusCode
HTTP Status code.
Task Return(Exception ex)
Returns an error to the client.
Implements an HTTP server.
The resource identified by the request is only capable of generating response entities which have con...
The server has not found anything matching the Request-URI. No indication is given of whether the con...
The server is currently unable to handle the request due to a temporary overloading or maintenance of...
Base class for all transfer encodings.
Transfer encoding for internal transfers of content
Task WaitUntilSent(int TimeoutMilliseconds)
Waits for all of the data to be returned.
Module that controls the life cycle of communication.
static bool Stopping
If the system is stopping.
Allows a client to get multiple resources in one call
override bool HandlesSubPaths
If the resource handles sub-paths.
MultiGetResource(string ResourceName, XmppClient Client, HttpServer WebServer, string UserVariable, params string[] UserPrivileges)
Allows a client to get multiple resources in one call
override bool UserSessions
If the resource uses user sessions.
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
bool AllowsPOST
If the POST method is allowed.
Maintains information about an item in the roster.
SubscriptionState State
roup Current subscription state.
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
Contains information about a variable.
virtual bool TryGetVariable(string Name, out Variable Variable)
Tries to get a variable object, given its name.
GET Interface for HTTP resources.
POST Interface for HTTP resources.
Basic interface for a user.
SubscriptionState
State of a presence subscription.
ContentType
DTLS Record content type.