Added command line parsing for example, fixed non text responses, added request object so you can access parameters and base url
Also, various fixes and improvements
This commit is contained in:
@@ -6,7 +6,7 @@ namespace Cuipod
|
||||
{
|
||||
public class Response
|
||||
{
|
||||
public StatusCode Status { get; internal set; }
|
||||
public StatusCode Status { get; set; }
|
||||
|
||||
private string _directoryToServe;
|
||||
private string _requestBody = "";
|
||||
@@ -27,14 +27,31 @@ namespace Cuipod
|
||||
_requestBody += File.ReadAllText(_directoryToServe + relativePathToFile, Encoding.UTF8) + "\r\n";
|
||||
}
|
||||
|
||||
public void SetRedirectURL(string route)
|
||||
{
|
||||
_requestBody = route + "\r\n";
|
||||
}
|
||||
|
||||
public void SetInputHint(string hint)
|
||||
{
|
||||
_requestBody = hint + "\r\n";
|
||||
}
|
||||
|
||||
internal static string WriteHeader(StatusCode statusCode)
|
||||
{
|
||||
return ((int)statusCode).ToString() + " text/gemini\r\n";
|
||||
return ((int)statusCode).ToString() + " ";
|
||||
}
|
||||
|
||||
internal byte[] Encode()
|
||||
{
|
||||
string wholeResponse = WriteHeader(Status) + _requestBody;
|
||||
string wholeResponse = ((int)Status).ToString() + " ";
|
||||
if (Status == StatusCode.Success)
|
||||
{
|
||||
wholeResponse += "text/gemini\r\n";
|
||||
}
|
||||
|
||||
wholeResponse += _requestBody;
|
||||
Console.WriteLine(wholeResponse);
|
||||
return Encoding.UTF8.GetBytes(wholeResponse);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user