Arno,

No luck I'm afraid... I'm still getting those AV's :(

Keith.


Here's my current code... As per your suggested code.
I also made the TMemoryManager global to the application.
I will try free and malloc next.



<<< CODE SNIPPETS >>>

//--------------------------------------------------------------------------
-
class TMyHttpConnection : public THttpConnection
{
 public:
  char *PostedDataBuffer;     // Will hold dynamically allocated buffer
  int  PostedDataSize;        // Databuffer size
  int  RcvdByteCount;         // Keep track of received byte count.
  
 public:
  __fastcall TMyHttpConnection(Classes::TComponent* AOwner);
  virtual __fastcall ~TMyHttpConnection();
};
//--------------------------------------------------------------------------
-



//--------------------------------------------------------------------------
-
__fastcall TMyHttpConnection::TMyHttpConnection(Classes::TComponent* AOwner)
: THttpConnection(AOwner)
{
 try
 {
  PostedDataBuffer = NULL;
  PostedDataSize = 0;
 }
 catch(...) {}
}
//--------------------------------------------------------------------------
-

__fastcall TMyHttpConnection::~TMyHttpConnection()
{
 try
 {
  if (PostedDataBuffer != NULL)
  {
   if (MemoryManager->FreeMem(PostedDataBuffer) == 0)
   {
    PostedDataBuffer = NULL;
    PostedDataSize = 0;
   }
  }
 }
 catch(...) {}
}
//--------------------------------------------------------------------------
-



//--------------------------------------------------------------------------
-
void __fastcall TAegisWebServerForm::HttpServerPostDocument(TObject *Sender,
TObject *Client, THttpGetFlag &Flags)
{
 try
 {
  TMyHttpConnection* Connection = (TMyHttpConnection*)Client;

  FCountRequests++;  // Count request and display a message

  if (CompareText(Connection->Path, "/content/home.html") == 0)    // This
page is not cached
  {
   Flags = hgAcceptData;

   Connection->LineMode = false;

   if (Connection->PostedDataSize < Connection->RequestContentLength + 1)
   {
    if (Connection->PostedDataBuffer != NULL) {if
(MemoryManager->FreeMem(Connection->PostedDataBuffer) != 0) throw
Exception("Unable to free memory for Posted Data Buffer");}

    Connection->PostedDataSize = 0;

    Connection->PostedDataBuffer =
(char*)(MemoryManager->GetMem(Connection->RequestContentLength + 1));
    if (Connection->PostedDataBuffer == NULL) throw Exception("Unable to
allocate memory for Posted Data Buffer");

    Connection->PostedDataSize = Connection->RequestContentLength + 1;
   }

   Connection->RcvdByteCount = 0;
  }
  else Flags = hg404;
 }
 catch (Exception &E)
{HandleError("TAegisWebServerForm::HttpServerPostDocument", E.Message);}
 catch (const exception &e)
{HandleError("TAegisWebServerForm::HttpServerPostDocument", e.what());}
 catch (...) {HandleError("TAegisWebServerForm::HttpServerPostDocument",
"Unknown Exception");}
}
//--------------------------------------------------------------------------
-

void __fastcall TAegisWebServerForm::HttpServerPostedData(TObject *Sender,
TObject *Client, WORD Error)
{
 try
 {
  int Len, Remains;
  char Junk[1024];

  TMyHttpConnection* Connection = (TMyHttpConnection*)Client;

  Remains = Connection->RequestContentLength - Connection->RcvdByteCount;

  if (Remains <= 0)
  {
   Connection->Receive(Junk, sizeof(Junk));
   return;
  }

  Len =
Connection->Receive(&(Connection->PostedDataBuffer[Connection->RcvdByteCount
]), Remains);
  if (Len <= 0) return;

  Connection->RcvdByteCount += Len;

  if (Connection->RcvdByteCount > Connection->RequestContentLength)
Connection->RcvdByteCount = Connection->RequestContentLength;

  if (Connection->RcvdByteCount == Connection->RequestContentLength)
  {
   Connection->PostedDataReceived();
   Connection->PostedDataBuffer[Connection->RcvdByteCount] = 0;
   ProcessPostedData(Connection);
  }
 }
 catch (Exception &E)
{HandleError("TAegisWebServerForm::HttpServerPostedData", E.Message);}
 catch (const exception &e)
{HandleError("TAegisWebServerForm::HttpServerPostedData", e.what());}
 catch (...) {HandleError("TAegisWebServerForm::HttpServerPostedData",
"Unknown Exception");}
}
//--------------------------------------------------------------------------
-

-- 
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

Reply via email to