aboutsummaryrefslogtreecommitdiff
path: root/src/Content.c
diff options
context:
space:
mode:
authorjshalf <jshalf@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2001-05-18 02:50:51 +0000
committerjshalf <jshalf@1faa4e14-9dd3-4be0-9f0e-ffe519881164>2001-05-18 02:50:51 +0000
commit8b12a1b456d296db9c305a1f008dbf93f515301c (patch)
tree3cdb29f0a47b626f26d4b18055b676a5a0b32ee2 /src/Content.c
parentd843bdb3d90b9a4fc22ddff4c750376d27d0105e (diff)
Modifications so that all cluster nodes involved in a simulation will
use http server redirect to route web-browsers to the master httpd node. The modifications are able to sense the different between nodes on the same SMP with shared network interface and those on different boxes. Tested on SP2, IA64, and IA32 clusters so far. git-svn-id: http://svn.cactuscode.org/arrangements/CactusConnect/HTTPD/trunk@128 1faa4e14-9dd3-4be0-9f0e-ffe519881164
Diffstat (limited to 'src/Content.c')
-rw-r--r--src/Content.c95
1 files changed, 90 insertions, 5 deletions
diff --git a/src/Content.c b/src/Content.c
index 757fcc3..2f2ffba 100644
--- a/src/Content.c
+++ b/src/Content.c
@@ -69,6 +69,7 @@ struct httpLink
static int RegisterImages(void);
+static int RedirectPage(cGH *cctkGH, httpRequest *request, void *data);
static int MainPage(cGH *cctkGH, httpRequest *request, void *data);
static int AboutPage(cGH *cctkGH, httpRequest *request, void *data);
@@ -87,6 +88,7 @@ static int CookieTestPage(cGH *cctkGH, httpRequest *request, void *data);
********************************************************************/
void HTTP_ContentWork(cGH *GH);
+int HTTP_RegisterRedirect(void);
int HTTP_RegisterPages(void);
int HTTPi_RegisterGroupsPages(void);
int HTTPi_RegisterThornPages(void);
@@ -133,6 +135,7 @@ void HTTP_ContentWork(cGH *GH)
#endif
}
+
/*@@
@routine HTTP_RegisterPages
@date Wed Sep 13 23:47:43 2000
@@ -190,6 +193,29 @@ int HTTP_RegisterPages(void)
}
/*@@
+ @routine HTTP_RegisterRedirect
+ @date Fri April 20 23:47:43 2001
+ @author John Shalf
+ @desc
+ Redirection Page Registration.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+int HTTP_RegisterRedirect(void){
+ DECLARE_CCTK_PARAMETERS
+#ifdef HTTP_DEBUG
+ printf("Registering Redirection Page");
+#endif
+ HTTP_RegisterPage("/index.html",RedirectPage,NULL);
+ RegisterImages();
+}
+
+ /*@@
@routine HTTP_ContentLink
@date Sun Sep 17 13:17:56 2000
@author Tom Goodale
@@ -276,6 +302,70 @@ static int CompareStrings(const void *string1, const void *string2)
/*@@
+ @routine RedirectPage
+ @date Fri April 20 23:47:43 2001
+ @author John Shalf
+ @desc
+ Redirects the webbrowser to the main server page
+ @enddesc
+ @calls
+ @calledby
+ @history
+ @hdate Thu Sep 14 10:54:22 2000 @hauthor John Shalf
+ @hdesc For clusters where its difficult to know which node is going to
+ have the webserver process, this opens a port on *all* distinct nodes
+ and redirects all web connection attempts to the root node for processing.
+ @endhistory
+
+@@*/
+
+static int RedirectPage(cGH *cctkGH, httpRequest *request, void *data)
+{
+
+ DECLARE_CCTK_PARAMETERS
+
+ int retval;
+ char message[10098];
+ char title[4098];
+ char menu[4098];
+ char *dir;
+ char *file;
+ struct httpLink *hlink;
+
+ /* 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));
+
+ /* Start the page */
+ strcpy(message,"<HTML><HEAD><TITLE>Server Redirect</TITLE>\n");
+ /* Write out the main header part */
+ HTTP_Write(request, message, strlen(message));
+ sprintf(message,"<META http-equiv=\"refresh\" content=\"1; URL=http://%s:%u\"></HEAD><body>\n",
+ HTTP_Master(),HTTP_Port());
+ HTTP_Write(request,message,strlen(message));
+ /* ********** Server Redirect To Master ************* */
+ sprintf(message,"<p><h1>Redirect to master host=%s:%u</h1><p>\n",
+ HTTP_Master(),HTTP_Port());
+ HTTP_Write(request,message,strlen(message));
+
+ HTTP_ContentFooter(cctkGH, 0, 4096, message);
+ retval = HTTP_Write(request, message, strlen(message));
+
+ /* retval = HTTP_Write(request, base_page, strlen(base_page)); */
+
+ return retval;
+}
+
+ /*@@
@routine MainPage
@date Wed Sep 13 23:47:43 2000
@author Tom Goodale
@@ -611,8 +701,6 @@ static int MainPage(cGH *cctkGH, httpRequest *request, void *data)
HTTP_ContentFooter(cctkGH, 0, 4096, message);
retval = HTTP_Write(request, message, strlen(message));
- /* retval = HTTP_Write(request, base_page, strlen(base_page)); */
-
return retval;
}
@@ -1254,9 +1342,6 @@ static int ControlTerminationPage(cGH *cctkGH, httpRequest *request)
HTTP_ContentFooter(cctkGH,0,4098,message);
retval = HTTP_Write(request, message, strlen(message));
-
- /* retval = HTTP_Write(request, base_page, strlen(base_page)); */
-
return retval;
}