mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-02-21 02:41:04 +00:00
add support for /wo/showapps
return HTTP status 504 if app is unreachable
This commit is contained in:
parent
e1114e4395
commit
3d5a52e699
3 changed files with 94 additions and 74 deletions
|
@ -1,9 +1,14 @@
|
|||
2017-12-04 David Wetzel <dave@turbocat.de>
|
||||
* GSWAdaptors/Apache2/mod_gsw.c
|
||||
add support for /wo/showapps
|
||||
return HTTP status 504 if app is unreachable
|
||||
* GSWAdaptors/README.txt
|
||||
update note for /wo/showapps
|
||||
2017-11-19 David Wetzel <dave@turbocat.de>
|
||||
* GSWAdaptors/Apache2/mod_gsw.c
|
||||
compiles with Apache 2.4 now
|
||||
* GSWAdaptors/README.txt
|
||||
updated readme
|
||||
|
||||
2017-11-19 David Wetzel <dave@turbocat.de>
|
||||
* GSWeb/GSWAjaxRequestHandler.*
|
||||
new files
|
||||
|
|
|
@ -1219,117 +1219,9 @@ static void print_css(request_rec * r)
|
|||
</style>\n", r);
|
||||
}
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* Now we declare our content handlers, which are invoked when the server */
|
||||
/* encounters a document which our module is supposed to have a chance to */
|
||||
/* see. (See mod_mime's SetHandler and AddHandler directives, and the */
|
||||
/* mod_info and mod_status gsws, for more details.) */
|
||||
/* */
|
||||
/* Since content handlers are dumping data directly into the connection */
|
||||
/* (using the r*() routines, such as rputs() and rprintf()) without */
|
||||
/* intervention by other parts of the server, they need to make */
|
||||
/* sure any accumulated HTTP headers are sent first. This is done by */
|
||||
/* calling send_http_header(). Otherwise, no header will be sent at all, */
|
||||
/* and the output sent to the client will actually be HTTP-uncompliant. */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Sample content handler. All this does is display the call list that has
|
||||
* been built up so far.
|
||||
*
|
||||
* The return value instructs the caller concerning what happened and what to
|
||||
* do next:
|
||||
* OK ("we did our thing")
|
||||
* DECLINED ("this isn't something with which we want to get involved")
|
||||
* HTTP_mumble ("an error status should be reported")
|
||||
*/
|
||||
static int gsw_handler(request_rec *r)
|
||||
static void showApps(request_rec * r, gsw_cfg *dcfg)
|
||||
{
|
||||
gsw_app_conf * app = NULL;
|
||||
gsw_cfg * dcfg;
|
||||
char data1[1024];
|
||||
char data[1024];
|
||||
void * user_data;
|
||||
int handle_status = OK;
|
||||
void * postdata = NULL;
|
||||
uint32_t contentLen = 0;
|
||||
|
||||
|
||||
// ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "xx handler uri: %s", r->uri);
|
||||
|
||||
if (strncmp(r->uri, "/wo/",4) != 0) {
|
||||
// ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "xx handler DECLINED");
|
||||
return DECLINED;
|
||||
}
|
||||
|
||||
|
||||
dcfg = our_dconfig(r);
|
||||
|
||||
/*
|
||||
* We're about to start sending content, so we need to force the HTTP
|
||||
* headers to be sent at this point. Otherwise, no headers will be sent
|
||||
* at all. We can set any we like first, of course. **NOTE** Here's
|
||||
* where you set the "Content-type" header, and you do so by putting it in
|
||||
* r->content_type, *not* r->headers_out("Content-type"). If you don't
|
||||
* set it, it will be filled in with the server's default type (typically
|
||||
* "text/plain"). You *must* also ensure that r->content_type is lower
|
||||
* case.
|
||||
*
|
||||
* We also need to start a timer so the server can know if the connexion
|
||||
* is broken.
|
||||
*/
|
||||
|
||||
|
||||
app = find_app(r);
|
||||
|
||||
if (app != NULL) {
|
||||
int i;
|
||||
handle_status = OK;
|
||||
|
||||
if (ap_setup_client_block(r, REQUEST_CHUNKED_ERROR) != OK) {
|
||||
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "handle_request: DECLINED");
|
||||
} else {
|
||||
if (r->method_number == M_POST) {
|
||||
contentLen = get_content_len(r);
|
||||
postdata = read_post_data(r, contentLen, r->pool, app);
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; ((i < RETRY_COUNT) && (handle_status <= OK)); i++) {
|
||||
handle_status = handle_request(r, app, postdata, contentLen);
|
||||
|
||||
switch (handle_status) {
|
||||
case UNREACHABLE:
|
||||
mark_unreachable(r,app);
|
||||
app = find_app(r);
|
||||
break;
|
||||
case DECLINED:
|
||||
break;
|
||||
case OK:
|
||||
return handle_status;
|
||||
case HTTP_MOVED_TEMPORARILY:
|
||||
return OK; // otherwise, we get a apache error doc!
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((handle_status > OK)) {
|
||||
return handle_status;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ap_set_content_type(r, "text/html");
|
||||
/*
|
||||
* If we're only supposed to send header information (HEAD request), we're
|
||||
* already there.
|
||||
*/
|
||||
if (r->header_only) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now send our actual output. Since we tagged this as being
|
||||
|
@ -1398,6 +1290,125 @@ static int gsw_handler(request_rec *r)
|
|||
|
||||
ap_rputs("</div>\n</body>\n", r);
|
||||
ap_rputs("</html>\n", r);
|
||||
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/* */
|
||||
/* Now we declare our content handlers, which are invoked when the server */
|
||||
/* encounters a document which our module is supposed to have a chance to */
|
||||
/* see. (See mod_mime's SetHandler and AddHandler directives, and the */
|
||||
/* mod_info and mod_status gsws, for more details.) */
|
||||
/* */
|
||||
/* Since content handlers are dumping data directly into the connection */
|
||||
/* (using the r*() routines, such as rputs() and rprintf()) without */
|
||||
/* intervention by other parts of the server, they need to make */
|
||||
/* sure any accumulated HTTP headers are sent first. This is done by */
|
||||
/* calling send_http_header(). Otherwise, no header will be sent at all, */
|
||||
/* and the output sent to the client will actually be HTTP-uncompliant. */
|
||||
/*--------------------------------------------------------------------------*/
|
||||
/*
|
||||
* Sample content handler. All this does is display the call list that has
|
||||
* been built up so far.
|
||||
*
|
||||
* The return value instructs the caller concerning what happened and what to
|
||||
* do next:
|
||||
* OK ("we did our thing")
|
||||
* DECLINED ("this isn't something with which we want to get involved")
|
||||
* HTTP_mumble ("an error status should be reported")
|
||||
*/
|
||||
static int gsw_handler(request_rec *r)
|
||||
{
|
||||
gsw_app_conf * app = NULL;
|
||||
gsw_cfg * dcfg;
|
||||
char data1[1024];
|
||||
char data[1024];
|
||||
void * user_data;
|
||||
int handle_status = OK;
|
||||
void * postdata = NULL;
|
||||
uint32_t contentLen = 0;
|
||||
|
||||
|
||||
// ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "xx handler uri: %s", r->uri);
|
||||
|
||||
if (strncmp(r->uri, "/wo/",4) != 0) {
|
||||
// ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "xx handler DECLINED");
|
||||
return DECLINED;
|
||||
}
|
||||
|
||||
|
||||
dcfg = our_dconfig(r);
|
||||
|
||||
if (strncmp(r->uri, "/wo/showapps",12) == 0) {
|
||||
showApps(r, dcfg);
|
||||
return OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* We're about to start sending content, so we need to force the HTTP
|
||||
* headers to be sent at this point. Otherwise, no headers will be sent
|
||||
* at all. We can set any we like first, of course. **NOTE** Here's
|
||||
* where you set the "Content-type" header, and you do so by putting it in
|
||||
* r->content_type, *not* r->headers_out("Content-type"). If you don't
|
||||
* set it, it will be filled in with the server's default type (typically
|
||||
* "text/plain"). You *must* also ensure that r->content_type is lower
|
||||
* case.
|
||||
*
|
||||
* We also need to start a timer so the server can know if the connexion
|
||||
* is broken.
|
||||
*/
|
||||
|
||||
|
||||
app = find_app(r);
|
||||
|
||||
if (app != NULL) {
|
||||
int i;
|
||||
handle_status = OK;
|
||||
|
||||
if (ap_setup_client_block(r, REQUEST_CHUNKED_ERROR) != OK) {
|
||||
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "handle_request: DECLINED");
|
||||
} else {
|
||||
if (r->method_number == M_POST) {
|
||||
contentLen = get_content_len(r);
|
||||
postdata = read_post_data(r, contentLen, r->pool, app);
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; ((i < RETRY_COUNT) && (handle_status <= OK)); i++) {
|
||||
handle_status = handle_request(r, app, postdata, contentLen);
|
||||
|
||||
switch (handle_status) {
|
||||
case UNREACHABLE:
|
||||
mark_unreachable(r,app);
|
||||
app = find_app(r);
|
||||
break;
|
||||
case DECLINED:
|
||||
break;
|
||||
case OK:
|
||||
return handle_status;
|
||||
case HTTP_MOVED_TEMPORARILY:
|
||||
return OK; // otherwise, we get a apache error doc!
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((handle_status > OK)) {
|
||||
return handle_status;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If we're only supposed to send header information (HEAD request), we're
|
||||
* already there.
|
||||
*/
|
||||
// if (r->header_only) {
|
||||
//// return OK;
|
||||
// return 504;
|
||||
// }
|
||||
|
||||
/*
|
||||
* We're all done, so cancel the timeout we set. Since this is probably
|
||||
* the end of the request we *could* assume this would be done during
|
||||
|
@ -1408,7 +1419,7 @@ static int gsw_handler(request_rec *r)
|
|||
* We did what we wanted to do, so tell the rest of the server we
|
||||
* succeeded.
|
||||
*/
|
||||
return OK;
|
||||
return 504;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
|
|
@ -17,10 +17,14 @@ ShowApps on
|
|||
|
||||
App Name=TCWebMail Instance=1 Host=127.0.0.1:9804
|
||||
|
||||
|
||||
Then you start your App like this (plus your other arguments):
|
||||
|
||||
./TCWebMail.gswa/TCWebMail -WOHost 127.0.0.1 -WOPort 9804
|
||||
|
||||
If you enabled ShowApps, you can access the list of applications like this:
|
||||
|
||||
http://www.example.org/wo/showapps
|
||||
|
||||
If an application is unreachable the adaptor will return an HTTP status 504
|
||||
|
||||
dw.
|
||||
|
|
Loading…
Reference in a new issue