From 89b88d27b20641e04cd1c2714c299d8908822b54 Mon Sep 17 00:00:00 2001
From: swhite
Date: Tue, 6 Apr 2004 17:45:14 +0000
Subject: Regarding Cactus bug report 1632 "HTTPD contains buffer overflows"
1) Got rid of most strcat/sprintf into automatic array, replaced
with a String module that allocates dynamic memory on the heap.
2) Went a long way toward initializing all variables.
3) Tested: Ran two copies with same parfile except different port,
one with my changes, one with original. Went through different
kinds of pages by hand, checked by eye.
4) Tried to make HTML XHTML 1.0-compliant. Checked with Amaya.
One problem: How to deal with raw less-than characters, etc.
Made a function to convert them to HTML Character Entities,
but isn't clear this will work properly in the forms. So
I left these symbols in the forms.
5) Also checked with more primitive browsers, lynx and dillo.
6) Marked a few instances of questionable code with 'SW'
To do
-----
Document a few new functions, esp. in Content.c
git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@187 1faa4e14-9dd3-4be0-9f0e-ffe519881164
---
src/Content.c | 971 ++++++++++++++++++++++++++++++----------------------------
1 file changed, 507 insertions(+), 464 deletions(-)
(limited to 'src/Content.c')
diff --git a/src/Content.c b/src/Content.c
index 2cf34a7..425b9f2 100644
--- a/src/Content.c
+++ b/src/Content.c
@@ -40,10 +40,13 @@
#include "cctk_Arguments.h"
#include "cctk_Parameters.h"
+#include "http_SString.h"
+
static const char *rcsid = "$Header$";
CCTK_FILEVERSION(CactusConnect_HTTPD_Content_c)
+#define EMPTYSTRING {'\0'}
/********************************************************************
********************* Local Data Types ***********************
********************************************************************/
@@ -103,11 +106,10 @@ int HTTPi_RegisterParameterPages(void);
struct httpLink *ContentLinks = NULL;
static const char *notauthorized_page =
-"\nError 401: Not Authorized\
-You are not authorized to access this page\n\n";
+"\nError 401: Not Authorized\n\n"
+"\nYou are not authorized to access this page\n\n\n";
-#define USER_LENGTH 255
/********************************************************************
********************* External Routines **********************
********************************************************************/
@@ -212,12 +214,10 @@ int HTTP_ContentLink(const char *URL,
const char *description,
int flags)
{
- int retval;
- struct httpLink *hlink;
+ int retval = -1;
struct httpLink *last;
struct httpLink *current;
-
- hlink = (struct httpLink *)malloc(sizeof(struct httpLink));
+ struct httpLink *hlink = (struct httpLink *)malloc(sizeof(struct httpLink));
if(hlink)
{
@@ -243,10 +243,6 @@ int HTTP_ContentLink(const char *URL,
retval = 0;
}
- else
- {
- retval = -1;
- }
return retval;
}
@@ -297,146 +293,211 @@ static int CompareStrings(const void *string1, const void *string2)
@endhistory
@@*/
+int
+Send_HTTP( httpRequest * request, const char * message )
+{
+ return HTTP_Write(request, message, strlen(message));
+}
+
+int
+Send_HTTP_String( httpRequest *request, const String * message )
+{
+ return Send_HTTP(request, GetBuffer( message ) );
+}
+
+void
+SendHTTP_OK_Header( httpRequest *request )
+{
+ /* Status message */
+ Send_HTTP(request, "HTTP/1.0 200 OK\r\n");
+
+ /* Content-Type */
+ Send_HTTP(request, "Content-Type: text/html\r\n");
+ Send_HTTP(request, "\r\n");
+}
+
+void
+SSUtil_SplitFilename(const char **dir,const char **file, const String *message)
+{
+ Util_SplitFilename((char **)dir,(char **)file,GetBuffer(message));
+}
+
+static void
+TimeListItem( String *message, int time, const char *units )
+{
+ ConcatCString(message, " " );
+ ConcatDecimal(message, time );
+ ConcatCString(message, " " );
+ ConcatCString(message, units );
+ ConcatCString(message, "\n" );
+}
+
+void
+CCTK_GetRunTitleString( String *s )
+{
+ char buf[1024] = EMPTYSTRING;
+ CCTK_RunTitle(sizeof(buf)-1,buf);
+ SetToCString( s, buf );
+}
+
+void
+CCTK_GetParameterFilenameString( String *name )
+{
+ char buf[1024] = EMPTYSTRING;
+ CCTK_ParameterFilename(sizeof(buf)-1,buf);
+ SetToCString( name, buf );
+}
+
static int MainPage(const cGH *cctkGH, httpRequest *request, void *data)
{
DECLARE_CCTK_PARAMETERS
- int retval;
- char message[10098];
- char title[4098];
- char menu[4098];
- char *dir;
- char *file;
- char *user;
- struct httpLink *hlink;
+ int retval = -1;
+ String *message = String_New();
+ String *title = String_New();
+ String *menu = String_New();
+ const char *dir = NULL;
+ const char *file = NULL;
+ char *user = NULL;
+ struct httpLink *hlink = NULL;
int seconds,minutes,hours,days,weeks,months,years,millenia;
- char host[HOSTLENGTH+1];
+ char host[HOSTLENGTH+1] = EMPTYSTRING;
/* avoid compiler warning about unused parameter */
data = data;
- /* Status message */
- strcpy(message,"HTTP/1.0 200 OK\r\n");
-
- HTTP_Write(request, message, strlen(message));
-
- /* Content-Type */
- strcpy(message,"Content-Type: text/html\r\n\r\n");
-
- HTTP_Write(request, message, strlen(message));
+ SendHTTP_OK_Header( request );
+ SetHTML_Doctype( message );
+ Send_HTTP_String(request, message);
/* Start the page */
- strcpy(message,"Running CACTUS Status Information\n");
-
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request, "\n\n");
+ Send_HTTP(request, "Running CACTUS Status Information\n");
+ SetHTML_HeadHeader( message);
+ Send_HTTP_String(request, message );
+ Send_HTTP(request, "\n\n");
/* Write out the main header part */
/* LIST COMPILED THORNS */
{
int i;
- int nthorns;
- const char **thorns;
-
- nthorns = CCTK_NumCompiledThorns();
- thorns = (const char **)malloc(nthorns * sizeof(char *));
- for(i=0; i < nthorns; i++)
+ int nthorns = CCTK_NumCompiledThorns();
+ if( nthorns > 0 )
{
- thorns[i] = CCTK_CompiledThorn (i);
- }
- qsort(thorns, nthorns, sizeof(char *), CompareStrings);
-
- strcpy(menu, " Active Thorns:\n");
- for(i=0; i < nthorns; i++)
- {
- if (CCTK_IsThornActive(thorns[i]))
+ const char **thorns = (const char **)malloc(nthorns * sizeof(char *));
+ if( thorns != NULL )
{
- sprintf(menu,"%s%s\n",
- menu, thorns[i], thorns[i]);
+ for(i=0; i < nthorns; i++)
+ thorns[i] = CCTK_CompiledThorn (i);
+
+ qsort(thorns, nthorns, sizeof(char *), CompareStrings);
+
+ SetToCString( menu,"Active Thorns:
\n");
+ for(i=0; i < nthorns; i++)
+ if (CCTK_IsThornActive(thorns[i]))
+ {
+ ConcatCString( menu,"");
+ ConcatCString( menu, thorns[i]);
+ ConcatCString( menu,"
\n");
+ }
+ free(thorns);
}
}
- free(thorns);
}
- HTTP_ContentHeader(cctkGH, 0, 10096, message, menu);
- HTTP_Write(request, message, strlen(message));
+ SetHTML_ContentHeader(cctkGH, 0, message, menu);
+ Send_HTTP_String(request, message );
- strcpy(message,"\n"
- "
\n");
+ Send_HTTP(request,
+ "\n"
+ "
![\"Cactus\"](\"/Images/wwwcactuscodeorg.jpg\"")
\n");
- HTTP_Write(request, message, strlen(message));
-
- CCTK_RunTitle(4098,title);
+ CCTK_GetRunTitleString(title);
/* Some blurb */
- sprintf(message, "
"
- "\n"
- "\n"
- "\n"
- "\n"
- "%s\n"
- "This browser is connected to a Cactus simulation which "
- "contains a web server thorn. This thorn provides information "
- " and control for the simulation. \n"
- "\n"
- "\n"
- "\n"
- " Before controlling any features of the simulation, users "
- "must authenticate. \n"
- " | \n"
- " | \n"
- "
\n"
- "
\n",title);
-
- HTTP_Write(request, message, strlen(message));
-
- strcpy(message,
- "\n"
- "\n"
- "\n"
- "\n");
- HTTP_Write(request, message, strlen(message));
+ SetToCString(message,
+ "\n"
+ " \n"
+ "\n"
+ "\n"
+ "");
+ Concat(message, title );
+ ConcatCString(message,
+ "\n"
+ "This browser is connected to a Cactus simulation which \n"
+ "contains a web server thorn. This thorn provides information \n"
+ " and control for the simulation. \n"
+ "\n"
+ "\n"
+ "\n"
+ " Before controlling any features of the simulation, users \n"
+ "must authenticate. \n"
+ " | \n"
+ " | \n"
+ " \n"
+ " \n"
+ " \n");
+
+ Send_HTTP_String(request, message );
+
+ Send_HTTP(request,
+ "\n"
+ "\n"
+ "\n");
/* AVAILABLE OPTIONS */
if(ContentLinks)
{
- strcpy(message,
- "Available options:\n"
- "\n");
+ SetToCString(message,
+ "Available options:\n"
+ "\n");
for(hlink = ContentLinks; hlink; hlink=hlink->next)
{
- sprintf(message,
- "%s- %s
- %s \n",
- message, hlink->URL, hlink->name, hlink->description);
-
+ ConcatCString(message, "
- URL );
+ ConcatCString(message, "\">" );
+ ConcatCString(message, hlink->name );
+ ConcatCString(message, "
\n- " );
+ ConcatCString(message, hlink->description );
+ ConcatCString(message, "
\n" );
}
- sprintf(message,"%s \n",message);
- HTTP_Write(request, message, strlen(message));
+ ConcatCString(message, " \n" );
+ Send_HTTP_String(request, message );
}
- strcpy(message,
- " | \n"
- "\n");
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request,
+ " | \n"
+ "\n");
/* CONFIGURATION DETAILS */
- sprintf(message,
+ SetToCString(message,
"Simulation:\n"
"\n"
- "- Flesh version %s
\n"
- "- Flesh compiled on %s"
- " at %s
\n",
- CCTK_FullVersion(),CCTK_CompileDate(),CCTK_CompileTime());
-
- HTTP_Write(request, message, strlen(message));
+ "- Flesh version ");
+ ConcatCString(message, CCTK_FullVersion() );
+ ConcatCString(message,
+ "
\n"
+ "- Flesh compiled on ");
+ ConcatCString(message, CCTK_CompileDate() );
+ ConcatCString(message,
+ "\n"
+ " at ");
+ ConcatCString(message, CCTK_CompileTime() );
+ ConcatCString(message,
+ "
\n");
+
+ Send_HTTP_String(request, message );
seconds = CCTK_RunTime();
minutes = seconds/60;
@@ -454,66 +515,59 @@ static int MainPage(const cGH *cctkGH, httpRequest *request, void *data)
millenia=years/1000;
years=years-millenia*1000;
- strcpy(message,"- Time since start up\n
");
+ SetToCString(message, "- Time since start up\n
");
if (millenia)
{
- sprintf(message,
- "%s - %d millenia\n",message,millenia);
+ TimeListItem( message, millenia, "millenia" );
}
if (years)
{
- sprintf(message,
- "%s
- %d years\n",message,years);
+ TimeListItem( message, years, "years" );
}
if (months)
{
- sprintf(message,
- "%s
- %d months\n",message,months);
+ TimeListItem( message, months, "months" );
}
if (weeks)
{
- sprintf(message,
- "%s
- %d weeks\n",message,weeks);
+ TimeListItem( message, weeks, "weeks" );
}
if (days)
{
- sprintf(message,
- "%s
- %d days\n",message,days);
+ TimeListItem( message, days, "days" );
}
if (hours)
{
- sprintf(message,
- "%s
- %d hours\n",message,hours);
+ TimeListItem( message, hours, "hours" );
}
if (minutes)
{
- sprintf(message,
- "%s
- %d minutes\n",message,minutes);
+ TimeListItem( message, minutes, "minutes" );
}
if (seconds)
{
- sprintf(message,
- "%s
- %d seconds\n",message,seconds);
+ TimeListItem( message, seconds, "seconds" );
}
- strcat(message,"
- Parameter filename ");
- HTTP_Write(request, message, strlen(message));
+ ConcatCString(message, "
\n- Parameter filename " );
+ Send_HTTP_String(request, message );
- CCTK_ParameterFilename(4098,message);
- Util_SplitFilename(&dir,&file,message);
- HTTP_Write(request, file, strlen(file));
+ CCTK_GetParameterFilenameString(message);
+ SSUtil_SplitFilename(&dir,&file,message);
+ Send_HTTP(request, file);
- strcpy(message,"\n");
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request, "
\n");
if (cctkGH && cctkGH->cctk_iteration)
{
- strcpy(message,"- Estimated time per iteration:
");
- sprintf(message,"%s - %f seconds
",
- message,CCTK_RunTime()/(double)cctkGH->cctk_iteration);
- HTTP_Write(request, message, strlen(message));
+ SetToCString(message, " - Estimated time per iteration:
\n");
+ ConcatCString(message, " - ");
+ ConcatDouble(message, CCTK_RunTime()/(double)cctkGH->cctk_iteration );
+ ConcatCString(message, " seconds
\n");
- strcpy(message,"- Estimated time to completion:
");
+ Send_HTTP_String(request, message );
+
+ SetToCString(message, "- Estimated time to completion:\n
");
if (cctk_final_time%d millenia\n",message,millenia);
+ TimeListItem( message, millenia, "millenia" );
}
if (years)
{
- sprintf(message,
- "%s - %d years\n",message,years);
+ TimeListItem( message, years, "years" );
}
if (months)
{
- sprintf(message,
- "%s
- %d months\n",message,months);
+ TimeListItem( message, months, "months" );
}
if (weeks)
{
- sprintf(message,
- "%s
- %d weeks\n",message,weeks);
+ TimeListItem( message, months, "months" );
}
if (days)
{
- sprintf(message,
- "%s
- %d days\n",message,days);
+ TimeListItem( message, days, "days" );
}
if (hours)
{
- sprintf(message,
- "%s
- %d hours\n",message,hours);
+ TimeListItem( message, hours, "hours" );
}
if (minutes)
{
- sprintf(message,
- "%s
- %d minutes\n",message,minutes);
+ TimeListItem( message, minutes, "minutes" );
}
if (seconds)
{
- sprintf(message,
- "%s
- %d seconds\n",message,seconds);
+ TimeListItem( message, seconds, "seconds" );
}
- strcat(message,"
");
+ ConcatCString(message, " \n");
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP_String(request, message );
}
Util_GetHostName(host,HOSTLENGTH);
@@ -593,41 +639,44 @@ static int MainPage(const cGH *cctkGH, httpRequest *request, void *data)
if (CCTK_nProcs(cctkGH) == 1)
{
- sprintf(message,
- "- Single processor run
\n"
- "- Running on %s
\n",host);
+ SetToCString(message, "- Single processor run
\n"
+ "- Running on " );
+ ConcatCString(message, host);
+ ConcatCString(message, "
\n");
}
else
{
- sprintf(message,
- " - Multiprocessor run on %d CPUs
\n"
- " - Processor 0 running on %s
\n",
- CCTK_nProcs(cctkGH),host);
+ SetToCString(message, " - Multiprocessor run on " );
+ ConcatDecimal(message, CCTK_nProcs(cctkGH));
+ ConcatCString(message, " CPUs
\n"
+ " - Processor 0 running on ");
+ ConcatCString(message, host);
+ ConcatCString(message, "
\n");
}
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP_String(request, message );
user = getenv ("USER");
if (user)
{
- sprintf(message, " - Started by %s
\n",user);
+ SetToCString(message, " - Started by ");
+ ConcatCString(message, user);
+ ConcatCString(message, "
\n");
+ Send_HTTP_String(request, message );
}
- HTTP_Write(request, message, strlen(message));
- strcpy(message," ");
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request, "\n");
/* Finish table started by blurb */
- strcpy(message,
- " | \n"
- " \n"
- " \n"
- "\n");
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request, " | \n
\n
\n\n");
/* Write out the footer part. */
- HTTP_ContentFooter(cctkGH, 0, 4096, message);
- retval = HTTP_Write(request, message, strlen(message));
+ SetHTML_ContentFooter(cctkGH, 0, message);
+ retval = Send_HTTP_String(request, message );
+
+ String_Delete( message );
+ String_Delete( title );
+ String_Delete( menu );
return retval;
}
@@ -657,10 +706,9 @@ static int MainPage(const cGH *cctkGH, httpRequest *request, void *data)
@@*/
static int RegisterImages(void)
{
- struct httpStaticPage *image;
- struct httpStaticPage *image2;
-
- image = (struct httpStaticPage *)malloc(sizeof(struct httpStaticPage));
+ struct httpStaticPage *image2 = NULL;
+ struct httpStaticPage *image
+ = (struct httpStaticPage *)malloc(sizeof(struct httpStaticPage));
if(image)
{
@@ -709,37 +757,35 @@ static int RegisterImages(void)
@@*/
static int ShowStaticPage(const cGH *cctkGH, httpRequest *request, void *data)
{
- int retval;
- char message[1024];
- struct httpStaticPage *page;
+ int retval = -1;
/* avoid compiler warning about unused parameter */
cctkGH = cctkGH;
if(data)
{
- page = (struct httpStaticPage *)data;
+ struct httpStaticPage *page = (struct httpStaticPage *)data;
+ String *message = String_New();
- strcpy(message,"HTTP/1.0 200 OK\r\n");
-
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request, "HTTP/1.0 200 OK\r\n");
- sprintf(message,"Content-Length: %d\r\nContent-Type: %s\r\n\r\n", page->length, page->mime_type);
+ SetToCString(message, "Content-Length: ");
+ ConcatDecimal(message, page->length );
+ ConcatCString(message, "\r\nContent-Type: ");
+ ConcatCString(message, page->mime_type );
+ ConcatCString(message, "\r\n\r\n");
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP_String(request, message);
retval = HTTP_Write(request, page->page, page->length);
- }
- else
- {
- retval = -1;
- }
+ String_Delete( message );
+ }
return retval;
}
-
+#define USER_LENGTH 255
/*@@
@routine ControlPage
@date Sun Sep 17 14:37:59 2000
@@ -758,142 +804,155 @@ static int ControlPage(const cGH *cctkGH, httpRequest *request, void *data)
{
DECLARE_CCTK_PARAMETERS
- char message[4098];
-
- int notauthorised;
+ int notauthorised = 0;
+ char thisuser[USER_LENGTH+1] = EMPTYSTRING;
- char thisuser[USER_LENGTH+1];
+ data = data; /* avoid compiler warning about unused parameter */
- /* avoid compiler warning about unused parameter */
- data = data;
-
- notauthorised = HTTP_AuthenticateBasic(request, "user", thisuser, USER_LENGTH);
+ notauthorised = HTTP_AuthenticateBasic(request, "user", thisuser,
+ sizeof(thisuser));
if(!notauthorised)
{
/* Ok the person is authorised. */
if(request->n_arguments == 0)
{
+ String *message = String_New();
/* No arguments, so just display the page */
- strcpy(message,"HTTP/1.0 200 Ok\r\n");
-
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request,"HTTP/1.0 200 Ok\r\n");
- strcpy(message,"WWW-Authenticate: Basic realm=\"Cactus Control\"\r\n");
-
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request,"WWW-Authenticate: Basic realm=\"Cactus Control\"\r\n");
HTTP_CookieSend(request,"user", thisuser, "/", NULL, NULL, 0);
- strcpy(message,"Content-Type: text/html\r\n\r\n");
-
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request,"Content-Type: text/html\r\n\r\n");
+ SetHTML_Doctype( message );
+ Send_HTTP_String(request, message);
/* Start the page */
- strcpy(message, "Cactus Control and Status Page\n");
-
- HTTP_Write(request, message, strlen(message));
- HTTP_ContentHeader(cctkGH, 0,4098,message,NULL);
+ Send_HTTP(request, "\n");
+ Send_HTTP(request, "Cactus Control and Status Page\n");
- strcat(message, "Control and Status Page
");
+ SetHTML_HeadHeader( message);
+ Send_HTTP_String(request, message );
- HTTP_Write(request, message, strlen(message));
-
- strcpy(message,
- "This page is the control center for interacting with"
- " the current simulation. It is possible to steer certain"
- " parameters, as well as pause, restart, or terminate the"
- " simulation.
");
-
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request, "\n\n");
+
+ SetHTML_ContentHeader(cctkGH, 0,message,NULL);
- strcpy(message,
- "\n"
- "
\n"
+ "The HTTPD module, or thorn "
+ "which is serving these pages\n"
+ " can be added to any Cactus application to provide on-line \n"
+ "monitoring and control of simulations from any web browser.
\n"
+ "This HTTPD server and thorn interface has been designed and \n"
+ "and implemented by Tom Goodale, based on the original idea and \n"
+ "implementation by Werner Benger.
\n");
- retval = HTTP_Write(request, message, strlen(message));
+ retval = Send_HTTP_String(request, message);
- strcpy(message, "For more information about Cactus, visit our "
- "permanent home page at "
- "www.cactuscode.org
");
+ SetToCString(message, "For more information about Cactus, visit our "
+ "permanent home page at \n"
+ "www.cactuscode.org
\n");
- retval = HTTP_Write(request, message, strlen(message));
+ retval = Send_HTTP_String(request, message);
/* Write out the footer part. */
- HTTP_ContentFooter(cctkGH,0,4098,message);
- retval = HTTP_Write(request, message, strlen(message));
+ SetHTML_ContentFooter(cctkGH,0,message);
+ retval = Send_HTTP_String(request, message);
+ String_Delete( message);
return retval;
}
@@ -1397,18 +1438,16 @@ static int AboutPage(const cGH *cctkGH, httpRequest *request, void *data)
@@*/
static int CookieTestPage(const cGH *cctkGH, httpRequest *request, void *data)
{
- int retval;
- char message[4098];
- const char *value;
- char *value2;
+ int retval = -1;
+ String *message = String_New();
+ const char *value = NULL;
+ char *value2 = NULL;
/* avoid compiler warning about unused parameter */
data = data;
/* Status message */
- strcpy(message,"HTTP/1.0 200 OK\r\n");
-
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request,"HTTP/1.0 200 OK\r\n");
/* Cookie */
HTTP_CookieSend(request, "user1", "foobar4", NULL,NULL,NULL,0);
@@ -1419,45 +1458,49 @@ static int CookieTestPage(const cGH *cctkGH, httpRequest *request, void *data)
HTTP_CookieSend(request, "user4", "foobar1", NULL,NULL,NULL,0);
- strcpy(message,"Content-Type: text/html\r\n\r\n");
-
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request,"Content-Type: text/html\r\n\r\n");
+ SetHTML_Doctype( message );
+ Send_HTTP_String(request, message);
/* Start the page */
- strcpy(message, "Cookie Test\n");
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request, "Cookie Test\n");
+ SetHTML_HeadHeader( message);
+ Send_HTTP_String(request, message );
- HTTP_ContentHeader(cctkGH,0,4098,message,NULL);
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request, "\n\n");
- strcat(message, "Cookie Test
");
+ SetHTML_ContentHeader(cctkGH,0,message,NULL);
+ Send_HTTP_String(request, message);
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request, "Cookie Test
\n");
- strcpy(message, "");
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request, "");
value = HTTP_HeaderValue(request, "Cookie");
- sprintf(message, "
Cookie was '%s'
\n", value);
+ SetToCString(message, "
Cookie was '");
+ ConcatCString(message, value);
+ ConcatCString(message, "'
\n");
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP_String(request, message);
value2 = HTTP_CookieGet(request,"user3");
- sprintf(message, "
Cookie from decoder was '%s'
\n", value2);
+ SetToCString(message, "
Cookie from decoder was '");
+ ConcatCString(message, value2);
+ ConcatCString(message, "'
\n");
free(value2);
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP_String(request, message);
- strcpy(message,"");
- HTTP_Write(request, message, strlen(message));
+ Send_HTTP(request,"
\n");
/* Write out the footer part. */
- HTTP_ContentFooter(cctkGH,0,4098,message);
- retval = HTTP_Write(request, message, strlen(message));
+ SetHTML_ContentFooter(cctkGH,0,message);
+ retval = Send_HTTP_String(request, message);
+ String_Delete( message );
return retval;
}
--
cgit v1.2.3