@@ -119,6 +119,15 @@ public class LocalDnsHelper {
119119 private static final ScheduledExecutorService EXECUTORS =
120120 Executors .newScheduledThreadPool (2 , Executors .defaultThreadFactory ());
121121 private static final String PROJECT_ID = "dummyprojectid" ;
122+ private static final String responseBoundary = "____THIS_IS_HELPERS_BOUNDARY____" ;
123+ private static final String responseSeparator = new StringBuilder ("--" )
124+ .append (responseBoundary )
125+ .append ("\r \n " )
126+ .toString ();
127+ private static final String responseEnd = new StringBuilder ("--" )
128+ .append (responseBoundary )
129+ .append ("--\r \n \r \n " )
130+ .toString ();
122131
123132 static {
124133 try {
@@ -356,15 +365,6 @@ private Response handleBatch(final HttpExchange exchange) throws IOException {
356365 String contentType = exchange .getRequestHeaders ().getFirst ("Content-type" );
357366 if (contentType != null ) {
358367 int port = server .getAddress ().getPort ();
359- String responseBoundary = "____THIS_IS_HELPERS_BOUNDARY____" ;
360- String responseSeparator = new StringBuilder ("--" )
361- .append (responseBoundary )
362- .append ("\r \n " )
363- .toString ();
364- String responseEnd = new StringBuilder ("--" )
365- .append (responseBoundary )
366- .append ("--\r \n \r \n " )
367- .toString ();
368368 HttpMediaType httpMediaType = new HttpMediaType (contentType );
369369 String boundary = httpMediaType .getParameter ("boundary" );
370370 MultipartStream multipartStream =
@@ -412,7 +412,7 @@ private Response handleBatch(final HttpExchange exchange) throws IOException {
412412 }
413413 }
414414 out .write (responseEnd .getBytes ());
415- writeBatchResponse (exchange , out , responseBoundary );
415+ writeBatchResponse (exchange , out );
416416 }
417417 return null ;
418418 }
@@ -520,11 +520,10 @@ private static void writeResponse(HttpExchange exchange, Response response) {
520520 }
521521 }
522522
523- private static void writeBatchResponse (HttpExchange exchange , ByteArrayOutputStream out ,
524- String boundary ) {
525- exchange . getResponseHeaders (). set ( "Content-type" , "multipart/mixed; boundary=" + boundary );
523+ private static void writeBatchResponse (HttpExchange exchange , ByteArrayOutputStream out ) {
524+ exchange . getResponseHeaders (). set (
525+ "Content-type" , "multipart/mixed; boundary=" + responseBoundary );
526526 try {
527- exchange .getResponseHeaders ().add ("Connection" , "close" );
528527 exchange .getResponseHeaders ().add ("Connection" , "close" );
529528 exchange .sendResponseHeaders (200 , out .toByteArray ().length );
530529 OutputStream responseBody = exchange .getResponseBody ();
0 commit comments