Hello,
We have the following code which should IMHO work straght-forward but when I
run it on production server with GUI 7/24 open, it fails. When I telnet to
it, I enter,
GET /
and it does nothing when it should. When I press enter 10-20 times, it
displays "forbidden" (which is what it should have shown in the first case)
and then 503s. Is this a known issue? Below is the code.
Regards,
SZ
void __fastcall AdminServer::HTTPServerGetDocument(TObject *Sender, TObject
*Client, Overbyteicshttpsrv::THttpGetFlag &Flags)
{
Flags = hg403;
}
//---------------------------------------------------------------------------
void __fastcall AdminServer::HTTPServerHeadDocument(TObject *Sender, TObject
*Client, Overbyteicshttpsrv::THttpGetFlag &Flags)
{
Flags = hg403;
}
//---------------------------------------------------------------------------
void __fastcall AdminServer::HTTPServerPostDocument(TObject *Sender, TObject
*Client, Overbyteicshttpsrv::THttpGetFlag &Flags)
{
THttpConnection *httpClient = (THttpConnection*)Client;
httpClient->Tag = (int)(void*)new AdminServerConnectionData();
httpClient->LineMode = false;
if(httpClient->RequestContentLength <= 4 * 1024 * 1024)
Flags = hgAcceptData;
}
//---------------------------------------------------------------------------
void __fastcall AdminServer::HTTPServerPostedData(TObject *Sender, TObject
*Client, WORD ErrCode)
{
THttpConnection *httpClient = (THttpConnection*)Client;
AdminServerConnectionData *connectionData =
(AdminServerConnectionData*)(void*)httpClient->Tag;
if(ErrCode)
{
delete connectionData;
httpClient->Tag = 0;
httpClient->Abort();
}
else
{
int Len = 0;
if(connectionData)
Len = httpClient->Receive((void*)connectionData->buffer, 16384);
if(Len <= 0)
return;
if(connectionData->docSize + Len > httpClient->RequestContentLength)
{
connectionData->stream->Write((void*)connectionData->buffer,
httpClient->RequestContentLength - connectionData->docSize);
connectionData->docSize = httpClient->RequestContentLength;
}
else
{
connectionData->stream->Write((void*)connectionData->buffer, Len);
connectionData->docSize += Len;
}
if(httpClient->RequestContentLength <= connectionData->docSize)
{
connectionData->stream->Seek(0, 0);
TMemoryStream *responseXML = processRequest(connectionData->stream,
httpClient);
Overbyteicshttpsrv::THttpGetFlag Flags;
httpClient->DocStream = responseXML;
httpClient->AnswerStream(Flags, "", "application/xml", "");
}
}
}
//---------------------------------------------------------------------------
void __fastcall AdminServer::HTTPServerClientRequestDone(TObject *Sender,
TObject *Client)
{
Overbyteicshttpsrv::THttpConnection *httpClient =
(Overbyteicshttpsrv::THttpConnection*)Client;
AdminServerConnectionData *connectionData =
(AdminServerConnectionData*)(void*)httpClient->Tag;
delete connectionData;
httpClient->Tag = 0;
httpClient->PostedDataReceived();
if(newIP.Length() || newPort.Length())
PostMessage(serverContainerObject->handle, WM_RESTART_ADMIN_SERVER, 0, 0);
}
//---------------------------------------------------------------------------
void __fastcall AdminServer::HTTPServerClientDisconnected(TObject *Sender,
TObject *Client, WORD Error)
{
THttpConnection *httpClient = (THttpConnection*)Client;
AdminServerConnectionData *connectionData =
(AdminServerConnectionData*)(void*)httpClient->Tag;
delete connectionData;
httpClient->Tag = 0;
}
//---------------------------------------------------------------------------
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be