ok, so I started over. now, the dll loads, and I can interact with it on the web, but for some reason, no matter what I try, I can't get more than the first 48k of post data, even though I'm sending about 80k.
the html file that contains the submission form is as follows:
Code:
<HTML>
<HEAD>
<TITLE>
Test Form
</TITLE>
</HEAD>
<BODY>
<FORM method="POST" action="/team_isapi/plain-isapi.dll?foo=bar">
<INPUT type="text" name="T1"><br>
<TEXTAREA name="T2" rows="10" cols="60"></TEXTAREA><br>
<INPUT type="submit" value="Submit" name="B1"><br>
<INPUT type="reset" value="Reset" name="B2"><br>
</FORM>
</BODY>
</HTML>
the only header file in the project is as follows:
Code:
// plain-isapi.h
#ifndef __PLAIN_ISAPI_H
#define __PLAIN_ISAPI_H
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <httpext.h>
using std::endl;
using std::ofstream;
using std::ifstream;
using std::string;
using std::stringstream;
using std::vector;
using std::queue;
#endif // __PLAIN_ISAPI_H
and the main source file:
Code:
// plain-isapi.cpp
#include "plain-isapi.h"
void PrintHtml(EXTENSION_CONTROL_BLOCK* pECB, string s);
string ReadFromClient(EXTENSION_CONTROL_BLOCK* pECB);
BOOL WINAPI DllMain(HMODULE hMod, DWORD fReason, LPVOID pvRes)
{
switch (fReason)
{
case DLL_PROCESS_ATTACH:
{
break;
}
case DLL_THREAD_ATTACH:
{
break;
}
case DLL_THREAD_DETACH:
{
break;
}
case DLL_PROCESS_DETACH:
{
break;
}
}
return TRUE;
}
BOOL WINAPI GetExtensionVersion(HSE_VERSION_INFO* pVer)
{
pVer->dwExtensionVersion = 1;
strncpy(pVer->lpszExtensionDesc, "plain-isapi extension.", HSE_MAX_EXT_DLL_NAME_LEN);
return TRUE;
}
DWORD WINAPI HttpExtensionProc(EXTENSION_CONTROL_BLOCK* pECB)
{
stringstream ss_post;
string str(pECB->lpszQueryString);
PrintHtml(pECB, "<HTML><HEAD><TITLE>plain-isapi extension test</TITLE></HEAD><BODY><H1>FOO!</H1><br><hr>");
PrintHtml(pECB, str);
PrintHtml(pECB, "<br><hr>");
char buffer[4096];
int size = 4096;
memset(buffer, 0, 4096);
if (pECB->GetServerVariable(pECB->ConnID, (LPSTR)"CONTENT_LENGTH", (LPVOID)buffer, (LPDWORD)&size))
{
ss_post << "CONTENT_LENGTH: " << buffer << "<br>" << endl;
}
string post = ReadFromClient(pECB);
ss_post << "Post string length: " << post.length() << "<br>" << endl;
ss_post << "Post string: " << post << "<br>" << endl;
ss_post << "</BODY></HTML>";
post = ss_post.str();
PrintHtml(pECB, post);
pECB->dwHttpStatusCode = 200;
return HSE_STATUS_SUCCESS;
}
string ReadFromClient(EXTENSION_CONTROL_BLOCK* pECB)
{
PrintHtml(pECB, "In ReadClient()...<br>\r\n");
string str;
stringstream ss;
str.assign((char*)pECB->lpbData, pECB->cbAvailable);
ss << "str.length(): " << str.length() << "<br>" << endl;
size_t bytes, num_bytes;
size_t data_read = pECB->cbAvailable;
bytes = pECB->cbTotalBytes - pECB->cbAvailable;
ss << "Bytes left to read: " << bytes << "<br>" << endl;
PrintHtml(pECB, ss.str());
char *buffer = NULL;
if (bytes)
{
PrintHtml(pECB, "Attempting to read from client...<br>\r\n");
buffer = new char[bytes];
while (data_read < pECB->cbTotalBytes)
{
PrintHtml(pECB, "Iteration of loop...<br>\r\n");
memset(buffer, 0, bytes);
if (pECB->ReadClient(pECB->ConnID, (LPVOID)buffer, (LPDWORD)&num_bytes))
{
PrintHtml(pECB, "Read data from client...<br>\r\n");
if (num_bytes) str.append(buffer, num_bytes);
data_read += num_bytes;
}
else
{
PrintHtml(pECB, "Failed to read more data...<br>\r\n");
break;
}
}
delete buffer;
}
else
{
PrintHtml(pECB, "No data available for reading...<br>\r\n");
}
return str;
}
void PrintHtml(EXTENSION_CONTROL_BLOCK* pECB, string s)
{
char* str = new char[s.length() + 1];
size_t len = s.length();
pECB->WriteClient(pECB->ConnID, (LPVOID)s.c_str(), (LPDWORD)&len, 0);
}
I have been working on this one issue for about 4 hours now, with no progress. I'm sure it's something simple that I'm overlooking, but I just don't get it.