HttpServerBoxed 0.0.11 alpha
A simple http server for C# and .NET
|
Public Member Functions | |
Response (Socket socket, Request request, Configuration c, SslStream? sslStream) | |
void | Send (byte[] data, bool disconnect=true) |
Send an un modified byte array to to the socket. | |
void | Send (string data, string mimeType="text/plain", int statusCode=HTTP_CODES.OK, Dictionary< string, string >? customHeaders=null) |
Sends an HTTP Response with the body passed as parameter. | |
void | SendHTMLFile (string path, bool process=false, Dictionary< string, string >? customHeaders=null) |
Loads and HTML file from path and sends it as HTTP Response with mimeType = text/html Optionally it can provides a basic processor function. | |
void | SendHTMLContent (string content, bool process=false, int statusCode=HTTP_CODES.OK, string encoding="UTF-8", Dictionary< string, string >? customHeaders=null) |
Sends an html page passed as string. | |
void | SendFile (string absPath, string? mimeType=null, int statusCode=HTTP_CODES.OK, Dictionary< string, string >? customHeaders=null) |
Loads a file from a given path and sends an HTTP Response. | |
void | SendFile (byte[] data, string mimeType, int statusCode=HTTP_CODES.OK, Dictionary< string, string >? customHeaders=null) |
Sends data to the client. | |
void | SendObject (object obj, string fileName="") |
Sends a generic object to the client, with possible optimization (string, byte[], FilePart, generic object) | |
void | SendFile (FilePart filePart, int statusCode=HTTP_CODES.OK, Dictionary< string, string >? customHeaders=null) |
Send a FilePart to the client. | |
void | SendCode (int statusCode) |
Send an HTTP Response with no body but with given status code. | |
void | Send (int statusCode) |
Shorthand for SendCode. | |
void | Redirect (string route, int statusCode=HTTP_CODES.FOUND) |
Sends a redirect to the client. | |
void | Redirect (Servlet s, int statusCode=HTTP_CODES.FOUND) |
Redirects to a given servlet. | |
void | E400 () |
Bad Request. | |
void | E401 () |
Unauthorized. | |
void | E404 () |
Not Found. | |
void | E500 () |
Internal Server Error. | |
void | JSON (string content) |
Sends a HTTP Response with a JSON body passed as parameter. | |
void | JSON< T > (T o, JsonSerializerOptions options) |
Serializes and sends an Object in JSON format. | |
void | JSON< T > (T o, bool includeFields=true, bool WriteIndented=true) |
Serialize and sends an Object in JSON Format. | |
void | SendJSON< T > (T o, JsonSerializerOptions options) |
Alternate name for function JSON. | |
void | SendJSON< T > (T o, bool includeFields=true) |
Alternate name for function JSON. | |
void | SendJSON (string content) |
void | AddAttribute (string name, string value) |
Adds an attribute to the HTML file that will be processed, if it already exists it will be overwritten. | |
void | RemoveAttribute (string name) |
Removes an attribute to the HTML file that will be processed. | |
string | GetAttribute (string name) |
Retrieves the value of an attribute to the HTML file that will be processed, if doesn't exists it will return an empty string. | |
Definition at line 14 of file Response.cs.
HSB.Response.Response | ( | Socket | socket, |
Request | request, | ||
Configuration | c, | ||
SslStream? | sslStream | ||
) |
Definition at line 25 of file Response.cs.
Adds an attribute to the HTML file that will be processed, if it already exists it will be overwritten.
name | Name of the attribute |
value | Value of the attribute |
Definition at line 413 of file Response.cs.
void HSB.Response.E400 | ( | ) |
Bad Request.
Definition at line 243 of file Response.cs.
void HSB.Response.E401 | ( | ) |
Unauthorized.
Definition at line 250 of file Response.cs.
void HSB.Response.E404 | ( | ) |
Not Found.
Definition at line 257 of file Response.cs.
void HSB.Response.E500 | ( | ) |
Internal Server Error.
Definition at line 264 of file Response.cs.
Retrieves the value of an attribute to the HTML file that will be processed, if doesn't exists it will return an empty string.
name | Name of the attribute |
Definition at line 432 of file Response.cs.
Sends a HTTP Response with a JSON body passed as parameter.
content | String of the body in JSON format |
Definition at line 272 of file Response.cs.
Serialize and sends an Object in JSON Format.
T |
o | |
includeFields | Whether or not or not include fields of the object |
Definition at line 291 of file Response.cs.
void HSB.Response.JSON< T > | ( | T | o, |
JsonSerializerOptions | options | ||
) |
Serializes and sends an Object in JSON format.
o | Object to be serialized and sended as response |
options | Options for the serializer (System.Text.Json.JsonSerializer) |
Definition at line 281 of file Response.cs.
Redirects to a given servlet.
s | |
statusCode |
Definition at line 235 of file Response.cs.
Sends a redirect to the client.
route |
Definition at line 216 of file Response.cs.
Removes an attribute to the HTML file that will be processed.
name | Name of the attribute |
Definition at line 424 of file Response.cs.
void HSB.Response.Send | ( | byte[] | data, |
bool | disconnect = true |
||
) |
Send an un modified byte array to to the socket.
data |
Definition at line 40 of file Response.cs.
void HSB.Response.Send | ( | int | statusCode | ) |
void HSB.Response.Send | ( | string | data, |
string | mimeType = "text/plain" , |
||
int | statusCode = HTTP_CODES::OK , |
||
Dictionary< string, string >? | customHeaders = null |
||
) |
Sends an HTTP Response with the body passed as parameter.
data | Body of the response |
mimeType | MimeType of the body |
statusCode | Response status code |
Definition at line 68 of file Response.cs.
Send an HTTP Response with no body but with given status code.
statusCode |
Definition at line 198 of file Response.cs.
void HSB.Response.SendFile | ( | byte[] | data, |
string | mimeType, | ||
int | statusCode = HTTP_CODES::OK , |
||
Dictionary< string, string >? | customHeaders = null |
||
) |
Sends data to the client.
data | |
mimeType | |
statusCode |
Definition at line 147 of file Response.cs.
void HSB.Response.SendFile | ( | FilePart | filePart, |
int | statusCode = HTTP_CODES::OK , |
||
Dictionary< string, string >? | customHeaders = null |
||
) |
Send a FilePart to the client.
filePart | |
statusCode | |
customHeaders |
Definition at line 190 of file Response.cs.
void HSB.Response.SendFile | ( | string | absPath, |
string? | mimeType = null , |
||
int | statusCode = HTTP_CODES::OK , |
||
Dictionary< string, string >? | customHeaders = null |
||
) |
Loads a file from a given path and sends an HTTP Response.
absPath | Path (absolute) of the file |
mimeType | MimeType of the file |
statusCode | Response status code |
Definition at line 122 of file Response.cs.
void HSB.Response.SendHTMLContent | ( | string | content, |
bool | process = false , |
||
int | statusCode = HTTP_CODES::OK , |
||
string | encoding = "UTF-8" , |
||
Dictionary< string, string >? | customHeaders = null |
||
) |
Sends an html page passed as string.
path | HTML content |
process | Whether or not or not process the document before sending |
statusCode | Response status code |
encoding | Encoding of the document |
customHeaders | Optional headers |
Definition at line 110 of file Response.cs.
void HSB.Response.SendHTMLFile | ( | string | path, |
bool | process = false , |
||
Dictionary< string, string >? | customHeaders = null |
||
) |
Loads and HTML file from path and sends it as HTTP Response with mimeType = text/html Optionally it can provides a basic processor function.
path | Path of the HTML file |
process | Whether or not or not process the document before sending |
Definition at line 82 of file Response.cs.
Alternate name for function JSON.
T |
o | |
options |
summary> Alternate name for function JSON
content |
void HSB.Response.SendJSON< T > | ( | T | o, |
JsonSerializerOptions | options | ||
) |
Alternate name for function JSON.
T |
o | |
options |
Sends a generic object to the client, with possible optimization (string, byte[], FilePart, generic object)
obj | |
fileName |
Definition at line 168 of file Response.cs.