mirror of
https://onedev.site.tesses.net/tesses-framework
synced 2026-02-08 15:55:46 +00:00
Add GUI Support
This commit is contained in:
@@ -36,7 +36,11 @@ namespace Tesses::Framework::Http
|
||||
p = p.substr(1, p.size()-2);
|
||||
}
|
||||
|
||||
|
||||
p = HttpUtils::UrlPathDecode(p);
|
||||
|
||||
|
||||
|
||||
cd.filename = p;
|
||||
}
|
||||
else if(res2[0] == "name")
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Tesses::Framework::Http
|
||||
if(this->allowListing)
|
||||
{
|
||||
std::string p = HttpUtils::HtmlEncode(ctx.originalPath);
|
||||
std::string html = "<!DOCTYPE html><html><head><title>Index of ";
|
||||
std::string html = "<!DOCTYPE html><html><head><meta charset=\"UTF-8\"><title>Index of ";
|
||||
html.append(p);
|
||||
html.append("</title></head><body><h1>Index of ");
|
||||
html.append(p);
|
||||
|
||||
@@ -9,19 +9,18 @@
|
||||
#include "TessesFramework/Crypto/MbedHelpers.hpp"
|
||||
#include "TessesFramework/Threading/Mutex.hpp"
|
||||
#include "TessesFramework/Common.hpp"
|
||||
#include "TessesFramework/TextStreams/StdIOWriter.hpp"
|
||||
|
||||
#include <iostream>
|
||||
using FileStream = Tesses::Framework::Streams::FileStream;
|
||||
using Stream = Tesses::Framework::Streams::Stream;
|
||||
using SeekOrigin = Tesses::Framework::Streams::SeekOrigin;
|
||||
using MemoryStream = Tesses::Framework::Streams::MemoryStream;
|
||||
using StreamReader = Tesses::Framework::TextStreams::StreamReader;
|
||||
using StreamWriter = Tesses::Framework::TextStreams::StreamWriter;
|
||||
using TcpServer = Tesses::Framework::Streams::TcpServer;
|
||||
using NetworkStream = Tesses::Framework::Streams::NetworkStream;
|
||||
using BufferedStream = Tesses::Framework::Streams::BufferedStream;
|
||||
|
||||
|
||||
using namespace Tesses::Framework::TextStreams;
|
||||
|
||||
namespace Tesses::Framework::Http
|
||||
{
|
||||
@@ -503,6 +502,7 @@ namespace Tesses::Framework::Http
|
||||
else
|
||||
{
|
||||
auto strm = cb(ct, cd1.filename, cd1.fieldName);
|
||||
if(strm == nullptr) strm = new Stream();
|
||||
bool retVal = parseUntillBoundaryEnd(&ctx->GetStream(),strm,boundary);
|
||||
delete strm;
|
||||
return retVal;
|
||||
@@ -635,13 +635,13 @@ namespace Tesses::Framework::Http
|
||||
{
|
||||
TF_LOG("Before printing interfaces");
|
||||
|
||||
std::cout << "\x1B[34mInterfaces:\n";
|
||||
StdOut() << "\x1B[34mInterfaces:" << NewLine();
|
||||
for(auto _ip : NetworkStream::GetIPs())
|
||||
{
|
||||
std::cout << "\x1B[32m";
|
||||
std::cout << _ip.first << ": ";
|
||||
std::cout << "\x1B[35mhttp://";
|
||||
std::cout << _ip.second << ":" << std::to_string(this->GetPort()) << "/\n";
|
||||
StdOut() << "\x1B[32m"
|
||||
<< _ip.first << ": "
|
||||
<< "\x1B[35mhttp://"
|
||||
<< _ip.second << ":" << (uint64_t)this->GetPort() << "/" << NewLine();
|
||||
}
|
||||
|
||||
|
||||
@@ -649,7 +649,7 @@ namespace Tesses::Framework::Http
|
||||
if(this->showARTL)
|
||||
{
|
||||
if(!svr->IsValid()) std::cout << "\x1B[31mError, we failed to bind or something\x1B[39m\n" << std::endl;
|
||||
std::cout << "\x1B[31mAlmost Ready to Listen\x1B[39m\n";
|
||||
StdOut() << "\x1B[31mAlmost Ready to Listen\x1B[39m" << NewLine();
|
||||
}
|
||||
|
||||
TF_LOG("After printing interfaces");
|
||||
|
||||
@@ -516,6 +516,68 @@ namespace Tesses::Framework::Http {
|
||||
}
|
||||
return strs;
|
||||
}
|
||||
std::string HttpUtils::HtmlDecodeOnlyEntityNumber(std::string v)
|
||||
{
|
||||
std::string buff={};
|
||||
int state = 0;
|
||||
uint64_t n=0;
|
||||
for(auto item : v)
|
||||
{
|
||||
switch(state)
|
||||
{
|
||||
case 0:
|
||||
if(item == '&') state=1;
|
||||
else buff.push_back(item);
|
||||
break;
|
||||
case 1:
|
||||
if(item == '#') {state = 2; n=0;}
|
||||
else {state=0; buff.push_back('&'); buff.push_back(item); }
|
||||
break;
|
||||
case 2:
|
||||
if(item == ';') {
|
||||
state = 0;
|
||||
if(n <= 0x7F)
|
||||
{
|
||||
buff.push_back((char)n);
|
||||
}
|
||||
else if(n >= 0x80 && n <= 0x7FF)
|
||||
{
|
||||
uint8_t high = 0b11000000 | ((uint8_t)(n >> 6) & 0b00011111);
|
||||
uint8_t low = 0b10000000 | ((uint8_t)(n) & 0b00111111);
|
||||
buff.push_back((char)high);
|
||||
buff.push_back((char)low);
|
||||
}
|
||||
else if(n >= 0x800 && n <= 0xFFFF)
|
||||
{
|
||||
uint8_t high = 0b11100000 | ((uint8_t)(n >> 12) & 0b00001111);
|
||||
uint8_t low = 0b10000000 | ((uint8_t)(n >> 6) & 0b00111111);
|
||||
uint8_t lowest = 0b10000000 | ((uint8_t)(n) & 0b00111111);
|
||||
buff.push_back((char)high);
|
||||
buff.push_back((char)low);
|
||||
buff.push_back((char)lowest);
|
||||
}
|
||||
else if(n >= 0x010000 && n <= 0x10FFFF)
|
||||
{
|
||||
uint8_t highest = 0b11110000 | ((uint8_t)(n >> 18) & 0b00000111);
|
||||
uint8_t high = 0b10000000 | ((uint8_t)(n >> 12) & 0b00111111);
|
||||
uint8_t low = 0b10000000 | ((uint8_t)(n >> 6) & 0b00111111);
|
||||
uint8_t lowest = 0b10000000 | ((uint8_t)(n) & 0b00111111);
|
||||
buff.push_back((char)highest);
|
||||
|
||||
buff.push_back((char)high);
|
||||
buff.push_back((char)low);
|
||||
buff.push_back((char)lowest);
|
||||
}
|
||||
}
|
||||
else if(item >= '0' && item <= '9')
|
||||
{
|
||||
n *= 10;
|
||||
n += item - '0';
|
||||
}
|
||||
}
|
||||
}
|
||||
return buff;
|
||||
}
|
||||
std::string HttpUtils::HtmlEncode(std::string html)
|
||||
{
|
||||
std::string myHtml = {};
|
||||
|
||||
Reference in New Issue
Block a user