@@ -112,9 +112,10 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
112112resp .sendError (HttpServletResponse .SC_BAD_REQUEST );
113113return ;
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}
119120String domain =req .getParameter (SimplePipeRequest .FORM_PIPE_DOMAIN );
120121doPipe (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 )
143144throws IOException {
144145PrintWriter writer =null ;
145146resp .setHeader ("Pragma" ,"no-cache" );
146147resp .setHeader ("Cache-Control" ,"no-cache" );
147148resp .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
160161writer .write ("\" );" );
161162return ;
162163}
163- if (SimplePipeRequest .PIPE_TYPE_SUBDOMAIN_QUERY . equals ( type ) ) {// subdomain query
164+ if (SimplePipeRequest .PIPE_TYPE_SUBDOMAIN_QUERY == type ) {// subdomain query
164165resp .setContentType ("text/html; charset=utf-8" );
165166writer =resp .getWriter ();
166167StringBuffer buffer =new StringBuffer ();
@@ -189,11 +190,11 @@ protected void doPipe(final HttpServletResponse resp, String key, String type, S
189190writer .write (buffer .toString ());
190191return ;
191192}
192- boolean isContinuum =SimplePipeRequest .PIPE_TYPE_CONTINUUM . equals ( type ) ;
193+ boolean isContinuum =SimplePipeRequest .PIPE_TYPE_CONTINUUM == type ;
193194if (isContinuum ) {
194195resp .setHeader ("Transfer-Encoding" ,"chunked" );
195196}
196- boolean isScripting =SimplePipeRequest .PIPE_TYPE_SCRIPT . equals ( type ) ;
197+ boolean isScripting =SimplePipeRequest .PIPE_TYPE_SCRIPT == type ;
197198if (isScripting ) {// iframe
198199resp .setContentType ("text/html; charset=utf-8" );
199200writer =resp .getWriter ();
@@ -211,8 +212,7 @@ protected void doPipe(final HttpServletResponse resp, String key, String type, S
211212writer .write (buffer .toString ());
212213writer .flush ();
213214}else {
214- if (SimplePipeRequest .PIPE_TYPE_QUERY .equals (type )
215- ||isContinuum ) {
215+ if (SimplePipeRequest .PIPE_TYPE_QUERY ==type ||isContinuum ) {
216216resp .setContentType ("text/plain; charset=utf-8" );
217217}else {
218218resp .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 ) {
350349StringBuffer 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
353352buffer .append ("<script type=\" text/javascript\" >$ (\" " );
354- }else if (SimplePipeRequest .PIPE_TYPE_XSS . equals ( type ) ) {
353+ }else if (SimplePipeRequest .PIPE_TYPE_XSS == type ) {
355354buffer .append ("$p1p3p$ (\" " );// $p1p3p$
356355}
357356buffer .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 ) {
360359str =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 ) {
363362str =str .replaceAll ("<\\ /script>" ,"<\\ /scr\" +\" ipt>" );
364363}
365364}
366365buffer .append (str );
367- if (SimplePipeRequest .PIPE_TYPE_SCRIPT . equals ( type ) ) {// iframe
366+ if (SimplePipeRequest .PIPE_TYPE_SCRIPT == type ) {// iframe
368367buffer .append ("\" );</script>\r \n " );
369- }else if (SimplePipeRequest .PIPE_TYPE_XSS . equals ( type ) ) {
368+ }else if (SimplePipeRequest .PIPE_TYPE_XSS == type ) {
370369buffer .append ("\" );\r \n " );
371370}
372371return buffer .toString ();