@@ -297,48 +297,44 @@ public void handle(final HttpExchange exchange) throws IOException {
297297
298298 // Process the deletion
299299 if (blobs .remove ("/" + account + toDelete ) != null ) {
300- response .append ("--" )
301- .append (responseBoundary )
302- .append ("\r \n " )
303- .append ("Content-Type: application/http\r \n " )
304- .append ("Content-ID: " )
305- .append (contentId )
306- .append ("\r \n \r \n " )
307- .append ("HTTP/1.1 202 Accepted\r \n " )
308- .append ("x-ms-delete-type-permanent: true\r \n " )
309- .append ("x-ms-request-id: " )
310- .append (requestId )
311- .append ("\r \n " )
312- .append ("x-ms-version: 2018-11-09\r \n \r \n " );
300+ final String acceptedPart = Strings .format ("""
301+ --%s
302+ Content-Type: application/http
303+ Content-ID: %s
304+
305+ HTTP/1.1 202 Accepted
306+ x-ms-delete-type-permanent: true
307+ x-ms-request-id: %s
308+ x-ms-version: 2018-11-09
309+
310+ """ , responseBoundary , contentId , requestId ).replaceAll ("\n " , "\r \n " );
311+ response .append (acceptedPart );
313312 } else {
314- String notFoundResponse = Strings .format (
313+ final String notFoundBody = Strings .format (
315314 """
316- <?xml version="1.0" encoding="utf-8"?>\r
317- <Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.\r
318- RequestId:%s\r
315+ <?xml version="1.0" encoding="utf-8"?>
316+ <Error><Code>BlobNotFound</Code><Message>The specified blob does not exist.
317+ RequestId:%s
319318 Time:%s</Message></Error>""" ,
320319 requestId ,
321320 DateTimeFormatter .ISO_DATE_TIME .format (ZonedDateTime .now (ZoneId .of ("UTC" )))
322321 );
323- response .append ("--" )
324- .append (responseBoundary )
325- .append ("\r \n " )
326- .append ("Content-Type: application/http\r \n " )
327- .append ("Content-ID: " )
328- .append (contentId )
329- .append ("\r \n \r \n " )
330- .append ("HTTP/1.1 404 The specified blob does not exist.\r \n " )
331- .append ("x-ms-error-code: BlobNotFound\r \n " )
332- .append ("x-ms-request-id: " )
333- .append (requestId )
334- .append ("\r \n " )
335- .append ("x-ms-version: 2018-11-09\r \n " )
336- .append ("Content-Length: " )
337- .append (notFoundResponse .length ())
338- .append ("\r \n " )
339- .append ("Content-Type: application/xml\r \n \r \n " )
340- .append (notFoundResponse )
341- .append ("\r \n " );
322+ final String notFoundPart = Strings .format ("""
323+ --%s
324+ Content-Type: application/http
325+ Content-ID: %s
326+
327+ HTTP/1.1 404 The specified blob does not exist.
328+ x-ms-error-code: BlobNotFound
329+ x-ms-request-id: %s
330+ x-ms-version: 2018-11-09
331+ Content-Length: %d
332+ Content-Type: application/xml
333+
334+ %s
335+ """ , responseBoundary , contentId , requestId , notFoundBody .length (), notFoundBody )
336+ .replaceAll ("\n " , "\r \n " );
337+ response .append (notFoundPart );
342338 }
343339
344340 // Clear the state
0 commit comments