Thanks. Yeah, I have all that stuff. I do have working test pages with forms and cookies. I just can’t get my own home page to show up when the bare domain is requested (i.e. with no specific page in the URL).
I don’t mean to suck you into my vortex of non-productivity, but if you’re interested, I’ve posted code fragments below which should help see some of what I’ve already done.
Many thanks for your time.
I start by splitting GET and POST requests:
void RpExternalCgi(void *theDataPtr, rpCgiPtr theCgiPtr) {
if (theCgiPtr->fHttpRequest == eRpCgiHttpGet) {
mCgi_handleGetRequests(theDataPtr, theCgiPtr);
}
if (theCgiPtr->fHttpRequest == eRpCgiHttpPost) {
mCgi_handlePostRequests(theDataPtr, theCgiPtr);
}
}
Next, assuming a GET, have the following simple block to determine which page – I’ll work out a better one later:
void mCgi_handleGetRequests(void *theDataPtr, rpCgiPtr theCgiPtr) {
if (strncmp (theCgiPtr->fPathPtr, "/test_page", 10) == 0) {
test_page(theDataPtr, theCgiPtr);
return;
}
if (strncmp (theCgiPtr->fPathPtr, "/home_page", 10) == 0) {
home_page(theDataPtr, theCgiPtr);
return;
}
if (strncmp (theCgiPtr->fPathPtr, "/", 1) == 0) {
home_page(theDataPtr, theCgiPtr);
return;
}
// let's cheat the 404 by having a default page be the home page, just in case
home_page(theDataPtr, theCgiPtr);
}
You’ll notice a couple things. First, I have an explicit test for “/home_page” which if the URL includes that, the page appears just fine as expected. Second, that routine ends with a forced call to the home_page – and even that is not working. So this tells me that even though RpPages is effectively empty, something is still trying to handle the first page of the web site using a PBuilder page. The one I am expecting to work is the “/” since the 404 page complains it cannot find a “/” URL.
Anyway, the home page code is a dead simple example like this which works just fine if I call http://DOMAIN/home_page, but not if I call just http://DOMAIN/.
void home_page(void *theDataPtr, rpCgiPtr theCgiPtr) {
theCgiPtr->fResponseState = eRpCgiLastBuffer;
memset(buffer, '\0', MAX_PAGE_BYTES);
strcpy(buffer, "");
strcat(buffer, "");
strcat(buffer, "CGI Home");
strcat(buffer, "");
strcat(buffer, "");
strcat(buffer, "Home Page");
strcat(buffer, "Woohoo! Finally got a CGI home page.
");
strcat(buffer, "");
strcat(buffer, "");
theCgiPtr->fResponseState = eRpCgiLastBuffer;
theCgiPtr->fHttpResponse = eRpCgiHttpOk;
theCgiPtr->fResponseBufferPtr = buffer;
theCgiPtr->fResponseBufferLength = strlen(buffer);
}