mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-07 10:34:54 -06:00
reorganizing repo
git-svn-id: svn://ultimatepp.org/upp/trunk@9206 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
7d17505cfe
commit
e3e8d627f5
3840 changed files with 0 additions and 1161578 deletions
|
|
@ -1,82 +0,0 @@
|
|||
#include <signal.h>
|
||||
|
||||
#include <Core/Core.h>
|
||||
#include <Web/Web.h>
|
||||
|
||||
#include "ScgiServer.h"
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
bool run = true;
|
||||
|
||||
void sighandler(int sig)
|
||||
{
|
||||
run = false;
|
||||
}
|
||||
|
||||
ScgiServer::ScgiServer(int port)
|
||||
{
|
||||
this->port = port;
|
||||
|
||||
signal(SIGABRT, sighandler);
|
||||
signal(SIGINT, sighandler);
|
||||
signal(SIGTERM, sighandler);
|
||||
}
|
||||
|
||||
void ScgiServer::Run()
|
||||
{
|
||||
ServerSocket(serverSock, port);
|
||||
while (run) {
|
||||
if (serverSock.Accept(clientSock, &clientIP)) {
|
||||
WhenAccepted();
|
||||
|
||||
String sLen = clientSock.ReadUntil(':');
|
||||
int len = atoi(sLen);
|
||||
String data;
|
||||
|
||||
if (clientSock.IsOpen() && !clientSock.IsEof() && !clientSock.IsError()) {
|
||||
// len + 1 = data plus the trailing , as in SCGI spec
|
||||
data = clientSock.ReadCount(len+1, 3000);
|
||||
}
|
||||
|
||||
String key;
|
||||
int spos = 0;
|
||||
for (int i=0; i < data.GetCount(); i++) {
|
||||
if (data[i] == 0) {
|
||||
if (key.IsEmpty())
|
||||
key = data.Mid(spos, i-spos);
|
||||
else {
|
||||
String value = data.Mid(spos, i-spos);
|
||||
|
||||
serverVars.Add(key, value);
|
||||
key.Clear();
|
||||
}
|
||||
|
||||
spos = i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
query.SetURL("?" + serverVars.Get("QUERY_STRING"));
|
||||
|
||||
hasPostData = false;
|
||||
if (serverVars.Get("REQUEST_METHOD") == "POST") {
|
||||
len = atoi(serverVars.Get("CONTENT_LENGTH"));
|
||||
if (len > 0 && clientSock.IsOpen() && !clientSock.IsEof() &&
|
||||
!clientSock.IsError())
|
||||
{
|
||||
data = clientSock.ReadCount(len, 3000);
|
||||
post.SetURL("?" + data);
|
||||
hasPostData = true;
|
||||
}
|
||||
}
|
||||
|
||||
WhenRequest();
|
||||
|
||||
clientSock.Close();
|
||||
serverVars.Clear();
|
||||
query.Clear();
|
||||
|
||||
WhenClosed();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue