3636
3737#include "mod_proxy_cluster.h"
3838
39- #define DEFMAXCONTEXT 100
40- #define DEFMAXNODE 20
41- #define DEFMAXHOST 20
42- #define DEFMAXSESSIONID 0 /* it has performance/security impact */
43- #define MAXMESSSIZE 1024
39+ #define DEFMAXCONTEXT 100
40+ #define DEFMAXNODE 20
41+ #define DEFMAXHOST 20
42+ #define DEFMAXSESSIONID 0 /* it has performance/security impact */
43+ #define MAXMESSSIZE 1024
4444
4545/* Warning messages */
46- #define SBALBAD "Balancer name contained an upper case character. We will use \"%s\" instead."
46+ #define SBALBAD "Balancer name contained an upper case character. We will use \"%s\" instead."
4747
4848/* Error messages */
49- #define TYPESYNTAX 1
50- #define SMESPAR "SYNTAX: Can't parse MCMP message. It might have contained illegal symbols or unknown elements."
51- #define SBALBIG "SYNTAX: Balancer field too big"
52- #define SBAFBIG "SYNTAX: A field is too big"
53- #define SROUBIG "SYNTAX: JVMRoute field too big"
54- #define SROUBAD "SYNTAX: JVMRoute can't be empty"
55- #define SDOMBIG "SYNTAX: LBGroup field too big"
56- #define SHOSBIG "SYNTAX: Host field too big"
57- #define SPORBIG "SYNTAX: Port field too big"
58- #define STYPBIG "SYNTAX: Type field too big"
59- #define SALIBAD "SYNTAX: Alias without Context"
60- #define SCONBAD "SYNTAX: Context without Alias"
61- #define SBADFLD "SYNTAX: Invalid field \"%s\" in message"
62- #define SMISFLD "SYNTAX: Mandatory field(s) missing in message"
63- #define SCMDUNS "SYNTAX: Command is not supported"
64- #define SMULALB "SYNTAX: Only one Alias in APP command"
65- #define SMULCTB "SYNTAX: Only one Context in APP command"
66- #define SREADER "SYNTAX: %s can't read POST data"
67-
68- #define SJIDBIG "SYNTAX: JGroupUuid field too big"
69- #define SJDDBIG "SYNTAX: JGroupData field too big"
70- #define SJIDBAD "SYNTAX: JGroupUuid can't be empty"
71-
72- #define TYPEMEM 2
73- #define MNODEUI "MEM: Can't update or insert node with \"%s\" JVMRoute"
74- #define MNODERM "MEM: Old node with \"%s\" JVMRoute still exists"
75- #define MBALAUI "MEM: Can't update or insert balancer for node with \"%s\" JVMRoute"
76- #define MNODERD "MEM: Can't read node with \"%s\" JVMRoute"
77- #define MHOSTRD "MEM: Can't read host alias for node with \"%s\" JVMRoute"
78- #define MHOSTUI "MEM: Can't update or insert host alias for node with \"%s\" JVMRoute"
79- #define MCONTUI "MEM: Can't update or insert context for node with \"%s\" JVMRoute"
80- #define MJBIDRD "MEM: Can't read JGroupId"
81- #define MJBIDUI "MEM: Can't update or insert JGroupId"
82- #define MNODEET "MEM: Another for the same worker already exist"
49+ #define TYPESYNTAX 1
50+ #define SMESPAR "SYNTAX: Can't parse MCMP message. It might have contained illegal symbols or unknown elements."
51+ #define SBALBIG "SYNTAX: Balancer field too big"
52+ #define SBAFBIG "SYNTAX: A field is too big"
53+ #define SROUBIG "SYNTAX: JVMRoute field too big"
54+ #define SROUBAD "SYNTAX: JVMRoute can't be empty"
55+ #define SDOMBIG "SYNTAX: LBGroup field too big"
56+ #define SHOSBIG "SYNTAX: Host field too big"
57+ #define SPORBIG "SYNTAX: Port field too big"
58+ #define STYPBIG "SYNTAX: Type field too big"
59+ #define SALIBAD "SYNTAX: Alias without Context"
60+ #define SCONBAD "SYNTAX: Context without Alias"
61+ #define SBADFLD "SYNTAX: Invalid field \"%s\" in message"
62+ #define SMISFLD "SYNTAX: Mandatory field(s) missing in message"
63+ #define SCMDUNS "SYNTAX: Command is not supported"
64+ #define SMULALB "SYNTAX: Only one Alias in APP command"
65+ #define SMULCTB "SYNTAX: Only one Context in APP command"
66+ #define SREADER "SYNTAX: %s can't read POST data"
67+
68+ #define SJIDBIG "SYNTAX: JGroupUuid field too big"
69+ #define SJDDBIG "SYNTAX: JGroupData field too big"
70+ #define SJIDBAD "SYNTAX: JGroupUuid can't be empty"
71+
72+ #define TYPEMEM 2
73+ #define MNODEUI "MEM: Can't update or insert node with \"%s\" JVMRoute"
74+ #define MNODERM "MEM: Old node with \"%s\" JVMRoute still exists"
75+ #define MBALAUI "MEM: Can't update or insert balancer for node with \"%s\" JVMRoute"
76+ #define MNODERD "MEM: Can't read node with \"%s\" JVMRoute"
77+ #define MHOSTRD "MEM: Can't read host alias for node with \"%s\" JVMRoute"
78+ #define MHOSTUI "MEM: Can't update or insert host alias for node with \"%s\" JVMRoute"
79+ #define MCONTUI "MEM: Can't update or insert context for node with \"%s\" JVMRoute"
80+ #define MJBIDRD "MEM: Can't read JGroupId"
81+ #define MJBIDUI "MEM: Can't update or insert JGroupId"
82+ #define MNODEET "MEM: Another for the same worker already exist"
8383
8484/* Protocol version supported */
85- #define VERSION_PROTOCOL "0.2.1"
85+ #define VERSION_PROTOCOL "0.2.1"
8686
8787/* Internal substitution for node commands */
88- #define NODE_COMMAND "/NODE_COMMAND"
88+ #define NODE_COMMAND "/NODE_COMMAND"
8989
9090/* range of the commands */
91- #define RANGECONTEXT 0
92- #define RANGENODE 1
93- #define RANGEDOMAIN 2
91+ #define RANGECONTEXT 0
92+ #define RANGENODE 1
93+ #define RANGEDOMAIN 2
9494
9595/* define content-type */
96- #define TEXT_PLAIN 1
97- #define TEXT_XML 2
96+ #define TEXT_PLAIN 1
97+ #define TEXT_XML 2
98+
99+ #define PLAINTEXT_CONTENT_TYPE "text/plain"
100+ #define XML_CONTENT_TYPE "text/xml"
98101
99102/* Data structure for shared memory block */
100103typedef struct version_data
@@ -1572,12 +1575,12 @@ static char *process_dump(request_rec *r, int *errtype)
15721575 const char * accept_header = apr_table_get (r -> headers_in , "Accept" );
15731576 (void )errtype ;
15741577
1575- if (accept_header && strstr ((char * )accept_header , "text/xml" ) != NULL ) {
1576- ap_set_content_type (r , "text/xml" );
1578+ if (accept_header && strstr ((char * )accept_header , XML_CONTENT_TYPE ) != NULL ) {
1579+ ap_set_content_type (r , XML_CONTENT_TYPE );
15771580 type = TEXT_XML ;
15781581 ap_rprintf (r , "<?xml version=\"1.0\" standalone=\"yes\" ?>\n" );
15791582 } else {
1580- ap_set_content_type (r , "text/plain" );
1583+ ap_set_content_type (r , PLAINTEXT_CONTENT_TYPE );
15811584 type = TEXT_PLAIN ;
15821585 }
15831586
@@ -1771,12 +1774,12 @@ static char *process_info(request_rec *r, int *errtype)
17711774 const char * accept_header = apr_table_get (r -> headers_in , "Accept" );
17721775 (void )errtype ;
17731776
1774- if (accept_header && strstr ((char * )accept_header , "text/xml" ) != NULL ) {
1775- ap_set_content_type (r , "text/xml" );
1777+ if (accept_header && strstr ((char * )accept_header , XML_CONTENT_TYPE ) != NULL ) {
1778+ ap_set_content_type (r , XML_CONTENT_TYPE );
17761779 type = TEXT_XML ;
17771780 ap_rprintf (r , "<?xml version=\"1.0\" standalone=\"yes\" ?>\n" );
17781781 } else {
1779- ap_set_content_type (r , "text/plain" );
1782+ ap_set_content_type (r , PLAINTEXT_CONTENT_TYPE );
17801783 type = TEXT_PLAIN ;
17811784 }
17821785
@@ -2253,7 +2256,7 @@ static char *process_appl_cmd(request_rec *r, char **ptr, int status, int *errty
22532256 ap_log_error (APLOG_MARK , APLOG_DEBUG , 0 , r -> server , "process_appl_cmd: STOP-APP nbrequests %d" ,
22542257 ou -> nbrequests );
22552258 if (fromnode ) {
2256- ap_set_content_type (r , "text/plain" );
2259+ ap_set_content_type (r , PLAINTEXT_CONTENT_TYPE );
22572260 ap_rprintf (r , "Type=STOP-APP-RSP&JvmRoute=%.*s&Alias=%.*s&Context=%.*s&Requests=%d" ,
22582261 (int )sizeof (nodeinfo .mess .JVMRoute ), nodeinfo .mess .JVMRoute , (int )sizeof (vhost -> host ),
22592262 vhost -> host , (int )sizeof (vhost -> context ), vhost -> context , ou -> nbrequests );
@@ -2351,7 +2354,7 @@ static char *process_status(request_rec *r, const char *const *ptr, int *errtype
23512354 * If the node is usualable do a ping/pong to prevent Split-Brain Syndrome
23522355 * and update the worker status and load factor acccording to the test result.
23532356 */
2354- ap_set_content_type (r , "text/plain" );
2357+ ap_set_content_type (r , PLAINTEXT_CONTENT_TYPE );
23552358 ap_rprintf (r , "Type=STATUS-RSP&JVMRoute=%.*s" , (int )sizeof (nodeinfo .mess .JVMRoute ), nodeinfo .mess .JVMRoute );
23562359
23572360 ap_rprintf (r , isnode_up (r , node -> mess .id , Load ) != OK ? "&State=NOTOK" : "&State=OK" );
@@ -2371,13 +2374,13 @@ static char *process_version(request_rec *r, const char *const *const ptr, int *
23712374 (void )ptr ;
23722375 (void )errtype ;
23732376
2374- if (accept_header && strstr ((char * )accept_header , "text/xml" ) != NULL ) {
2375- ap_set_content_type (r , "text/xml" );
2377+ if (accept_header && strstr ((char * )accept_header , XML_CONTENT_TYPE ) != NULL ) {
2378+ ap_set_content_type (r , XML_CONTENT_TYPE );
23762379 ap_rprintf (r , "<?xml version=\"1.0\" standalone=\"yes\" ?>\n" );
23772380 ap_rprintf (r , "<version><release>%s</release><protocol>%s</protocol></version>" , MOD_CLUSTER_EXPOSED_VERSION ,
23782381 VERSION_PROTOCOL );
23792382 } else {
2380- ap_set_content_type (r , "text/plain" );
2383+ ap_set_content_type (r , PLAINTEXT_CONTENT_TYPE );
23812384 ap_rprintf (r , "release: %s, protocol: %s" , MOD_CLUSTER_EXPOSED_VERSION , VERSION_PROTOCOL );
23822385 }
23832386 ap_rprintf (r , "\n" );
@@ -2427,14 +2430,14 @@ static char *process_ping(request_rec *r, const char *const *ptr, int *errtype)
24272430 if (nodeinfo .mess .id == -1 ) {
24282431 /* PING scheme, host, port or just httpd */
24292432 if (scheme == NULL && host == NULL && port == NULL ) {
2430- ap_set_content_type (r , "text/plain" );
2433+ ap_set_content_type (r , PLAINTEXT_CONTENT_TYPE );
24312434 ap_rprintf (r , "Type=PING-RSP&State=OK" );
24322435 } else {
24332436 if (scheme == NULL || host == NULL || port == NULL ) {
24342437 * errtype = TYPESYNTAX ;
24352438 return apr_psprintf (r -> pool , SMISFLD );
24362439 }
2437- ap_set_content_type (r , "text/plain" );
2440+ ap_set_content_type (r , PLAINTEXT_CONTENT_TYPE );
24382441 ap_rprintf (r , "Type=PING-RSP" );
24392442 ap_rprintf (r , ishost_up (r , scheme , host , port ) != OK ? "&State=NOTOK" : "&State=OK" );
24402443 }
@@ -2453,7 +2456,7 @@ static char *process_ping(request_rec *r, const char *const *ptr, int *errtype)
24532456 * If the node is usualable do a ping/pong to prevent Split-Brain Syndrome
24542457 * and update the worker status and load factor acccording to the test result.
24552458 */
2456- ap_set_content_type (r , "text/plain" );
2459+ ap_set_content_type (r , PLAINTEXT_CONTENT_TYPE );
24572460 ap_rprintf (r , "Type=PING-RSP&JVMRoute=%.*s" , (int )sizeof (nodeinfo .mess .JVMRoute ), nodeinfo .mess .JVMRoute );
24582461
24592462 ap_rprintf (r , isnode_up (r , node -> mess .id , -2 ) != OK ? "&State=NOTOK" : "&State=OK" );
0 commit comments