@@ -112,9 +112,10 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
112112 resp .sendError (HttpServletResponse .SC_BAD_REQUEST );
113113 return ;
114114 }
115- String type = req .getParameter (SimplePipeRequest .FORM_PIPE_TYPE );
116- if (type == null ) {
117- type = SimplePipeRequest .PIPE_TYPE_CONTINUUM ;
115+ char type = SimplePipeRequest .PIPE_TYPE_CONTINUUM ;
116+ String typeStr = req .getParameter (SimplePipeRequest .FORM_PIPE_TYPE );
117+ if (typeStr != null && typeStr .length () > 0 ) {
118+ type = typeStr .charAt (0 );
118119 }
119120 String domain = req .getParameter (SimplePipeRequest .FORM_PIPE_DOMAIN );
120121 doPipe (resp , key , type , domain );
@@ -139,14 +140,14 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
139140 * type = notify
140141 * Notify that client (browser) still keeps the pipe connection.
141142 */
142- protected void doPipe (final HttpServletResponse resp , String key , String type , String domain )
143+ protected void doPipe (final HttpServletResponse resp , String key , char type , String domain )
143144 throws IOException {
144145 PrintWriter writer = null ;
145146 resp .setHeader ("Pragma" , "no-cache" );
146147 resp .setHeader ("Cache-Control" , "no-cache" );
147148 resp .setDateHeader ("Expires" , 0 );
148149
149- if (SimplePipeRequest .PIPE_TYPE_NOTIFY . equals ( type ) ) {
150+ if (SimplePipeRequest .PIPE_TYPE_NOTIFY == type ) {
150151 /*
151152 * Client send in "notify" request to execute #notifyPipeStatus, see below comments
152153 */
@@ -160,7 +161,7 @@ protected void doPipe(final HttpServletResponse resp, String key, String type, S
160161 writer .write ("\" );" );
161162 return ;
162163 }
163- if (SimplePipeRequest .PIPE_TYPE_SUBDOMAIN_QUERY . equals ( type ) ) { // subdomain query
164+ if (SimplePipeRequest .PIPE_TYPE_SUBDOMAIN_QUERY == type ) { // subdomain query
164165 resp .setContentType ("text/html; charset=utf-8" );
165166 writer = resp .getWriter ();
166167 StringBuffer buffer = new StringBuffer ();
@@ -189,11 +190,11 @@ protected void doPipe(final HttpServletResponse resp, String key, String type, S
189190 writer .write (buffer .toString ());
190191 return ;
191192 }
192- boolean isContinuum = SimplePipeRequest .PIPE_TYPE_CONTINUUM . equals ( type ) ;
193+ boolean isContinuum = SimplePipeRequest .PIPE_TYPE_CONTINUUM == type ;
193194 if (isContinuum ) {
194195 resp .setHeader ("Transfer-Encoding" , "chunked" );
195196 }
196- boolean isScripting = SimplePipeRequest .PIPE_TYPE_SCRIPT . equals ( type ) ;
197+ boolean isScripting = SimplePipeRequest .PIPE_TYPE_SCRIPT == type ;
197198 if (isScripting ) { // iframe
198199 resp .setContentType ("text/html; charset=utf-8" );
199200 writer = resp .getWriter ();
@@ -211,8 +212,7 @@ protected void doPipe(final HttpServletResponse resp, String key, String type, S
211212 writer .write (buffer .toString ());
212213 writer .flush ();
213214 } else {
214- if (SimplePipeRequest .PIPE_TYPE_QUERY .equals (type )
215- || isContinuum ) {
215+ if (SimplePipeRequest .PIPE_TYPE_QUERY == type || isContinuum ) {
216216 resp .setContentType ("text/plain; charset=utf-8" );
217217 } else {
218218 resp .setContentType ("text/javascript; charset=utf-8" );
@@ -345,28 +345,27 @@ protected void doPipe(final HttpServletResponse resp, String key, String type, S
345345 }
346346 }
347347
348- protected static String output (String type , String key ,
349- String str ) {
348+ protected static String output (char type , String key , String str ) {
350349 StringBuffer buffer = new StringBuffer ();
351- if (SimplePipeRequest .PIPE_TYPE_SCRIPT . equals ( type ) ) {
350+ if (SimplePipeRequest .PIPE_TYPE_SCRIPT == type ) {
352351 // iframe, so $ is a safe method identifier
353352 buffer .append ("<script type=\" text/javascript\" >$ (\" " );
354- } else if (SimplePipeRequest .PIPE_TYPE_XSS . equals ( type ) ) {
353+ } else if (SimplePipeRequest .PIPE_TYPE_XSS == type ) {
355354 buffer .append ("$p1p3p$ (\" " ); // $p1p3p$
356355 }
357356 buffer .append (key );
358- if (SimplePipeRequest .PIPE_TYPE_SCRIPT . equals ( type )
359- || SimplePipeRequest .PIPE_TYPE_XSS . equals ( type ) ) {
357+ if (SimplePipeRequest .PIPE_TYPE_SCRIPT == type
358+ || SimplePipeRequest .PIPE_TYPE_XSS == type ) {
360359 str = str .replaceAll ("\\ \\ " , "\\ \\ \\ \\ " ).replaceAll ("\r " , "\\ \\ r" )
361360 .replaceAll ("\n " , "\\ \\ n" ).replaceAll ("\" " , "\\ \\ \" " );
362- if (SimplePipeRequest .PIPE_TYPE_SCRIPT . equals ( type ) ) {
361+ if (SimplePipeRequest .PIPE_TYPE_SCRIPT == type ) {
363362 str = str .replaceAll ("<\\ /script>" , "<\\ /scr\" + \" ipt>" );
364363 }
365364 }
366365 buffer .append (str );
367- if (SimplePipeRequest .PIPE_TYPE_SCRIPT . equals ( type ) ) { // iframe
366+ if (SimplePipeRequest .PIPE_TYPE_SCRIPT == type ) { // iframe
368367 buffer .append ("\" );</script>\r \n " );
369- } else if (SimplePipeRequest .PIPE_TYPE_XSS . equals ( type ) ) {
368+ } else if (SimplePipeRequest .PIPE_TYPE_XSS == type ) {
370369 buffer .append ("\" );\r \n " );
371370 }
372371 return buffer .toString ();
0 commit comments