HLS/HTTP fixes:

- Optimize URIReader class to not close connections if not needed
- reConnector now works for non-GET requests with GET params
- Chunk sending mode correctly kept for HLS
- Removed lots of H.Clean() from HLS that weren't needed
- Improved HTTP output class request handling logic
- Removed firstRun from HTTP output class; no longer needed
This commit is contained in:
Thulinma 2021-09-20 13:09:27 +02:00
parent 5774ce3b9e
commit 194b6e1388
5 changed files with 13 additions and 27 deletions

View file

@ -148,7 +148,7 @@ std::string &HTTP::Parser::BuildRequest(){
/// \todo Include POST variable handling for vars?
std::map<std::string, std::string>::iterator it;
if (protocol.size() < 5 || protocol[4] != '/'){protocol = "HTTP/1.0";}
if (method == "GET" && vars.size() && url.find('?') == std::string::npos){
if (method != "POST" && vars.size() && url.find('?') == std::string::npos){
builder = method + " " + Encodings::URL::encode(url, "/:=@[]") + allVars() + " " + protocol + "\r\n";
}else{
builder = method + " " + Encodings::URL::encode(url, "/:=@[]") + " " + protocol + "\r\n";
@ -277,9 +277,10 @@ void HTTP::Parser::SendResponse(std::string code, std::string message, Socket::C
void HTTP::Parser::StartResponse(std::string code, std::string message, const HTTP::Parser &request,
Socket::Connection &conn, bool bufferAllChunks){
std::string prot = request.protocol;
sendingChunks =
bool willSendChunks =
(!bufferAllChunks && request.protocol == "HTTP/1.1" && request.GetHeader("Connection") != "close");
CleanPreserveHeaders();
sendingChunks = willSendChunks;
protocol = prot;
if (sendingChunks){
SetHeader("Transfer-Encoding", "chunked");

View file

@ -45,13 +45,13 @@ namespace HTTP{
void URIReader::dataCallback(const char *ptr, size_t size){allData.append(ptr, size);}
bool URIReader::open(const HTTP::URL &uri){
close();
myURI = uri;
curPos = 0;
allData.truncate(0);
bufPos = 0;
if (!myURI.protocol.size() || myURI.protocol == "file"){
close();
if (!myURI.path.size() || myURI.path == "-"){
downer.getSocket().open(-1, fileno(stdin));
stateType = HTTP::Stream;