public static boolean sendRequestedBlobs ( HttpServerExchange exchange ) { ByteBuffer buffer = null ; String type = null ; String etag = null ; String quotedEtag = null ; if ( "css" . equals ( exchange . getQueryString ( ) ) ) { buffer = Blobs . FILE_CSS_BUFFER . duplicate ( ) ; type = "text/css" ; etag = Blobs . FILE_CSS_ETAG ; quotedEtag = Blobs . FILE_CSS_ETAG_QUOTED ; } else if ( "js" . equals ( exchange . getQueryString ( ) ) ) { buffer = Blobs . FILE_JS_BUFFER . duplicate ( ) ; type = "application/javascript" ; etag = Blobs . FILE_JS_ETAG ; quotedEtag = Blobs . FILE_JS_ETAG_QUOTED ; } if ( buffer != null ) { if ( ! ETagUtils . handleIfNoneMatch ( exchange , new ETag ( false , etag ) , false ) ) { exchange . setStatusCode ( StatusCodes . NOT_MODIFIED ) ; return true ; } exchange . getResponseHeaders ( ) . put ( Headers . CONTENT_LENGTH , String . valueOf ( buffer . limit ( ) ) ) ; exchange . getResponseHeaders ( ) . put ( Headers . CONTENT_TYPE , type ) ; exchange . getResponseHeaders ( ) . put ( Headers . ETAG , quotedEtag ) ; if ( Methods . HEAD . equals ( exchange . getRequestMethod ( ) ) ) { exchange . endExchange ( ) ; return true ; } exchange . getResponseSender ( ) . send ( buffer ) ; return true ; } return false ; }
Serve static resource for the directory listing