chrisemunt / mg_web

A High speed web server extension for InterSystems Cache/IRIS, YottaDB and JavaScript.
Apache License 2.0
7 stars 2 forks source link

Apache AH02429 - 500 Internal Server error #2

Open theflyingape opened 1 year ago

theflyingape commented 1 year ago

This module compiles & runs well, except for when specific frames are rendered. This does not fail using Cache 2018.1 with Weblink.

Apache throws this in its error log, and the browser receives the canned 500 Internal Server error page:

[Wed Apr 12 08:07:43.336363 2023] [http:error] [pid 4159346:tid 140020332807936] [client 10.15.13.43:64594] 
AH02429: Response header name '          a.nol {text-Decoration' contains invalid characters, aborting request, 
referer: https://watson.bidmc.org/mgweb/?MGWLPN=WATSON&_WEBTAG=Frameset&_WEBT=77281^-1

... and with mgweb.conf log_level setup, an example from the mgweb.log trace information follows:

>>> Time: Wed Apr 12 08:07:43 2023; Build: 2.4.28 pid=4159347;tid=140020332807936;script_name=/mgweb/;
    mg_web: Request to DB Server: (1478 Bytes)
    \xc6\x05\x00\x00\x1f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0e\x00\x00\x00\x15dbxweb^%zmgsis\x00\x00\x00\x00\x15\x90\x05\x00\x00\x15\x12\x00\x00\x00eREQUEST_METHOD=GET\x13\x00\x00\x00eSCRIPT_NAME=/mgweb/B\x00\x00\x00eQUERY_STRING=TopAPP=WLW&MGWLPN=WATSON&_WEBT=77281^-1&_WEBTAG=_main\x18\x00\x00\x00eSERVER_PROTOCOL=HTTP/1.1\x1a\x00\x00\x00eHTTP_HOST=watson.bidmc.org\x1a\x00\x00\x00eHTTP_CONNECTION=keep-aliveP\x00\x00\x00eHTTP_SEC_CH_UA="Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"\x18\x00\x00\x00eHTTP_SEC_CH_UA_MOBILE=?0!\x00\x00\x00eHTTP_SEC_CH_UA_PLATFORM="Windows" \x00\x00\x00eHTTP_UPGRADE_INSECURE_REQUESTS=1\x7f\x00\x00\x00eHTTP_USER_AGENT=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36\x93\x00\x00\x00eHTTP_ACCEPT=text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7\x1f\x00\x00\x00eHTTP_SEC_FETCH_SITE=same-origin\x1c\x00\x00\x00eHTTP_SEC_FETCH_MODE=navigate\x19\x00\x00\x00eHTTP_SEC_FETCH_DEST=frameZ\x00\x00\x00eHTTP_REFERER=https://watson.bidmc.org/mgweb/?MGWLPN=WATSON&_WEBTAG=Frameset&_WEBT=77281^-1&\x00\x00\x00eHTTP_ACCEPT_ENCODING=gzip, deflate, br#\x00\x00\x00eHTTP_ACCEPT_LANGUAGE=en-US,en;q=0.9\x89\x00\x00\x00eHTTP_COOKIE=CSPBrowserId=3$apE$Ug4OPNhocFTTzvgA--; CSPWSERVERID=hA09o1Ar; _ga=GA1.2.534211089.1681295860; _gid=GA1.2.144037208.1681295860 \x00\x00\x00eHTTP_X_FORWARDED_FOR=10.15.13.43'\x00\x00\x00eHTTP_X_ORIGINAL_REMOTE_ADDR=10.15.13.43U\x00\x00\x00eSERVER_SOFTWARE=Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mg_web/2.4.28'\x00\x00\x00\xa1server=local\x0067890123456789012345678901\x0c\x00\x00\x00\xa1server_no=00\x0c\x00\x00\x00\xa1path=/mgweb/\x14\x00\x00\x00\xa1function=web^%zmgweb\x07\x00\x00\x00\xa1no=\x02\x00\x00\x00\x0e\x00\x00\x00\xa1key=\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\xa1mode=tcp\x00\x00\x00\x00\xb6\x00\x00\x00\x00\x15\x00\x00\x00\x00\xb6
>>> Time: Wed Apr 12 08:07:43 2023; Build: 2.4.28 pid=4159347;tid=140020341200640;script_name=/mgweb/;
    mg_web: Read response
    Chunked Response from DB Server: 0x00001597 (5527 Bytes; sort=0; type=0)
>>> Time: Wed Apr 12 08:07:43 2023; Build: 2.4.28 pid=4159346;tid=140020332807936;script_name=/mgweb/;
    mg_web: Read response
    Chunked Response from DB Server: 0x000028c2 (10434 Bytes; sort=0; type=0)
>>> Time: Wed Apr 12 08:07:43 2023; Build: 2.4.28 pid=4159347;tid=140020341200640;script_name=/mgweb/;
    mg_web: Chunked Response from DB Server: 0x00001597 (5527 Bytes; sort=0; type=0)
    <html><head><title>BIDMC ED Portal</title><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"><META HTTP-E
QUIV="Pragma" Content="no-cache"><META HTTP-EQUIV="Cache-Control" Content="Private"><style>\x0d\x0a          A.nol {text-decoration: none} \x0d\x0a          .cweb {color: black; text-decoration: none; font-family: verdana; font-size: 12}\x0d\x0a          A.cond {color: blue; text-decoration: none; font-family: verdana; font-size: 7pt}\x0d\x0a          A.cweb {color: blue; text-decoration: none; font-family: verdana; font-size: 7pt}\x0d\x0a          A.whtb {color: white; text-decoration: none; font-family: verdana; 
font-size: 14} \x0d\x0a          A.whts {color: white; text-decoration: none; font-family: verdana; font-size: 10} \x0d\x0a       
   A.glk {color: green; text-decoration: none; font-family: verdana; font-size: 10} \x0d\x0a          A.rxm {color: black; text-decoration: none; font-family: verdana; font-size: 12} \x0d\x0a          A.rxc {color: black; text-decoration: none; font-family: arial; font-size: 9} \x0d\x0a          A.menucl {color: white; text-decoration: none; font-family: tahoma; font-size: 8pt} \x0d\x0a 
         A.bs1  {color: green; text-decoration: none; font-family: arial; font-size: 14} \x0d\x0a          A.bs2  {color: #EECC11; text-decoration: none; font-family: arial; font-size: 14} \x0d\x0a          A.bs3  {color: #FF0066; text-decoration: none; font-family: arial; font-size: 14} \x0d\x0a          A.bs4  {color: black; text-decoration: none; font-family: arial; font-size: 14} \x0d\x0a          A.bs5  {color: purple; text-decoration: none; font-family: arial; font-size: 14} \x0d\x0a          A.bs6  {color: p
urple; text-decoration: none; font-family: arial; font-size: 14} \x0d\x0a          A.bs7  {color: #CC3300; text-decoration: none; 
font-family: arial; font-size: 14} \x0d\x0a          A.gry {color: #777777; text-decoration: none; font-family: verdana; font-size: 7pt}\x0d\x0a          A:hover{color: #FF0000; }\x0d\x0a          A.bs3:hover {color: black;}\x0d\x0a          .userpic { positio
n:absolute; border: solid 3px #000000; padding: 1px; } \x0d\x0a          .butclass {position:relative; left:0; top:0; }\x0d\x0a   
       </style>\x0d\x0a</head>\x0d\x0a<body onload='rset(); upd(); self.focus();' bgcolor=#8888FF topmargin=0 marginheight=0 link=blue vlink=blue alink=red>\x0d\x0a<script language="Javascript">\x0d\x0afunction timeout() {\x0d\x0a   top.EWDASH=top.EWDASH || {}
; top.EWDASH.ClosingByTimeout=1; \x0d\x0a   if ((parent.remote != null) && ! parent.remote.closed) {parent.remote.close();parent.remote=null}\x0d\x0a   if (document.form.lock.value==1) {  \x0d\x0a       parent.frames[2].document.form.submit();    \x0d\x0a     
  setTimeout('timeout2()',3000)  \x0d\x0a   } else if (hasTrySaveAndNav()) {  \x0d\x0a       setTimeout('timeout2()',3000);  \x0d\
x0a       window.top.frames['main'].trySaveAndNav(timeout2);    \x0d\x0a   } else { \x0d\x0a       timeout2();  \x0d\x0a   } \x0d\
x0a}\x0d\x0a\x0d\x0afunction timeout2() { \x0d\x0a   document.form.lock.value=3; \x0d\x0a   parent.location.replace("?MGWLPN=WATSO
N&RUN=lan&app=poison&webt=77281");\x0d\x0a}\x0d\x0a\x0d\x0avar butvert=0\x0d\x0afunction movebut() { \x0d\x0a}\x0d\x0a\x0d\x0afunc
tion rset() {\x0d\x0a  sdobj = new Date(); \x0d\x0a  rfreq = 1000; toggle=0; \x0d\x0a  strt=sdobj.getTime();\x0d\x0a  if (document
.anchors[0]) {document.anchors[0].style.color='white'} ;\x0d\x0a}\x0d\x0a\x0d\x0afunction upd() { \x0d\x0a if (document.form.lock.
value==4) {  \x0d\x0a    parent.close();    \x0d\x0a   if ((parent.remote != null) && ! parent.remote.closed) {parent.remote.close
();parent.remote=null}\x0d\x0a } else if (document.form.lock.value==3) {  \x0d\x0a    document.form.lock.value=4;     \x0d\x0a    
window.setTimeout('upd()',4000);   \x0d\x0a } else {   \x0d\x0a    var ndobj = new Date();\x0d\x0a    var ntm = ndobj.getTime();\x0d\x0a    var rem = Math.floor(3600-((ntm-strt)/1000));\x0d\x0a    if ( (rem % 20 ) == 0 ) { \x0d\x0a       ajaxSend("?MGWLPN=WATS
ON&_WEBT=77281^-1&_WEBTAG=chkForerun&tmout=3600&rem="+rem+"&nocache="+ntm);\x0d\x0a    } else {\x0d\x0a       if ( (rem < 30) && (
(rem % 2) == 0) )  {\x0d\x0a          ajaxSend("?MGWLPN=WATSON&_WEBT=77281^-1&_WEBTAG=chkForerun&tmout=3600&rem="+rem+"&nocache="+
ntm);\x0d\x0a       }\x0d\x0a    }\x0d\x0a    if (rem > 60) { \x0d\x0a       document.form.tmr.value=Math.round(rem/60)+' min';\x0
d\x0a    } else {\x0d\x0a       document.form.tmr.value=rem+' sec';\x0d\x0a    }\x0d\x0a    if (rem < 1 ) {  rfreq=10000; timeout(
) }\x0d\x0a    else if (rem < -10 ) { rfreq=10; document.form.lock.value=4 }\x0d\x0a    else if ((rem<60)&&(rem>30)) { document.an
chors[0].style.color='red'; } \x0d\x0a    else if (rem<30) { document.anchors[0].style.font.size=16; rfreq=(rem/30)*500; if (toggl
e) { document.anchors[0].style.color='white'; toggle=0;} else { document.anchors[0].style.color='red'; toggle=1;} }\x0d\x0a    win
dow.setTimeout('upd()',rfreq);\x0d\x0a  } \x0d\x0a}\x0d\x0a\x0d\x0afunction fset(crem) {\x0d\x0a    var ndobj = new Date();\x0d\x0
a    var ntm = ndobj.getTime();\x0d\x0a    strt=ntm-crem;\x0d\x0a}\x0d\x0a\x0d\x0afunction ajaxSend(url){ \x0d\x0afunction ajaxBin
dCallback(){\x0d\x0a  if (ajaxRequest.readyState == 4) {\x0d\x0a   if (ajaxRequest.status == 200) {\x0d\x0a    try { eval(ajaxRequ
est.responseText.substring(ajaxRequest.responseText.indexOf('<AjAx>')+6,ajaxRequest.responseText.lastIndexOf('</AjAx>'))); }\x0d\x
0a    catch(e) {  alert('There was an error evaluating the ajax response text:\n' + ajaxRequest.responseText); }\x0d\x0a  }\x0d\x0
a }\x0d\x0a}\x0d\x0a\x0d\x0avar ajaxRequest = null;\x0d\x0a\x0d\x0aif (window.XMLHttpRequest) {\x0d\x0a  ajaxRequest = new XMLHttp
Request();\x0d\x0a  ajaxRequest.onreadystatechange = ajaxBindCallback;\x0d\x0a  ajaxRequest.open("GET", url, true);\x0d\x0a  ajaxR
equest.send(null);\x0d\x0a} else if (window.ActiveXObject) {\x0d\x0a  ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");\x0d\x0
a  if (ajaxRequest) {\x0d\x0a    ajaxRequest.onreadystatechange = ajaxBindCallback;\x0d\x0a    ajaxRequest.open("GET", url, true);
\x0d\x0a    ajaxRequest.send();\x0d\x0a  }\x0d\x0a}\x0d\x0a}\x0d\x0a\x0d\x0a\x0d\x0afunction $(id) { return document.getElementByI
d(id); }\x0d\x0a\x0d\x0a</script>\x0d\x0a
>>> Time: Wed Apr 12 08:07:43 2023; Build: 2.4.28 pid=4159347;tid=140020332807936;script_name=/mgweb/;
    mg_web: Read response
    Chunked Response from DB Server: 0x00000057 (87 Bytes; sort=0; type=0)
theflyingape commented 1 year ago

FWIIW, I patched mg_web.c to detect if it's missing "HTTP/" first to default send your DEFAULT response. If one is present, then process it normally finding the first empty line as the beginning of content.

      if (strncmp(pweb->response_headers, "HTTP/", 5))
              p = NULL;
      else
              p = (unsigned char *) strstr(pweb->response_headers, "\x0d\x0a\x0d\x0a");