Author: markt
Date: Mon Aug 15 20:42:09 2016
New Revision: 1756430
URL: http://svn.apache.org/viewvc?rev=1756430&view=rev
Log:
Switch the CGI servlet to the standard logging mechanism and remove support for
the debug attribute.
Align 6.0.x with 7.0.x
Modified:
tomcat/tc6.0.x/trunk/ (props changed)
tomcat/tc6.0.x/trunk/conf/web.xml
tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CGIServlet.java
tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/LocalStrings.properties
tomcat/tc6.0.x/trunk/webapps/docs/cgi-howto.xml
tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
Propchange: tomcat/tc6.0.x/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug 15 20:42:09 2016
@@ -1,4 +1,4 @@
-/tomcat/tc7.0.x/trunk:1190476,1224802,1243045,1298635,1304471,1311997,1312007,1331772,1333164,1333176,1348992,1354866,1371298,1371302,1371620,1402110,1409014,1413553,1413557,1413563,1430083,1438415,1446641-1446660,1447013,1453106,1453119,1484919,1486877,1500065,1503852,1505844,1513151,1521040,1526470,1536524,1539176-1539177,1544469,1544473,1552805,1558894,1558917,1561368,1561382,1561386,1561552,1561561,1561636,1561641,1561643,1561737,1562748,1564317,1568922,1570163,1577328,1577464-1577465,1578814,1586659,1586897,1586960,1588199,1588997,1589740,1589851,1589997,1590019,1590028,1590337,1590492,1590651,1590838,1590845,1590848,1590912,1593262,1593288,1593371,1593835,1594230,1595174,1595366,1600956,1601333,1601856,1601909,1609079,1609606,1617364,1617374,1617433,1617457-1617458,1624249,1626579,1627420,1627469,1632586,1637686,1637711,1640675,1642045,1643515,1643540,1643572,1643585-1643586,1643642,1643647,1644019,1648817,1656301,1658815,1659523,1659564,1664001,1664176,1665087,1666968,1666989
,1668541,1668635,1669802,1676557,1681183,1681841,1681865,1681867,1685829,1693109,1694293,1694433,1694875,1696381,1701945,1710353,1712656,1713873,1714000,1714005,1714540,1715213,1716221,1716417,1717107,1717210,1717212,1720236,1720398,1720443,1720464,1721814,1721883,1722645,1722801,1723151,1724435,1724553,1724675,1724797,1724806,1725931,1726631,1726808,1726813,1726815,1726817,1726819,1726917,1726919,1726922-1726924,1727031,1727034,1727043,1727158,1727672,1727903,1728450,1729363,1731010,1731119,1731956,1731978,1732362,1732674-1732675,1733942,1734116,1734134,1734532,1737249,1737253,1737968,1738049,1738186,1739778,1741178,1741184,1741193,1741211,1741218,1741228,1741235,1742281,1743121,1743142,1743649,1744061,1744129,1744155,1744241,1744383,1744689,1745230,1746942,1746994,1749377,1750018,1750980,1751066,1754114,1754147,1754728,1754880,1754891,1754898,1754902,1756030
+/tomcat/tc7.0.x/trunk:1190476,1224802,1243045,1298635,1304471,1311997,1312007,1331772,1333164,1333176,1348992,1354866,1371298,1371302,1371620,1402110,1409014,1413553,1413557,1413563,1430083,1438415,1446641-1446660,1447013,1453106,1453119,1484919,1486877,1500065,1503852,1505844,1513151,1521040,1526470,1536524,1539176-1539177,1544469,1544473,1552805,1558894,1558917,1561368,1561382,1561386,1561552,1561561,1561636,1561641,1561643,1561737,1562748,1564317,1568922,1570163,1577328,1577464-1577465,1578814,1586659,1586897,1586960,1588199,1588997,1589740,1589851,1589997,1590019,1590028,1590337,1590492,1590651,1590838,1590845,1590848,1590912,1593262,1593288,1593371,1593835,1594230,1595174,1595366,1600956,1601333,1601856,1601909,1609079,1609606,1617364,1617374,1617433,1617457-1617458,1624249,1626579,1627420,1627469,1632586,1637686,1637711,1640675,1642045,1643515,1643540,1643572,1643585-1643586,1643642,1643647,1644019,1648817,1656301,1658815,1659523,1659564,1664001,1664176,1665087,1666968,1666989
,1668541,1668635,1669802,1676557,1681183,1681841,1681865,1681867,1685829,1693109,1694293,1694433,1694875,1696381,1701945,1710353,1712656,1713873,1714000,1714005,1714540,1715213,1716221,1716417,1717107,1717210,1717212,1720236,1720398,1720443,1720464,1721814,1721883,1722645,1722801,1723151,1724435,1724553,1724675,1724797,1724806,1725931,1726631,1726808,1726813,1726815,1726817,1726819,1726917,1726919,1726922-1726924,1727031,1727034,1727043,1727158,1727672,1727903,1728450,1729363,1731010,1731119,1731956,1731978,1732362,1732674-1732675,1733942,1734116,1734134,1734532,1737249,1737253,1737968,1738049,1738186,1739778,1741178,1741184,1741193,1741211,1741218,1741228,1741235,1742281,1743121,1743142,1743649,1744061,1744129,1744155,1744241,1744383,1744689,1745230,1746942,1746994,1749377,1750018,1750980,1751066,1754114,1754147,1754728,1754880,1754891,1754898,1754902,1756030,1756417,1756420,1756423
/tomcat/tc8.0.x/trunk:1637685,1637709,1640674,1641726,1641729-1641730,1643513,1643539,1643571,1643581-1643582,1644018,1648816,1656300,1658801-1658803,1658811,1659522,1663997,1664175,1665086,1666967,1666988,1668634,1669801,1676556,1681182,1681840,1681864,1685827,1689921,1693108,1694291,1694427,1694873,1696379,1701944,1710347,1712618,1712655,1713872,1713998,1714004,1714538,1715207,1715866,1716216-1716217,1716414,1717208-1717209,1720235,1720396,1720442,1720463,1721813,1721882,1722800,1723130,1724434,1724674,1724792,1724803,1725929,1725963-1725965,1725970,1725974,1726172,1726175,1726179-1726182,1726195-1726198,1726200,1726203,1726226,1726576,1726630,1727029,1727037,1727671,1727900,1728449,1729362,1731009,1731955,1731977,1732360,1732672,1733941,1734115,1734133,1734531,1737967,1738173,1739777,1741217,1743647,1744152,1756018
-/tomcat/tc8.5.x/trunk:1737199,1737966,1738044,1741174,1741182,1741191,1741209,1741226,1741233,1742277,1743118,1743139-1743140,1744059,1744127,1744151,1744232,1744377,1744687,1745228,1746940,1749375,1750016,1750976,1751062,1754112,1754144,1754726,1754806,1754878,1754889,1754894,1754900
-/tomcat/trunk:601180,606992,612607,630314,640888,652744,653247,656018,666232,673796,673820,677910,683969,683982,684001,684081,684234,684269-684270,685177,687503,687645,689402,690781,691392,691805,692748,693378,694992,695053,695311,696780,696782,698012,698227,698236,698613,699427,699634,701355,709294,709811,709816,710063,710066,710125,710205,711126,711600,712461,712467,713953,714002,718360,719119,719124,719602,719626,719628,720046,720069,721040,721286,721708,721886,723404,723738,726052,727303,728032,728768,728947,729057,729567,729569,729571,729681,729809,729815,729934,730250,730590,731651,732859,732863,734734,740675,740684,742677,742697,742714,744160,744238,746321,746384,746425,747834,747863,748344,750258,750291,750921,751286-751287,751289,751295,752323,753039,757335,757774,758249,758365,758596,758616,758664,759074,761601,762868,762929,762936-762937,763166,763183,763193,763228,763262,763298,763302,763325,763599,763611,763654,763681,763706,764985,764997,765662,768335,769979,770716,770
809,770876,772872,776921,776924,776935,776945,777464,777466,777576,777625,778379,778523-778524,781528,781779,782145,782791,783316,783696,783724,783756,783762,783766,783863,783934,784453,784602,784614,785381,785688,785768,785859,786468,786487,786490,786496,786667,787627,787770,787985,789389,790405,791041,791184,791194,791224,791243,791326,791328,791789,792740,793372,793757,793882,793981,794082,794673,794822,795043,795152,795210,795457,795466,797168,797425,797596,797607,802727,802940,804462,804544,804734,805153,809131,809603,810916,810977,812125,812137,812432,813001,813013,813866,814180,814708,814876,815972,816252,817442,817822,819339,819361,820110,820132,820874,820954,821397,828196,828201,828210,828225,828759,830378-830379,830999,831106,831774,831785,831828,831850,831860,832214,832218,833121,833545,834047,835036,835336,836405,881396,881412,883130,883134,883146,883165,883177,883362,883565,884341,885038,885231,885241,885260,885901,885991,886019,888072,889363,889606,889716,890139,890265
,890349-890350,890417,891185-891187,891583,892198,892341,892415,892464,892555,892812,892814,892817,892843,892887,893321,893493,894580,894586,894805,894831,895013,895045,895057,895191,895392,895703,896370,896384,897380-897381,897776,898126,898256,898468,898527,898555,898558,898718,898836,898906,899284,899348,899420,899653,899769-899770,899783,899788,899792,899916,899918-899919,899935,899949,903916,905020,905151,905722,905728,905735,907311,907513,907538,907652,907727,907819,907825,907864,908002,908721,908754,908759,909097,909206,909212,909525,909636,909869,909875,909887,910266,910370,910442,910471,910485,910974,915226,915737,915861,916097,916141,916157,916170,917598,917633,918093,918489,918594,918684,918787,918792,918799,918803,918885,919851,919914,920025,920055,920298,920449,920596,920824,920840,921444,922010,926716,927062,927621,928482,928695,928732,928798,931709,932357,932967,935105,935983,939491,939551,940064,941356,941463,943112,944409,944416,945231,945808,945835,945841,946686,94
8057,950164,950596,950614,950851,950905,951615,953434,954435,955648,955655,956832,957130,957830,958192,960701,961948,962865,962872,962881,962900,963106,963865,963868,964614,966177-966178,966292,966692,966863,981815,988448,991837,993042,1001955,1002185,1002263,1002274,1002349,1002359,1002362,1002481,1002514,1003461,1003481,1003488,1003556,1003572,1003581,1003861,1004393,1004409,1004415,1004868-1004869,1004912,1005452,1005467,1005647,1005802,1022120,1022134,1022323,1022415,1022606,1022623,1024224,1024251,1026042,1026784,1026912,1026920,1029767,1033415,1033448,1033842,1033897,1037715,1037794,1037887,1037924,1038041,1041892,1042022,1042029,1042447,1042452,1042494,1043983,1044944,1044987,1049264,1050249,1055055,1055236,1055458,1055975,1056264,1056828,1056889,1059881,1060486,1061412,1061442,1061446,1061503,1062398,1064652,1066244,1066772,1067039,1067139,1069824,1070139,1070420,1070609,1072042,1073184,1073393,1075458,1076212,1078409,1078412,1079801,1081118,1081334,1088179,1088460,1090022,1
094069,1094089,1095138,1097899,1099575,1099586,1099772,1099789,1100145,1100822,1101094,1101144,1124680,1130774,1133014,1137862,1137996,1138950,1138953,1139280,1140693,1141104,1141441,1142043,1142904,1143134,1143150,1145137,1148216,1148471,1152601,1156171,1156519,1164567,1167394,1172233-1172234,1172236,1173614,1174353,1174882,1174884,1175158,1175190,1176799,1177125,1177245,1177850,1177862,1178228,1178233,1178684,1181028,1181136,1184917,1184919,1185200,1185588,1186011,1186104,1186123,1186137,1186153,1186378,1186712,1186763,1186949,1187381,1189240,1189386,1190388-1190389,1190474,1198622,1201576,1203091,1224801,1233426,1243034,1243038,1244567,1298140,1298628-1298629,1304468,1311997,1331766,1333161,1333173,1342498,1342503,1348425,1348461-1348495,1348989,1350294,1351056,1351636-1351640,1352011,1354685,1354847,1354856,1356125,1359981,1371283,1409007,1413552,1413556,1413562,1417282,1430079,1430481,1430567,1435606,1435636,1435642,1438411,1439054,1441348,1446640,1446650,1447012,1453105,145311
2,1456666-1456678,1456713,1456721,1457968,1460342,1460533,1484862,1486875,1492570,1494143,1500062,1503851,1505843,1513148-1513149,1526469,1533312,1536520,1539157,1539173,1540374,1552804,1555163,1558811,1561054-1561065,1561067-1561070,1561072-1561075,1561083,1561190-1561192,1561635,1561640,1561732,1562742,1562746,1564309,1564312,1568921,1574004,1577315,1577324,1577463,1578812-1578813,1586658,1586894,1586959,1588193,1588197,1589737-1589738,1589763,1589837,1589842,1589980,1590018,1590302,1590646,1590648,1590835,1590842,1590911,1593259,1593261,1593335,1593834,1594229,1595171,1595289,1597532,1600955,1600963,1600978,1600984,1601329-1601330,1601332,1601855,1608963,1609061,1609593,1617362,1617365,1617383,1617456,1623392,1624247,1626579,1627033,1628978,1631155,1631520,1632584,1634117,1634130,1637684,1637695,1640655-1640658,1641656,1641660,1641692,1641707-1641718,1641721-1641722,1642564,1642606,1643045,1643054,1643570,1644017,1648815,1656299,1658799,1658802,1659521,1663995,1664174,1665085,166
6966,1666985,1668630,1669800,1676552,1681837-1681838,1681854,1685826,1687242,1689918,1693105,1694290,1694872,1696378,1701940,1710346,1712617,1712654,1713871,1713997,1714002,1715188,1715206,1716213-1716214,1716413,1716640,1716856,1716858,1716881-1716882,1716886,1716894,1720234,1720394,1720439,1720462,1721812,1721881,1722532,1722799,1722807,1722824,1722828-1722829,1722831,1722859,1723127,1723707,1723736,1724427,1724433,1724673,1724788,1724863,1725113,1725183,1725199,1725202,1725204,1725207,1725263-1725264,1725266,1725278,1725282,1725405,1725646,1725649-1725652,1725696-1725697,1725914,1725926,1726177,1726202,1726628,1726676,1726926,1727162,1727670,1727899,1728448,1729361,1731008,1731953,1731976,1732359,1733940,1734113,1734128,1734192,1737119,1737715,1737834,1737959,1738039,1738043,1739775,1741173,1741181,1741190,1741208,1741213,1741225,1741232,1742090,1742276,1743115,1743117,1743554,1744058,1744125,1744229,1744323,1744684,1745227,1745337,1746939,1748629,1750015,1750975,1751061,1754111,
1754140-1754141,1754445,1754494,1754496,1754528,1754532-1754533,1754714,1756013
+/tomcat/tc8.5.x/trunk:1737199,1737966,1738044,1741174,1741182,1741191,1741209,1741226,1741233,1742277,1743118,1743139-1743140,1744059,1744127,1744151,1744232,1744377,1744687,1745228,1746940,1749375,1750016,1750976,1751062,1754112,1754144,1754726,1754806,1754878,1754889,1754894,1754900,1756412
+/tomcat/trunk:601180,606992,612607,630314,640888,652744,653247,656018,666232,673796,673820,677910,683969,683982,684001,684081,684234,684269-684270,685177,687503,687645,689402,690781,691392,691805,692748,693378,694992,695053,695311,696780,696782,698012,698227,698236,698613,699427,699634,701355,709294,709811,709816,710063,710066,710125,710205,711126,711600,712461,712467,713953,714002,718360,719119,719124,719602,719626,719628,720046,720069,721040,721286,721708,721886,723404,723738,726052,727303,728032,728768,728947,729057,729567,729569,729571,729681,729809,729815,729934,730250,730590,731651,732859,732863,734734,740675,740684,742677,742697,742714,744160,744238,746321,746384,746425,747834,747863,748344,750258,750291,750921,751286-751287,751289,751295,752323,753039,757335,757774,758249,758365,758596,758616,758664,759074,761601,762868,762929,762936-762937,763166,763183,763193,763228,763262,763298,763302,763325,763599,763611,763654,763681,763706,764985,764997,765662,768335,769979,770716,770
809,770876,772872,776921,776924,776935,776945,777464,777466,777576,777625,778379,778523-778524,781528,781779,782145,782791,783316,783696,783724,783756,783762,783766,783863,783934,784453,784602,784614,785381,785688,785768,785859,786468,786487,786490,786496,786667,787627,787770,787985,789389,790405,791041,791184,791194,791224,791243,791326,791328,791789,792740,793372,793757,793882,793981,794082,794673,794822,795043,795152,795210,795457,795466,797168,797425,797596,797607,802727,802940,804462,804544,804734,805153,809131,809603,810916,810977,812125,812137,812432,813001,813013,813866,814180,814708,814876,815972,816252,817442,817822,819339,819361,820110,820132,820874,820954,821397,828196,828201,828210,828225,828759,830378-830379,830999,831106,831774,831785,831828,831850,831860,832214,832218,833121,833545,834047,835036,835336,836405,881396,881412,883130,883134,883146,883165,883177,883362,883565,884341,885038,885231,885241,885260,885901,885991,886019,888072,889363,889606,889716,890139,890265
,890349-890350,890417,891185-891187,891583,892198,892341,892415,892464,892555,892812,892814,892817,892843,892887,893321,893493,894580,894586,894805,894831,895013,895045,895057,895191,895392,895703,896370,896384,897380-897381,897776,898126,898256,898468,898527,898555,898558,898718,898836,898906,899284,899348,899420,899653,899769-899770,899783,899788,899792,899916,899918-899919,899935,899949,903916,905020,905151,905722,905728,905735,907311,907513,907538,907652,907727,907819,907825,907864,908002,908721,908754,908759,909097,909206,909212,909525,909636,909869,909875,909887,910266,910370,910442,910471,910485,910974,915226,915737,915861,916097,916141,916157,916170,917598,917633,918093,918489,918594,918684,918787,918792,918799,918803,918885,919851,919914,920025,920055,920298,920449,920596,920824,920840,921444,922010,926716,927062,927621,928482,928695,928732,928798,931709,932357,932967,935105,935983,939491,939551,940064,941356,941463,943112,944409,944416,945231,945808,945835,945841,946686,94
8057,950164,950596,950614,950851,950905,951615,953434,954435,955648,955655,956832,957130,957830,958192,960701,961948,962865,962872,962881,962900,963106,963865,963868,964614,966177-966178,966292,966692,966863,981815,988448,991837,993042,1001955,1002185,1002263,1002274,1002349,1002359,1002362,1002481,1002514,1003461,1003481,1003488,1003556,1003572,1003581,1003861,1004393,1004409,1004415,1004868-1004869,1004912,1005452,1005467,1005647,1005802,1022120,1022134,1022323,1022415,1022606,1022623,1024224,1024251,1026042,1026784,1026912,1026920,1029767,1033415,1033448,1033842,1033897,1037715,1037794,1037887,1037924,1038041,1041892,1042022,1042029,1042447,1042452,1042494,1043983,1044944,1044987,1049264,1050249,1055055,1055236,1055458,1055975,1056264,1056828,1056889,1059881,1060486,1061412,1061442,1061446,1061503,1062398,1064652,1066244,1066772,1067039,1067139,1069824,1070139,1070420,1070609,1072042,1073184,1073393,1075458,1076212,1078409,1078412,1079801,1081118,1081334,1088179,1088460,1090022,1
094069,1094089,1095138,1097899,1099575,1099586,1099772,1099789,1100145,1100822,1101094,1101144,1124680,1130774,1133014,1137862,1137996,1138950,1138953,1139280,1140693,1141104,1141441,1142043,1142904,1143134,1143150,1145137,1148216,1148471,1152601,1156171,1156519,1164567,1167394,1172233-1172234,1172236,1173614,1174353,1174882,1174884,1175158,1175190,1176799,1177125,1177245,1177850,1177862,1178228,1178233,1178684,1181028,1181136,1184917,1184919,1185200,1185588,1186011,1186104,1186123,1186137,1186153,1186378,1186712,1186763,1186949,1187381,1189240,1189386,1190388-1190389,1190474,1198622,1201576,1203091,1224801,1233426,1243034,1243038,1244567,1298140,1298628-1298629,1304468,1311997,1331766,1333161,1333173,1342498,1342503,1348425,1348461-1348495,1348989,1350294,1351056,1351636-1351640,1352011,1354685,1354847,1354856,1356125,1359981,1371283,1409007,1413552,1413556,1413562,1417282,1430079,1430481,1430567,1435606,1435636,1435642,1438411,1439054,1441348,1446640,1446650,1447012,1453105,145311
2,1456666-1456678,1456713,1456721,1457968,1460342,1460533,1484862,1486875,1492570,1494143,1500062,1503851,1505843,1513148-1513149,1526469,1533312,1536520,1539157,1539173,1540374,1552804,1555163,1558811,1561054-1561065,1561067-1561070,1561072-1561075,1561083,1561190-1561192,1561635,1561640,1561732,1562742,1562746,1564309,1564312,1568921,1574004,1577315,1577324,1577463,1578812-1578813,1586658,1586894,1586959,1588193,1588197,1589737-1589738,1589763,1589837,1589842,1589980,1590018,1590302,1590646,1590648,1590835,1590842,1590911,1593259,1593261,1593335,1593834,1594229,1595171,1595289,1597532,1600955,1600963,1600978,1600984,1601329-1601330,1601332,1601855,1608963,1609061,1609593,1617362,1617365,1617383,1617456,1623392,1624247,1626579,1627033,1628978,1631155,1631520,1632584,1634117,1634130,1637684,1637695,1640655-1640658,1641656,1641660,1641692,1641707-1641718,1641721-1641722,1642564,1642606,1643045,1643054,1643570,1644017,1648815,1656299,1658799,1658802,1659521,1663995,1664174,1665085,166
6966,1666985,1668630,1669800,1676552,1681837-1681838,1681854,1685826,1687242,1689918,1693105,1694290,1694872,1696378,1701940,1710346,1712617,1712654,1713871,1713997,1714002,1715188,1715206,1716213-1716214,1716413,1716640,1716856,1716858,1716881-1716882,1716886,1716894,1720234,1720394,1720439,1720462,1721812,1721881,1722532,1722799,1722807,1722824,1722828-1722829,1722831,1722859,1723127,1723707,1723736,1724427,1724433,1724673,1724788,1724863,1725113,1725183,1725199,1725202,1725204,1725207,1725263-1725264,1725266,1725278,1725282,1725405,1725646,1725649-1725652,1725696-1725697,1725914,1725926,1726177,1726202,1726628,1726676,1726926,1727162,1727670,1727899,1728448,1729361,1731008,1731953,1731976,1732359,1733940,1734113,1734128,1734192,1737119,1737715,1737834,1737959,1738039,1738043,1739775,1741173,1741181,1741190,1741208,1741213,1741225,1741232,1742090,1742276,1743115,1743117,1743554,1744058,1744125,1744229,1744323,1744684,1745227,1745337,1746939,1748629,1750015,1750975,1751061,1754111,
1754140-1754141,1754445,1754494,1754496,1754528,1754532-1754533,1754714,1756013,1756408,1756410
Modified: tomcat/tc6.0.x/trunk/conf/web.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/conf/web.xml?rev=1756430&r1=1756429&r2=1756430&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/conf/web.xml (original)
+++ tomcat/tc6.0.x/trunk/conf/web.xml Mon Aug 15 20:42:09 2016
@@ -339,23 +339,6 @@
<!-- If not set, then webAppRootDir is used. -->
<!-- Recommended value: WEB-INF/cgi -->
<!-- -->
- <!-- debug Debugging detail level for messages logged -->
- <!-- by this servlet. Useful values range from 0 -->
- <!-- to 5 where 0 means no logging and 5 means -->
- <!-- maximum logging. Values of 10 or more mean -->
- <!-- maximum logging plus debug info added to the -->
- <!-- HTTP response. If an error occurs and debug -->
- <!-- is 10 or more the standard error page -->
- <!-- mechanism will be disabled and a response -->
- <!-- body with debug information will be produced. -->
- <!-- Note that any value of 10 or more has the -->
- <!-- same effect as a value of 10. If set to 10 or -->
- <!-- more the standard error page mechanism will -->
- <!-- be disabled and a debug page shown instead. -->
- <!-- The debug page is not considered secure and -->
- <!-- should not be enabled for production systems. -->
- <!-- [0] -->
- <!-- -->
<!-- executable Name of the executable used to run the -->
<!-- script. [perl] -->
<!-- -->
@@ -375,10 +358,6 @@
<servlet-name>cgi</servlet-name>
<servlet-class>org.apache.catalina.servlets.CGIServlet</servlet-class>
<init-param>
- <param-name>debug</param-name>
- <param-value>0</param-value>
- </init-param>
- <init-param>
<param-name>cgiPathPrefix</param-name>
<param-value>WEB-INF/cgi</param-value>
</init-param>
Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CGIServlet.java
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CGIServlet.java?rev=1756430&r1=1756429&r2=1756430&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CGIServlet.java
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/servlets/CGIServlet.java Mon
Aug 15 20:42:09 2016
@@ -14,8 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
package org.apache.catalina.servlets;
import java.io.BufferedOutputStream;
@@ -34,9 +32,11 @@ import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
import java.util.Locale;
+import java.util.Map.Entry;
import java.util.StringTokenizer;
import java.util.Vector;
+import javax.servlet.RequestDispatcher;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@@ -50,6 +50,9 @@ import javax.servlet.http.HttpSession;
import org.apache.catalina.Globals;
import org.apache.catalina.util.IOTools;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.res.StringManager;
/**
@@ -118,7 +121,7 @@ import org.apache.catalina.util.IOTools;
*
* <B>CGI Specification</B>:<br> derived from
* <a href="http://cgi-spec.golux.com">http://cgi-spec.golux.com</a>.
- * A work-in-progress & expired Internet Draft. Note no actual RFC describing
+ * A work-in-progress & expired Internet Draft. Note no actual RFC
describing
* the CGI specification exists. Where the behavior of this servlet differs
* from the specification cited above, it is either documented here, a bug,
* or an instance where the specification cited differs from Best
@@ -161,7 +164,6 @@ import org.apache.catalina.util.IOTools;
* </p>
* [end excerpt]
*
- * </p>
* <h2> Implementation notes</h2>
* <p>
*
@@ -175,12 +177,12 @@ import org.apache.catalina.util.IOTools;
* and stderr (which should not be too hard).
* <br>
* If you find your cgi scripts are timing out receiving input, you can set
- * the init parameter <code></code> of your webapps' cgi-handling servlet
- * to be
+ * the init parameter <code>stderrTimeout</code> of your webapps' cgi-handling
+ * servlet.
* </p>
* <p>
*
- * <b>Metavariable Values</b>: According to the CGI specificion,
+ * <b>Metavariable Values</b>: According to the CGI specification,
* implementations may choose to represent both null or missing values in an
* implementation-specific manner, but must define that manner. This
* implementation chooses to always define all required metavariables, but
@@ -193,7 +195,7 @@ import org.apache.catalina.util.IOTools;
*
* <b>NPH -- Non-parsed-header implementation</b>: This implementation does
* not support the CGI NPH concept, whereby server ensures that the data
- * supplied to the script are preceisely as supplied by the client and
+ * supplied to the script are precisely as supplied by the client and
* unaltered by the server.
* </p>
* <p>
@@ -213,7 +215,6 @@ import org.apache.catalina.util.IOTools;
* <a href="http://cgi-spec.golux.com">http://cgi-spec.golux.com</a>.
*
* </p>
- * <p>
* <h3>TODO:</h3>
* <ul>
* <li> Support for setting headers (for example, Location headers don't work)
@@ -228,34 +229,22 @@ import org.apache.catalina.util.IOTools;
* <li> Better documentation
* <li> Confirm use of ServletInputStream.available() in CGIRunner.run() is
* not needed
- * <li> Make checking for "." and ".." in servlet & cgi PATH_INFO less
- * draconian
* <li> [add more to this TODO list]
* </ul>
- * </p>
*
* @author Martin T Dengler [[email protected]]
* @author Amy Roh
- *
- * @since Tomcat 4.0
- *
*/
-
-
public final class CGIServlet extends HttpServlet {
+ private static final Log log = LogFactory.getLog(CGIServlet.class);
+ private static final StringManager sm =
StringManager.getManager(Constants.Package);
+
+ private static final String LINE_SEP =
System.getProperty("line.separator");
+
/* some vars below copied from Craig R. McClanahan's InvokerServlet */
- /**
- * The debugging detail level for this servlet. Useful values range from 0
- * to 5 where 0 means no logging and 5 means maximum logging. Values of 10
- * or more mean maximum logging and debug info added to the HTTP response.
- * If an error occurs and debug is 10 or more the standard error page
- * mechanism will be disabled and a response body with debug information
- * will be produced. Note that any value of 10 or more has the same effect
- * as a value of 10.
- */
- private int debug = 0;
+ private static final long serialVersionUID = 1L;
/**
* The CGI search path will start at
@@ -282,10 +271,10 @@ public final class CGIServlet extends Ht
private long stderrTimeout = 2000;
/** object used to ensure multiple threads don't try to expand same file */
- static Object expandFileLock = new Object();
+ private static final Object expandFileLock = new Object();
/** the shell environment variables to be passed to the CGI script */
- Hashtable<String,String> shellEnv = new Hashtable<String,String>();
+ private final Hashtable<String,String> shellEnv = new
Hashtable<String,String>();
/**
* Sets instance variables.
@@ -302,6 +291,7 @@ public final class CGIServlet extends Ht
* interferes with the servlet's normal
* operation
*/
+ @Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
@@ -315,11 +305,9 @@ public final class CGIServlet extends Ht
("Cannot invoke CGIServlet through the invoker");
// Set our properties from the initialization parameters
- if (getServletConfig().getInitParameter("debug") != null)
- debug =
Integer.parseInt(getServletConfig().getInitParameter("debug"));
cgiPathPrefix = getServletConfig().getInitParameter("cgiPathPrefix");
boolean passShellEnvironment =
-
Boolean.valueOf(getServletConfig().getInitParameter("passShellEnvironment")).booleanValue();
+
Boolean.parseBoolean(getServletConfig().getInitParameter("passShellEnvironment"));
if (passShellEnvironment) {
shellEnv.putAll(System.getenv());
@@ -354,245 +342,189 @@ public final class CGIServlet extends Ht
}
-
/**
- * Prints out important Servlet API and container information
+ * Logs important Servlet API and container information.
*
* <p>
* Copied from SnoopAllServlet by Craig R. McClanahan
* </p>
*
- * @param out ServletOutputStream as target of the information
+ * @param out Unused
* @param req HttpServletRequest object used as source of information
- * @param res HttpServletResponse object currently not used but could
- * provide future information
+ * @param res Unused
*
* @exception IOException if a write operation exception occurs
*
+ * @deprecated Use {@link #printServletEnvironment(HttpServletRequest).
+ * This will be removed in Tomcat 8.5.X onwards
*/
+ @Deprecated
protected void printServletEnvironment(ServletOutputStream out,
- HttpServletRequest req, HttpServletResponse res) throws IOException {
+ HttpServletRequest req, HttpServletResponse res) throws
IOException {
+ printServletEnvironment(req);
+ }
+
+ /**
+ * Logs important Servlet API and container information.
+ *
+ * <p>
+ * Based on SnoopAllServlet by Craig R. McClanahan
+ * </p>
+ *
+ * @param req HttpServletRequest object used as source of information
+ *
+ * @exception IOException if a write operation exception occurs
+ */
+ private void printServletEnvironment(HttpServletRequest req) throws
IOException {
// Document the properties from ServletRequest
- out.println("<h1>ServletRequest Properties</h1>");
- out.println("<ul>");
- Enumeration attrs = req.getAttributeNames();
+ log.trace("ServletRequest Properties");
+ @SuppressWarnings("unchecked")
+ Enumeration<String> attrs = req.getAttributeNames();
while (attrs.hasMoreElements()) {
- String attr = (String) attrs.nextElement();
- out.println("<li><b>attribute</b> " + attr + " = " +
- req.getAttribute(attr));
- }
- out.println("<li><b>characterEncoding</b> = " +
- req.getCharacterEncoding());
- out.println("<li><b>contentLength</b> = " +
- req.getContentLength());
- out.println("<li><b>contentType</b> = " +
- req.getContentType());
- Enumeration locales = req.getLocales();
+ String attr = attrs.nextElement();
+ log.trace("Request Attribute: " + attr + ": [ " +
req.getAttribute(attr) +"]");
+ }
+ log.trace("Character Encoding: [" + req.getCharacterEncoding() + "]");
+ log.trace("Content Length: [" + req.getContentLength() + "]");
+ log.trace("Content Type: [" + req.getContentType() + "]");
+ @SuppressWarnings("unchecked")
+ Enumeration<Locale> locales = req.getLocales();
while (locales.hasMoreElements()) {
- Locale locale = (Locale) locales.nextElement();
- out.println("<li><b>locale</b> = " + locale);
+ Locale locale = locales.nextElement();
+ log.trace("Locale: [" +locale + "]");
}
- Enumeration params = req.getParameterNames();
+ @SuppressWarnings("unchecked")
+ Enumeration<String> params = req.getParameterNames();
while (params.hasMoreElements()) {
- String param = (String) params.nextElement();
- String values[] = req.getParameterValues(param);
- for (int i = 0; i < values.length; i++)
- out.println("<li><b>parameter</b> " + param + " = " +
- values[i]);
- }
- out.println("<li><b>protocol</b> = " + req.getProtocol());
- out.println("<li><b>remoteAddr</b> = " + req.getRemoteAddr());
- out.println("<li><b>remoteHost</b> = " + req.getRemoteHost());
- out.println("<li><b>scheme</b> = " + req.getScheme());
- out.println("<li><b>secure</b> = " + req.isSecure());
- out.println("<li><b>serverName</b> = " + req.getServerName());
- out.println("<li><b>serverPort</b> = " + req.getServerPort());
- out.println("</ul>");
- out.println("<hr>");
+ String param = params.nextElement();
+ for (String value : req.getParameterValues(param)) {
+ log.trace("Request Parameter: " + param + ": [" + value +
"]");
+ }
+ }
+ log.trace("Protocol: [" + req.getProtocol() + "]");
+ log.trace("Remote Address: [" + req.getRemoteAddr() + "]");
+ log.trace("Remote Host: [" + req.getRemoteHost() + "]");
+ log.trace("Scheme: [" + req.getScheme() + "]");
+ log.trace("Secure: [" + req.isSecure() + "]");
+ log.trace("Server Name: [" + req.getServerName() + "]");
+ log.trace("Server Port: [" + req.getServerPort() + "]");
// Document the properties from HttpServletRequest
- out.println("<h1>HttpServletRequest Properties</h1>");
- out.println("<ul>");
- out.println("<li><b>authType</b> = " + req.getAuthType());
- out.println("<li><b>contextPath</b> = " +
- req.getContextPath());
+ log.trace("HttpServletRequest Properties");
+ log.trace("Auth Type: [" + req.getAuthType() + "]");
+ log.trace("Context Path: [" + req.getContextPath() + "]");
Cookie cookies[] = req.getCookies();
- if (cookies!=null) {
- for (int i = 0; i < cookies.length; i++)
- out.println("<li><b>cookie</b> " + cookies[i].getName() +" = "
+cookies[i].getValue());
+ if (cookies != null) {
+ for (Cookie cookie : cookies) {
+ log.trace("Cookie: " + cookie.getName() + ": [" +
cookie.getValue() + "]");
+ }
}
- Enumeration headers = req.getHeaderNames();
+ @SuppressWarnings("unchecked")
+ Enumeration<String> headers = req.getHeaderNames();
while (headers.hasMoreElements()) {
- String header = (String) headers.nextElement();
- out.println("<li><b>header</b> " + header + " = " +
- req.getHeader(header));
- }
- out.println("<li><b>method</b> = " + req.getMethod());
- out.println("<li><a name=\"pathInfo\"><b>pathInfo</b></a> = "
- + req.getPathInfo());
- out.println("<li><b>pathTranslated</b> = " +
- req.getPathTranslated());
- out.println("<li><b>queryString</b> = " +
- req.getQueryString());
- out.println("<li><b>remoteUser</b> = " +
- req.getRemoteUser());
- out.println("<li><b>requestedSessionId</b> = " +
- req.getRequestedSessionId());
- out.println("<li><b>requestedSessionIdFromCookie</b> = " +
- req.isRequestedSessionIdFromCookie());
- out.println("<li><b>requestedSessionIdFromURL</b> = " +
- req.isRequestedSessionIdFromURL());
- out.println("<li><b>requestedSessionIdValid</b> = " +
- req.isRequestedSessionIdValid());
- out.println("<li><b>requestURI</b> = " +
- req.getRequestURI());
- out.println("<li><b>servletPath</b> = " +
- req.getServletPath());
- out.println("<li><b>userPrincipal</b> = " +
- req.getUserPrincipal());
- out.println("</ul>");
- out.println("<hr>");
-
- // Document the servlet request attributes
- out.println("<h1>ServletRequest Attributes</h1>");
- out.println("<ul>");
- attrs = req.getAttributeNames();
- while (attrs.hasMoreElements()) {
- String attr = (String) attrs.nextElement();
- out.println("<li><b>" + attr + "</b> = " +
- req.getAttribute(attr));
+ String header = headers.nextElement();
+ log.trace("HTTP Header: " + header + ": [" + req.getHeader(header)
+ "]");
}
- out.println("</ul>");
- out.println("<hr>");
+ log.trace("Method: [" + req.getMethod() + "]");
+ log.trace("Path Info: [" + req.getPathInfo() + "]");
+ log.trace("Path Translated: [" + req.getPathTranslated() + "]");
+ log.trace("Query String: [" + req.getQueryString() + "]");
+ log.trace("Remote User: [" + req.getRemoteUser() + "]");
+ log.trace("Requested Session ID: [" + req.getRequestedSessionId() +
"]");
+ log.trace("Requested Session ID From Cookie: [" +
+ req.isRequestedSessionIdFromCookie() + "]");
+ log.trace("Requested Session ID From URL: [" +
req.isRequestedSessionIdFromURL() + "]");
+ log.trace("Requested Session ID Valid: [" +
req.isRequestedSessionIdValid() + "]");
+ log.trace("Request URI: [" + req.getRequestURI() + "]");
+ log.trace("Servlet Path: [" + req.getServletPath() + "]");
+ log.trace("User Principal: [" + req.getUserPrincipal() + "]");
// Process the current session (if there is one)
HttpSession session = req.getSession(false);
if (session != null) {
// Document the session properties
- out.println("<h1>HttpSession Properties</h1>");
- out.println("<ul>");
- out.println("<li><b>id</b> = " +
- session.getId());
- out.println("<li><b>creationTime</b> = " +
- new Date(session.getCreationTime()));
- out.println("<li><b>lastAccessedTime</b> = " +
- new Date(session.getLastAccessedTime()));
- out.println("<li><b>maxInactiveInterval</b> = " +
- session.getMaxInactiveInterval());
- out.println("</ul>");
- out.println("<hr>");
+ log.trace("HttpSession Properties");
+ log.trace("ID: [" + session.getId() + "]");
+ log.trace("Creation Time: [" + new Date(session.getCreationTime())
+ "]");
+ log.trace("Last Accessed Time: [" + new
Date(session.getLastAccessedTime()) + "]");
+ log.trace("Max Inactive Interval: [" +
session.getMaxInactiveInterval() + "]");
// Document the session attributes
- out.println("<h1>HttpSession Attributes</h1>");
- out.println("<ul>");
attrs = session.getAttributeNames();
while (attrs.hasMoreElements()) {
- String attr = (String) attrs.nextElement();
- out.println("<li><b>" + attr + "</b> = " +
- session.getAttribute(attr));
+ String attr = attrs.nextElement();
+ log.trace("Session Attribute: " + attr + ": [" +
session.getAttribute(attr) + "]");
}
- out.println("</ul>");
- out.println("<hr>");
-
}
// Document the servlet configuration properties
- out.println("<h1>ServletConfig Properties</h1>");
- out.println("<ul>");
- out.println("<li><b>servletName</b> = " +
- getServletConfig().getServletName());
- out.println("</ul>");
- out.println("<hr>");
+ log.trace("ServletConfig Properties");
+ log.trace("Servlet Name: [" + getServletConfig().getServletName() +
"]");
// Document the servlet configuration initialization parameters
- out.println("<h1>ServletConfig Initialization Parameters</h1>");
- out.println("<ul>");
params = getServletConfig().getInitParameterNames();
while (params.hasMoreElements()) {
- String param = (String) params.nextElement();
+ String param = params.nextElement();
String value = getServletConfig().getInitParameter(param);
- out.println("<li><b>" + param + "</b> = " + value);
+ log.trace("Servlet Init Param: " + param + ": [" + value + "]");
}
- out.println("</ul>");
- out.println("<hr>");
// Document the servlet context properties
- out.println("<h1>ServletContext Properties</h1>");
- out.println("<ul>");
- out.println("<li><b>majorVersion</b> = " +
- getServletContext().getMajorVersion());
- out.println("<li><b>minorVersion</b> = " +
- getServletContext().getMinorVersion());
- out.println("<li><b>realPath('/')</b> = " +
- getServletContext().getRealPath("/"));
- out.println("<li><b>serverInfo</b> = " +
- getServletContext().getServerInfo());
- out.println("</ul>");
- out.println("<hr>");
+ log.trace("ServletContext Properties");
+ log.trace("Major Version: [" + getServletContext().getMajorVersion() +
"]");
+ log.trace("Minor Version: [" + getServletContext().getMinorVersion() +
"]");
+ log.trace("Real Path for '/': [" +
getServletContext().getRealPath("/") + "]");
+ log.trace("Server Info: [" + getServletContext().getServerInfo() +
"]");
// Document the servlet context initialization parameters
- out.println("<h1>ServletContext Initialization Parameters</h1>");
- out.println("<ul>");
+ log.trace("ServletContext Initialization Parameters");
params = getServletContext().getInitParameterNames();
while (params.hasMoreElements()) {
- String param = (String) params.nextElement();
+ String param = params.nextElement();
String value = getServletContext().getInitParameter(param);
- out.println("<li><b>" + param + "</b> = " + value);
+ log.trace("Servlet Context Init Param: " + param + ": [" + value +
"]");
}
- out.println("</ul>");
- out.println("<hr>");
// Document the servlet context attributes
- out.println("<h1>ServletContext Attributes</h1>");
- out.println("<ul>");
+ log.trace("ServletContext Attributes");
attrs = getServletContext().getAttributeNames();
while (attrs.hasMoreElements()) {
- String attr = (String) attrs.nextElement();
- out.println("<li><b>" + attr + "</b> = " +
- getServletContext().getAttribute(attr));
+ String attr = attrs.nextElement();
+ log.trace("Servlet Context Attribute: " + attr +
+ ": [" + getServletContext().getAttribute(attr) + "]");
}
- out.println("</ul>");
- out.println("<hr>");
-
-
-
}
-
/**
- * Provides CGI Gateway service -- delegates to <code>doGet</code>
+ * Provides CGI Gateway service -- delegates to
+ * {@link #doGet(HttpServletRequest, HttpServletResponse)}.
*
* @param req HttpServletRequest passed in by servlet container
* @param res HttpServletResponse passed in by servlet container
*
* @exception ServletException if a servlet-specific exception occurs
* @exception IOException if a read/write exception occurs
- *
- * @see javax.servlet.http.HttpServlet
- *
*/
+ @Override
protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException {
doGet(req, res);
}
-
/**
- * Provides CGI Gateway service
+ * Provides CGI Gateway service.
*
* @param req HttpServletRequest passed in by servlet container
* @param res HttpServletResponse passed in by servlet container
*
* @exception ServletException if a servlet-specific exception occurs
* @exception IOException if a read/write exception occurs
- *
- * @see javax.servlet.http.HttpServlet
- *
*/
+ @Override
protected void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
@@ -608,75 +540,37 @@ public final class CGIServlet extends Ht
cgiEnv.getEnvironment(),
cgiEnv.getWorkingDirectory(),
cgiEnv.getParameters());
- //if POST, we need to cgi.setInput
- //REMIND: how does this interact with Servlet API 2.3's Filters?!
+
if ("POST".equals(req.getMethod())) {
cgi.setInput(req.getInputStream());
}
cgi.setResponse(res);
cgi.run();
+ } else {
+ res.sendError(404);
}
- if (!cgiEnv.isValid()) {
- if (setStatus(res, 404)) {
- return;
- }
- }
-
- if (debug >= 10) {
-
- ServletOutputStream out = res.getOutputStream();
- out.println("<HTML><HEAD><TITLE>$Name$</TITLE></HEAD>");
- out.println("<BODY>$Header$<p>");
-
- if (cgiEnv.isValid()) {
- out.println(cgiEnv.toString());
- } else {
- out.println("<H3>");
- out.println("CGI script not found or not specified.");
- out.println("</H3>");
- out.println("<H4>");
- out.println("Check the <b>HttpServletRequest ");
- out.println("<a href=\"#pathInfo\">pathInfo</a></b> ");
- out.println("property to see if it is what you meant ");
- out.println("it to be. You must specify an existant ");
- out.println("and executable file as part of the ");
- out.println("path-info.");
- out.println("</H4>");
- out.println("<H4>");
- out.println("For a good discussion of how CGI scripts ");
- out.println("work and what their environment variables ");
- out.println("mean, please visit the <a ");
- out.println("href=\"http://cgi-spec.golux.com\">CGI ");
- out.println("Specification page</a>.");
- out.println("</H4>");
-
+ if (log.isTraceEnabled()) {
+ String[] cgiEnvLines = cgiEnv.toString().split(LINE_SEP);
+ for (String cgiEnvLine : cgiEnvLines) {
+ log.trace(cgiEnvLine);
}
- printServletEnvironment(out, req, res);
-
- out.println("</BODY></HTML>");
-
+ printServletEnvironment(req);
}
+ }
- } //doGet
-
-
- /*
- * Behaviour depends on the status code and the value of debug.
+ /**
+ * Behaviour depends on the status code.
*
- * Status < 400 - Always calls setStatus. Returns false. CGI servlet will
- * provide the response body.
- * Status >= 400 - Depends on debug
- * debug < 10 - Calls sendError(status), returns true. Standard error
- * page mechanism will provide the response body.
- * debug >= 10 - Calls setStatus(status), return false. CGI servlet
will
- * provide the response body.
+ * Status < 400 - Calls setStatus. Returns false. CGI servlet will provide
+ * the response body.
+ * Status >= 400 - Calls sendError(status), returns true. Standard error
+ * page mechanism will provide the response body.
*/
private boolean setStatus(HttpServletResponse response, int status) throws
IOException {
-
- if (status >= HttpServletResponse.SC_BAD_REQUEST && debug < 10) {
+ if (status >= HttpServletResponse.SC_BAD_REQUEST) {
response.sendError(status);
return true;
} else {
@@ -689,13 +583,6 @@ public final class CGIServlet extends Ht
/**
* Encapsulates the CGI environment and rules to derive
* that environment from the servlet container and request information.
- *
- * <p>
- * </p>
- *
- *
- * @since Tomcat 4.0
- *
*/
protected class CGIEnvironment {
@@ -719,19 +606,19 @@ public final class CGIServlet extends Ht
private File tmpDir = null;
/** derived cgi environment */
- private Hashtable env = null;
+ private Hashtable<String, String> env = null;
/** cgi command to be invoked */
private String command = null;
/** cgi command's desired working directory */
- private File workingDirectory = null;
+ private final File workingDirectory;
/** cgi command's command line parameters */
- private ArrayList<String> cmdLineParameters = new ArrayList<String>();
+ private final ArrayList<String> cmdLineParameters = new
ArrayList<String>();
/** whether or not this object is valid or not */
- private boolean valid = false;
+ private final boolean valid;
/**
@@ -742,7 +629,7 @@ public final class CGIServlet extends Ht
* the Servlet API
* @param context ServletContext for information provided by the
* Servlet API
- *
+ * @throws IOException an IO error occurred
*/
protected CGIEnvironment(HttpServletRequest req,
ServletContext context) throws IOException {
@@ -754,12 +641,13 @@ public final class CGIServlet extends Ht
if (this.valid) {
workingDirectory = new File(command.substring(0,
command.lastIndexOf(File.separator)));
+ } else {
+ workingDirectory = null;
}
}
-
/**
* Uses the ServletContext to set some CGI variables
*
@@ -773,13 +661,12 @@ public final class CGIServlet extends Ht
}
-
/**
* Uses the HttpServletRequest to set most CGI variables
*
* @param req HttpServletRequest for information provided by
* the Servlet API
- * @throws UnsupportedEncodingException
+ * @throws UnsupportedEncodingException Unknown encoding
*/
protected void setupFromRequest(HttpServletRequest req)
throws UnsupportedEncodingException {
@@ -822,7 +709,7 @@ public final class CGIServlet extends Ht
} else {
qs = req.getQueryString();
}
- if (qs != null && qs.indexOf("=") == -1) {
+ if (qs != null && qs.indexOf('=') == -1) {
StringTokenizer qsTokens = new StringTokenizer(qs, "+");
while ( qsTokens.hasMoreTokens() ) {
cmdLineParameters.add(URLDecoder.decode(qsTokens.nextToken(),
@@ -838,6 +725,7 @@ public final class CGIServlet extends Ht
*
* <p>
* Example URI:
+ * </p>
* <PRE> /servlet/cgigateway/dir1/realCGIscript/pathinfo1 </PRE>
* <ul>
* <LI><b>path</b> = $CATALINA_HOME/mywebapp/dir1/realCGIscript
@@ -845,7 +733,6 @@ public final class CGIServlet extends Ht
* <LI><b>cgiName</b> = /dir1/realCGIscript
* <LI><b>name</b> = realCGIscript
* </ul>
- * </p>
* <p>
* CGI search algorithm: search the real path below
* <my-webapp-root> and find the first non-directory in
@@ -895,8 +782,6 @@ public final class CGIServlet extends Ht
* <code>name</code> - simple name (no directories) of the
* cgi script, or null if no cgi was found
* </ul>
- *
- * @since Tomcat 4.0
*/
protected String[] findCGI(String pathInfo, String webAppRootDir,
String contextPath, String servletPath,
@@ -904,45 +789,42 @@ public final class CGIServlet extends Ht
String path = null;
String name = null;
String scriptname = null;
- String cginame = "";
- if ((webAppRootDir != null)
- && (webAppRootDir.lastIndexOf(File.separator) ==
- (webAppRootDir.length() - 1))) {
- //strip the trailing "/" from the webAppRootDir
- webAppRootDir =
- webAppRootDir.substring(0, (webAppRootDir.length() - 1));
+ if (webAppRootDir != null &&
+ webAppRootDir.lastIndexOf(File.separator) ==
(webAppRootDir.length() - 1)) {
+ //strip the trailing "/" from the webAppRootDir
+ webAppRootDir = webAppRootDir.substring(0,
(webAppRootDir.length() - 1));
}
if (cgiPathPrefix != null) {
- webAppRootDir = webAppRootDir + File.separator
- + cgiPathPrefix;
+ webAppRootDir = webAppRootDir + File.separator + cgiPathPrefix;
}
- if (debug >= 2) {
- log("findCGI: path=" + pathInfo + ", " + webAppRootDir);
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("cgiServlet.find.path", pathInfo,
webAppRootDir));
}
File currentLocation = new File(webAppRootDir);
- StringTokenizer dirWalker =
- new StringTokenizer(pathInfo, "/");
- if (debug >= 3) {
- log("findCGI: currentLoc=" + currentLocation);
+ StringTokenizer dirWalker = new StringTokenizer(pathInfo, "/");
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("cgiServlet.find.location",
+ currentLocation.getAbsolutePath()));
}
+ StringBuilder cginameBuilder = new StringBuilder();
while (!currentLocation.isFile() && dirWalker.hasMoreElements()) {
- if (debug >= 3) {
- log("findCGI: currentLoc=" + currentLocation);
- }
String nextElement = (String) dirWalker.nextElement();
currentLocation = new File(currentLocation, nextElement);
- cginame = cginame + "/" + nextElement;
+ cginameBuilder.append('/').append(nextElement);
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("cgiServlet.find.location",
+ currentLocation.getAbsolutePath()));
+ }
}
+ String cginame = cginameBuilder.toString();
if (!currentLocation.isFile()) {
return new String[] { null, null, null, null };
- } else {
- if (debug >= 2) {
- log("findCGI: FOUND cgi at " + currentLocation);
}
+
path = currentLocation.getAbsolutePath();
name = currentLocation.getName();
@@ -954,24 +836,23 @@ public final class CGIServlet extends Ht
if (!servletPath.equals(cginame)) {
scriptname = scriptname + cginame;
}
- }
- if (debug >= 1) {
- log("findCGI calc: name=" + name + ", path=" + path
- + ", scriptname=" + scriptname + ", cginame=" + cginame);
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("cgiServlet.find.found", name, path,
scriptname, cginame));
}
return new String[] { path, scriptname, cginame, name };
}
/**
* Constructs the CGI environment to be supplied to the invoked CGI
- * script; relies heavliy on Servlet API methods and findCGI
+ * script; relies heavily on Servlet API methods and findCGI
*
* @param req request associated with the CGI
- * invokation
+ * Invocation
*
* @return true if environment was set OK, false if there
* was a problem and no environment was set
+ * @throws IOException an IO error occurred
*/
protected boolean setCGIEnvironment(HttpServletRequest req) throws
IOException {
@@ -988,7 +869,6 @@ public final class CGIServlet extends Ht
// Add the CGI environment variables
String sPathInfoOrig = null;
- String sPathTranslatedOrig = null;
String sPathInfoCGI = null;
String sPathTranslatedCGI = null;
String sCGIFullPath = null;
@@ -1001,10 +881,6 @@ public final class CGIServlet extends Ht
sPathInfoOrig = this.pathInfo;
sPathInfoOrig = sPathInfoOrig == null ? "" : sPathInfoOrig;
- sPathTranslatedOrig = req.getPathTranslated();
- sPathTranslatedOrig =
- sPathTranslatedOrig == null ? "" : sPathTranslatedOrig;
-
if (webAppRootDir == null ) {
// The app has not been deployed in exploded form
webAppRootDir = tmpDir.toString();
@@ -1038,7 +914,8 @@ public final class CGIServlet extends Ht
envp.put("SERVER_PROTOCOL", nullsToBlanks(req.getProtocol()));
int port = req.getServerPort();
- Integer iPort = (port == 0 ? new Integer(-1) : new Integer(port));
+ Integer iPort =
+ (port == 0 ? Integer.valueOf(-1) : Integer.valueOf(port));
envp.put("SERVER_PORT", iPort.toString());
envp.put("REQUEST_METHOD", nullsToBlanks(req.getMethod()));
@@ -1085,10 +962,8 @@ public final class CGIServlet extends Ht
* SHOULD NOT be defined.
*
*/
- if (sPathInfoCGI != null && !("".equals(sPathInfoCGI))) {
+ if (!("".equals(sPathInfoCGI))) {
sPathTranslatedCGI = context.getRealPath(sPathInfoCGI);
- } else {
- sPathTranslatedCGI = null;
}
if (sPathTranslatedCGI == null || "".equals(sPathTranslatedCGI)) {
//NOOP
@@ -1120,15 +995,16 @@ public final class CGIServlet extends Ht
*/
int contentLength = req.getContentLength();
String sContentLength = (contentLength <= 0 ? "" :
- (new Integer(contentLength)).toString());
+ Integer.toString(contentLength));
envp.put("CONTENT_LENGTH", sContentLength);
- Enumeration headers = req.getHeaderNames();
+ @SuppressWarnings("unchecked")
+ Enumeration<String> headers = req.getHeaderNames();
String header = null;
while (headers.hasMoreElements()) {
header = null;
- header = ((String) headers.nextElement()).toUpperCase();
+ header = headers.nextElement().toUpperCase(Locale.ENGLISH);
//REMIND: rewrite multiple headers as if received as single
//REMIND: change character set
//REMIND: I forgot what the previous REMIND means
@@ -1159,8 +1035,8 @@ public final class CGIServlet extends Ht
* directory to enable CGI script to be executed.
*/
protected void expandCGIScript() {
- StringBuffer srcPath = new StringBuffer();
- StringBuffer destPath = new StringBuffer();
+ StringBuilder srcPath = new StringBuilder();
+ StringBuilder destPath = new StringBuilder();
InputStream is = null;
// paths depend on mapping
@@ -1187,23 +1063,27 @@ public final class CGIServlet extends Ht
if (is == null) {
// didn't find anything, give up now
- if (debug >= 2) {
- log("expandCGIScript: source '" + srcPath + "' not found");
- }
- return;
+ log.warn(sm.getString("cgiServlet.expandNotFound", srcPath));
+ return;
}
File f = new File(destPath.toString());
if (f.exists()) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ log.warn(sm.getString("cgiServlet.expandCloseFail",
srcPath), e);
+ }
// Don't need to expand if it already exists
return;
}
// create directories
- String dirPath = new String (destPath.toString().substring(
- 0,destPath.toString().lastIndexOf("/")));
- File dir = new File(dirPath);
- dir.mkdirs();
+ File dir = f.getParentFile();
+ if (!dir.mkdirs() && !dir.isDirectory()) {
+ log.warn(sm.getString("cgiServlet.expandCreateDirFail",
dir.getAbsolutePath()));
+ return;
+ }
try {
synchronized (expandFileLock) {
@@ -1218,88 +1098,100 @@ public final class CGIServlet extends Ht
}
FileOutputStream fos = new FileOutputStream(f);
+ try {
// copy data
IOTools.flow(is, fos);
- is.close();
- fos.close();
- if (debug >= 2) {
- log("expandCGIScript: expanded '" + srcPath + "' to '"
+ destPath + "'");
+ } finally {
+ try {
+ is.close();
+ } catch (IOException e) {
+ log.warn(sm.getString("cgiServlet.expandError"),
e);
+ }
+ fos.close();
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(sm.getString("cgiServlet.expandOk", srcPath,
destPath));
}
}
} catch (IOException ioe) {
+ log.warn(sm.getString("cgiServlet.expandFail", srcPath,
destPath), ioe);
// delete in case file is corrupted
if (f.exists()) {
- f.delete();
+ if (!f.delete()) {
+ log.warn(sm.getString("cgiServlet.expandDeleteFail",
f.getAbsolutePath()));
+ }
}
}
}
/**
- * Print important CGI environment information in a easy-to-read HTML
- * table
- *
- * @return HTML string containing CGI environment info
+ * Returns important CGI environment information in a multi-line text
+ * format.
*
+ * @return CGI environment info
*/
+ @Override
public String toString() {
- StringBuffer sb = new StringBuffer();
-
- sb.append("<TABLE border=2>");
-
- sb.append("<tr><th colspan=2 bgcolor=grey>");
- sb.append("CGIEnvironment Info</th></tr>");
+ StringBuilder sb = new StringBuilder();
- sb.append("<tr><td>Debug Level</td><td>");
- sb.append(debug);
- sb.append("</td></tr>");
-
- sb.append("<tr><td>Validity:</td><td>");
- sb.append(isValid());
- sb.append("</td></tr>");
+ sb.append("CGIEnvironment Info:");
+ sb.append(LINE_SEP);
if (isValid()) {
- Enumeration envk = env.keys();
- while (envk.hasMoreElements()) {
- String s = (String) envk.nextElement();
- sb.append("<tr><td>");
- sb.append(s);
- sb.append("</td><td>");
- sb.append(blanksToString((String) env.get(s),
- "[will be set to blank]"));
- sb.append("</td></tr>");
+ sb.append("Validity: [true]");
+ sb.append(LINE_SEP);
+
+ sb.append("Environment values:");
+ sb.append(LINE_SEP);
+ for (Entry<String,String> entry : env.entrySet()) {
+ sb.append(" ");
+ sb.append(entry.getKey());
+ sb.append(": [");
+ sb.append(blanksToString(entry.getValue(), "will be set to
blank"));
+ sb.append("]");
+ sb.append(LINE_SEP);
}
- }
- sb.append("<tr><td colspan=2><HR></td></tr>");
+ sb.append("Derived Command :[");
+ sb.append(nullsToBlanks(command));
+ sb.append("]");
+ sb.append(LINE_SEP);
- sb.append("<tr><td>Derived Command</td><td>");
- sb.append(nullsToBlanks(command));
- sb.append("</td></tr>");
- sb.append("<tr><td>Working Directory</td><td>");
- if (workingDirectory != null) {
- sb.append(workingDirectory.toString());
- }
- sb.append("</td></tr>");
+ sb.append("Working Directory: [");
+ if (workingDirectory != null) {
+ sb.append(workingDirectory.toString());
+ }
+ sb.append("]");
+ sb.append(LINE_SEP);
- sb.append("<tr><td>Command Line Params</td><td>");
- for (int i=0; i < cmdLineParameters.size(); i++) {
- String param = (String) cmdLineParameters.get(i);
- sb.append("<p>");
- sb.append(param);
- sb.append("</p>");
+ sb.append("Command Line Params:");
+ sb.append(LINE_SEP);
+ for (String param : cmdLineParameters) {
+ sb.append(" [");
+ sb.append(param);
+ sb.append("]");
+ sb.append(LINE_SEP);
+ }
+ } else {
+ sb.append("Validity: [false]");
+ sb.append(LINE_SEP);
+ sb.append("CGI script not found or not specified.");
+ sb.append(LINE_SEP);
+ sb.append("Check the HttpServletRequest pathInfo property to
see if it is what ");
+ sb.append(LINE_SEP);
+ sb.append("you meant it to be. You must specify an existant
and executable file ");
+ sb.append(LINE_SEP);
+ sb.append("as part of the path-info.");
+ sb.append(LINE_SEP);
}
- sb.append("</td></tr>");
-
- sb.append("</TABLE><p>end.");
return sb.toString();
}
-
/**
* Gets derived command string
*
@@ -1311,7 +1203,6 @@ public final class CGIServlet extends Ht
}
-
/**
* Gets derived CGI working directory
*
@@ -1323,31 +1214,28 @@ public final class CGIServlet extends Ht
}
-
/**
* Gets derived CGI environment
*
* @return CGI environment
*
*/
- protected Hashtable getEnvironment() {
+ protected Hashtable<String,String> getEnvironment() {
return env;
}
-
/**
* Gets derived CGI query parameters
*
* @return CGI query parameters
*
*/
- protected ArrayList getParameters() {
+ protected ArrayList<String> getParameters() {
return cmdLineParameters;
}
-
/**
* Gets validity status
*
@@ -1360,7 +1248,6 @@ public final class CGIServlet extends Ht
}
-
/**
* Converts null strings to blank strings ("")
*
@@ -1373,7 +1260,6 @@ public final class CGIServlet extends Ht
}
-
/**
* Converts null strings to another string
*
@@ -1388,7 +1274,6 @@ public final class CGIServlet extends Ht
}
-
/**
* Converts blank strings to another string
*
@@ -1405,14 +1290,9 @@ public final class CGIServlet extends Ht
}
-
} //class CGIEnvironment
-
-
-
-
/**
* Encapsulates the knowledge of how to run a CGI script, given the
* script's desired environment and (optionally) input/output streams
@@ -1426,7 +1306,7 @@ public final class CGIServlet extends Ht
* <p>
*
* The CGI environment and settings are derived from the information
- * passed to the constuctor.
+ * passed to the constructor.
*
* </p>
* <p>
@@ -1434,23 +1314,20 @@ public final class CGIServlet extends Ht
* The input and output streams can be set by the <code>setInput</code>
* and <code>setResponse</code> methods, respectively.
* </p>
- *
- *
*/
-
protected class CGIRunner {
/** script/command to be executed */
- private String command = null;
+ private final String command;
/** environment used when invoking the cgi script */
- private Hashtable env = null;
+ private final Hashtable<String,String> env;
/** working directory used when invoking the cgi script */
- private File wd = null;
+ private final File wd;
/** command line parameters to be passed to the invoked script */
- private ArrayList params = null;
+ private final ArrayList<String> params;
/** stdin to be passed to cgi script */
private InputStream stdin = null;
@@ -1462,8 +1339,6 @@ public final class CGIServlet extends Ht
private boolean readyToRun = false;
-
-
/**
* Creates a CGIRunner and initializes its environment, working
* directory, and query parameters.
@@ -1476,10 +1351,10 @@ public final class CGIServlet extends Ht
* @param env Hashtable with the desired script environment
* @param wd File with the script's desired working directory
* @param params ArrayList with the script's query command line
- * paramters as strings
+ * parameters as strings
*/
- protected CGIRunner(String command, Hashtable env, File wd,
- ArrayList params) {
+ protected CGIRunner(String command, Hashtable<String,String> env,
+ File wd, ArrayList<String> params) {
this.command = command;
this.env = env;
this.wd = wd;
@@ -1488,9 +1363,8 @@ public final class CGIServlet extends Ht
}
-
/**
- * Checks & sets ready status
+ * Checks and sets ready status
*/
protected void updateReadyStatus() {
if (command != null
@@ -1505,7 +1379,6 @@ public final class CGIServlet extends Ht
}
-
/**
* Gets ready status
*
@@ -1517,7 +1390,6 @@ public final class CGIServlet extends Ht
}
-
/**
* Sets HttpServletResponse object used to set headers and send
* output to
@@ -1531,7 +1403,6 @@ public final class CGIServlet extends Ht
}
-
/**
* Sets standard input to be passed on to the invoked cgi script
*
@@ -1544,7 +1415,6 @@ public final class CGIServlet extends Ht
}
-
/**
* Converts a Hashtable to a String array by converting each
* key/value pair in the Hashtable to a String in the form
@@ -1557,13 +1427,13 @@ public final class CGIServlet extends Ht
* @exception NullPointerException if a hash key has a null value
*
*/
- protected String[] hashToStringArray(Hashtable h)
+ protected String[] hashToStringArray(Hashtable<String,?> h)
throws NullPointerException {
Vector<String> v = new Vector<String>();
- Enumeration e = h.keys();
+ Enumeration<String> e = h.keys();
while (e.hasMoreElements()) {
- String k = e.nextElement().toString();
- v.add(k + "=" + h.get(k));
+ String k = e.nextElement();
+ v.add(k + "=" + h.get(k).toString());
}
String[] strArr = new String[v.size()];
v.copyInto(strArr);
@@ -1571,13 +1441,13 @@ public final class CGIServlet extends Ht
}
-
/**
* Executes a CGI script with the desired environment, current working
* directory, and input/output streams
*
* <p>
* This implements the following CGI specification recommedations:
+ * </p>
* <UL>
* <LI> Servers SHOULD provide the "<code>query</code>" component of
* the script-URI as command-line arguments to scripts if it
@@ -1604,7 +1474,10 @@ public final class CGIServlet extends Ht
* segments</u>:
* This implementation does not allow "<code>.</code>" and
* "<code>..</code>" in the the path, and such characters
- * will result in an IOException being thrown;
+ * will result in an IOException being thrown (this should
+ * never happen since Tomcat normalises the requestURI
+ * before determining the contextPath, servletPath and
+ * pathInfo);
* <LI> <u>Implementation limitations</u>: This implementation
* does not impose any limitations except as documented
* above. This implementation may be limited by the
@@ -1614,7 +1487,6 @@ public final class CGIServlet extends Ht
* container's implementation of the Servlet API methods.
* </ul>
* </UL>
- * </p>
*
* @exception IOException if problems during reading/writing occur
*
@@ -1628,12 +1500,11 @@ public final class CGIServlet extends Ht
*/
if (!isReady()) {
- throw new IOException(this.getClass().getName()
- + ": not ready to run.");
+ throw new IOException(this.getClass().getName() + ": not ready
to run.");
}
- if (debug >= 1 ) {
- log("runCGI(envp=[" + env + "], command=" + command + ")");
+ if (log.isDebugEnabled()) {
+ log.debug("envp: [" + env + "], command: [" + command + "]");
}
if ((command.indexOf(File.separator + "." + File.separator) >= 0)
@@ -1646,11 +1517,11 @@ public final class CGIServlet extends Ht
}
/* original content/structure of this section taken from
- * http://developer.java.sun.com/developer/
- * bugParade/bugs/4216884.html
+ * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4216884
* with major modifications by Martin Dengler
*/
Runtime rt = null;
+ BufferedReader cgiHeaderReader = null;
InputStream cgiOutput = null;
BufferedReader commandsStdErr = null;
Thread errReaderThread = null;
@@ -1674,7 +1545,7 @@ public final class CGIServlet extends Ht
cmdAndArgs.toArray(new String[cmdAndArgs.size()]),
hashToStringArray(env), wd);
- String sContentLength = (String) env.get("CONTENT_LENGTH");
+ String sContentLength = env.get("CONTENT_LENGTH");
if(!"".equals(sContentLength)) {
commandsStdIn = new
BufferedOutputStream(proc.getOutputStream());
@@ -1685,8 +1556,7 @@ public final class CGIServlet extends Ht
/* we want to wait for the process to exit, Process.waitFor()
* is useless in our situation; see
- * http://developer.java.sun.com/developer/
- * bugParade/bugs/4223650.html
+ * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4223650
*/
boolean isRunning = true;
@@ -1695,15 +1565,16 @@ public final class CGIServlet extends Ht
final BufferedReader stdErrRdr = commandsStdErr ;
errReaderThread = new Thread() {
+ @Override
public void run () {
- sendToLog(stdErrRdr) ;
- } ;
+ sendToLog(stdErrRdr);
+ }
};
errReaderThread.start();
InputStream cgiHeaderStream =
new HTTPHeaderInputStream(proc.getInputStream());
- BufferedReader cgiHeaderReader =
+ cgiHeaderReader =
new BufferedReader(new InputStreamReader(cgiHeaderStream));
// Need to be careful here. If sendError() is called the
@@ -1716,25 +1587,24 @@ public final class CGIServlet extends Ht
try {
//set headers
String line = null;
- while (((line = cgiHeaderReader.readLine()) != null)
- && !("".equals(line))) {
- if (debug >= 2) {
- log("runCGI: addHeader(\"" + line + "\")");
+ while (((line = cgiHeaderReader.readLine()) != null)
&& !("".equals(line))) {
+ if (log.isTraceEnabled()) {
+ log.trace("addHeader(\"" + line + "\")");
}
if (line.startsWith("HTTP")) {
skipBody = setStatus(response,
getSCFromHttpStatusLine(line));
- } else if (line.indexOf(":") >= 0) {
+ } else if (line.indexOf(':') >= 0) {
String header =
- line.substring(0,
line.indexOf(":")).trim();
+ line.substring(0,
line.indexOf(':')).trim();
String value =
- line.substring(line.indexOf(":") +
1).trim();
+ line.substring(line.indexOf(':') +
1).trim();
if (header.equalsIgnoreCase("status")) {
skipBody = setStatus(response,
getSCFromCGIStatusHeader(value));
} else {
response.addHeader(header , value);
}
} else {
- log("runCGI: bad header line \"" + line +
"\"");
+
log.info(sm.getString("cgiServlet.runBadHeader", line));
}
}
@@ -1746,9 +1616,8 @@ public final class CGIServlet extends Ht
try {
while (!skipBody && (bufRead =
cgiOutput.read(bBuf)) != -1) {
- if (debug >= 4) {
- log("runCGI: output " + bufRead +
- " bytes of data");
+ if (log.isTraceEnabled()) {
+ log.trace("output " + bufRead + " bytes of
data");
}
out.write(bBuf, 0, bufRead);
}
@@ -1757,7 +1626,9 @@ public final class CGIServlet extends Ht
// such as a socket disconnect on the servlet
side; otherwise, the
// external process could hang
if (bufRead != -1) {
- while ((bufRead = cgiOutput.read(bBuf)) != -1)
{}
+ while ((bufRead = cgiOutput.read(bBuf)) != -1)
{
+ // NOOP - just read the data
+ }
}
}
@@ -1769,21 +1640,29 @@ public final class CGIServlet extends Ht
try {
Thread.sleep(500);
} catch (InterruptedException ignored) {
+ // Ignore
}
}
} //replacement for Process.waitFor()
- }
- catch (IOException e){
- log ("Caught exception " + e);
+
+ } catch (IOException e){
+ log.warn(sm.getString("cgiServlet.runFail"), e);
throw e;
- }
- finally{
+ } finally {
+ // Close the header reader
+ if (cgiHeaderReader != null) {
+ try {
+ cgiHeaderReader.close();
+ } catch (IOException ioe) {
+
log.warn(sm.getString("cgiServlet.runHeaderReaderFail"), ioe);
+ }
+ }
// Close the output stream if used
if (cgiOutput != null) {
try {
cgiOutput.close();
} catch (IOException ioe) {
- log ("Exception closing output stream " + ioe);
+
log.warn(sm.getString("cgiServlet.runOutputStreamFail"), ioe);
}
}
// Make sure the error stream reader has finished
@@ -1791,11 +1670,7 @@ public final class CGIServlet extends Ht
try {
errReaderThread.join(stderrTimeout);
} catch (InterruptedException e) {
- log ("Interupted waiting for stderr reader thread");
- }
- }
- if (debug > 4) {
- log ("Running finally block");
+
log.warn(sm.getString("cgiServlet.runReaderInterupt")); }
}
if (proc != null){
proc.destroy();
@@ -1816,7 +1691,7 @@ public final class CGIServlet extends Ht
if (statusStart < 1 || line.length() < statusStart + 3) {
// Not a valid HTTP Status-Line
- log ("runCGI: invalid HTTP Status-Line:" + line);
+ log.warn(sm.getString("cgiServlet.runInvalidStatus", line));
return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
}
@@ -1827,7 +1702,7 @@ public final class CGIServlet extends Ht
statusCode = Integer.parseInt(status);
} catch (NumberFormatException nfe) {
// Not a valid status code
- log ("runCGI: invalid status code:" + status);
+ log.warn(sm.getString("cgiServlet.runInvalidStatus", status));
return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
}
@@ -1845,7 +1720,7 @@ public final class CGIServlet extends Ht
private int getSCFromCGIStatusHeader(String value) {
if (value.length() < 3) {
// Not a valid status value
- log ("runCGI: invalid status value:" + value);
+ log.warn(sm.getString("cgiServlet.runInvalidStatus", value));
return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
}
@@ -1856,7 +1731,7 @@ public final class CGIServlet extends Ht
statusCode = Integer.parseInt(status);
} catch (NumberFormatException nfe) {
// Not a valid status code
- log ("runCGI: invalid status code:" + status);
+ log.warn(sm.getString("cgiServlet.runInvalidStatus", status));
return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
}
@@ -1868,21 +1743,21 @@ public final class CGIServlet extends Ht
int lineCount = 0 ;
try {
while ((line = rdr.readLine()) != null) {
- log("runCGI (stderr):" + line) ;
+ log.warn(sm.getString("cgiServlet.runStdErr", line));
lineCount++ ;
}
} catch (IOException e) {
- log("sendToLog error", e) ;
+ log.warn(sm.getString("cgiServlet.runStdErrFail"), e);
} finally {
try {
- rdr.close() ;
- } catch (IOException ce) {
- log("sendToLog error", ce) ;
- } ;
- } ;
- if ( lineCount > 0 && debug > 2) {
- log("runCGI: " + lineCount + " lines received on stderr") ;
- } ;
+ rdr.close();
+ } catch (IOException e) {
+ log.warn(sm.getString("cgiServlet.runStdErrFail"), e);
+ }
+ }
+ if (lineCount > 0) {
+ log.warn(sm.getString("cgiServlet.runStdErrCount",
Integer.valueOf(lineCount)));
+ }
}
} //class CGIRunner
@@ -1891,14 +1766,14 @@ public final class CGIServlet extends Ht
* upto and including the two blank lines terminating the headers. It
* allows the content to be read using bytes or characters as appropriate.
*/
- protected class HTTPHeaderInputStream extends InputStream {
+ protected static class HTTPHeaderInputStream extends InputStream {
private static final int STATE_CHARACTER = 0;
private static final int STATE_FIRST_CR = 1;
private static final int STATE_FIRST_LF = 2;
private static final int STATE_SECOND_CR = 3;
private static final int STATE_HEADER_END = 4;
- private InputStream input;
+ private final InputStream input;
private int state;
HTTPHeaderInputStream(InputStream theInput) {
@@ -1909,6 +1784,7 @@ public final class CGIServlet extends Ht
/**
* @see java.io.InputStream#read()
*/
+ @Override
public int read() throws IOException {
if (state == STATE_HEADER_END) {
return -1;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]