Login  
Search All Forums
Dart Home | PowerTCP WebServer for ActiveX | Custom Development Reply | PowerTCP WebServer for ActiveX Topics | Forums   
AuthorForum: PowerTCP WebServer for ActiveX
Topic: Beyond 50000 for Response
mjxnjx

From: sunnyvale, CA USA
Posts: 26
Member Since: 06/15/05
posted June 29, 2007 2:16 PM

(Haven't gotten a response to my email yet, so let me try here. Kinda need to resolve this quickly.)

It looks like the conversion from CString to _bstr_t is limited somewhere
between 50000 and 80000 characters worth of bytes. To account for this, I
have segmented the Body that I am passing back in the Response object into a
loop of 50000 characters each (as shown in the code below).

The problem i'm having is that the Body->Write appears to only take the
first portion of the loop worth of data. The second pass through the loop
does not appear to write any more data to the object. The response back to
the client only contains the first 50000 worth of data.

Can you pinpoint to me what it is i'm doing wrong in this code below?


// Create a stream to hold the text of the page
DartWebServer::IDartStreamPtr Body;
Body.CreateInstance(DartWebServer::CLSID_DartStream);

//Get the Full Body Message and Length (Can be Quite Large!)
CString sCompleteBody = pMyRequestHandler->m_sCompleteBody;
long nBodyLength = sCompleteBody.GetLength();
long nPosition = 0;

do
{
 //Get the first 50000 characters, or All, if it is less than 50000
 CString sBodyString;
 if (nBodyLength > 50000)
 sBodyString = sCompleteBody.Left(50000);
 else
 sBodyString = sCompleteBody;

 //Create variant to store up to 50000 characters and populate it with the
Body String Segment
 COleVariant ovBody;
 ovBody.ChangeType(VT_BSTR);
 ovBody.bstrVal = _bstr_t(sBodyString);

 // Add the text to the stream
 nPosition = Body->Write(ovBody,nPosition);

 //Adjust to the next 50000 if there is more than 50000 remaining
 if (nBodyLength > 50000)
 {
 sCompleteBody = sCompleteBody.Mid(50000);
 nBodyLength = sCompleteBody.GetLength();
 }


}
while (nBodyLength > 50000);

// Add the stream to the Response
Response->Body = Body;
mjxnjx

From: sunnyvale, CA USA
Posts: 26
Member Since: 06/15/05
posted June 29, 2007 2:45 PM

Ah geez. Sorry, I posted a bad code (never work and post code at the same time). Here's the actual proper loop that isn't working for me in the same manner:

// Create a stream to hold the text of the page
DartWebServer::IDartStreamPtr Body;
Body.CreateInstance(DartWebServer::CLSID_DartStream);

CString sCompleteBody = pRequest->m_sCompleteBody;
long nBodyLength = sCompleteBody.GetLength();
long nPosition = 0;

while (nBodyLength > 50000)
{
 //Get the first 50000 characters//
 CString sBodyString;
 sBodyString = sCompleteBody.Left(50000);

 //Create variant to store up to 50000 chars//
 COleVariant ovBody;
 ovBody.ChangeType(VT_BSTR);
 ovBody.bstrVal = _bstr_t(sBodyString);

 // Add the text to the stream
 nPosition = Body->Write(ovBody,nPosition);

 //Adjust to the next 50000//
 if (nBodyLength > 50000)
 {
 sCompleteBody = sCompleteBody.Mid(50000);
 nBodyLength = sCompleteBody.GetLength();
 }
}


//Create variant to store up to 50000 characters//
COleVariant ovBody;
ovBody.ChangeType(VT_BSTR);
ovBody.bstrVal = _bstr_t(sCompleteBody);

// Add the text to the stream
nPosition = Body->Write(ovBody,nPosition);
// Add the stream to the Response
Response->Body = Body;

// Set the status of the Response
Response->Status = DartWebServer::httpOK;
mjxnjx

From: sunnyvale, CA USA
Posts: 26
Member Since: 06/15/05
posted June 29, 2007 4:48 PM

I guess I get to "toot my own horn" here.

I fixed this problem by saving the large CString to a .htm file first. I then pointed the DartStream at the file instead of doing a Write().

Doesn't seem like the most efficeint way of doing this, but oh well.
Raj

From: Rome, NY, USA
Posts: 389
Member Since: 02/01/06
posted June 29, 2007 5:23 PM

Glad to know that you have got a workaround.

I was just curious to know if you checked the WebServer sample, does it work for you?
-Raj
Reply | PowerTCP WebServer for ActiveX Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX