@Override
  public void service(RequestWeb req)
  {
    init();
    
    String pathInfo = req.pathInfo();
    
    if (pathInfo.isEmpty() || pathInfo.equals("/")) {
      pathInfo = _config.get("server.index", "index.html");
    } else {
      pathInfo = pathInfo.substring(1);
    }

    Path path = _root.resolve(pathInfo);
    //PathImpl path = Vfs.lookup(root).lookup("./" + pathInfo);
    
    if (Files.isDirectory(path)) {
      path = path.resolve(_config.get("server.index", "index.html"));
    }
    
    long len;
    
    try {
      len = Files.size(path);
    } catch (IOException e) {
      
      req.fail(new FileNotFoundException("file not found: " + req.uri()));
      return;
    }
    
    try (InputStream is = Files.newInputStream(path)) {
      if (is == null) {
        req.fail(new FileNotFoundException(pathInfo));
        return;
      }

      String mimeType = mimeType(pathInfo);
      
      if (mimeType != null) {
        req.header("content-type", mimeType);
      }
      else {
        req.header("content-type", "text/plain; charset=utf-8");
      }
      
      // XXX:
      if (len > 0) {
        req.length(len);
      }
      
      TempBuffer tBuf = TempBuffer.create();
      byte []buffer = tBuf.buffer();
      
      int sublen;
      
      while ((sublen = is.read(buffer, 0, buffer.length)) > 0) {
        req.write(buffer, 0, sublen);
      }
      
      tBuf.free();
    } catch (IOException e) {
      req.fail(e);
    }
    
    req.ok();
  }
@ Override public void service ( RequestWeb req ) { init ( ) ; String pathInfo = req . pathInfo ( ) ; if ( pathInfo . isEmpty ( ) || pathInfo . equals ( "/" ) ) { pathInfo = _config . get ( "server.index" , "index.html" ) ; } else { pathInfo = pathInfo . substring ( 1 ) ; } Path path = _root . resolve ( pathInfo ) ; if ( Files . isDirectory ( path ) ) { path = path . resolve ( _config . get ( "server.index" , "index.html" ) ) ; } long len ; try { len = Files . size ( path ) ; } catch ( IOException e ) { req . fail ( new FileNotFoundException ( "file not found: " + req . uri ( ) ) ) ; return ; } try ( InputStream is = Files . newInputStream ( path ) ) { if ( is == null ) { req . fail ( new FileNotFoundException ( pathInfo ) ) ; return ; } String mimeType = mimeType ( pathInfo ) ; if ( mimeType != null ) { req . header ( "content-type" , mimeType ) ; } else { req . header ( "content-type" , "text/plain; charset=utf-8" ) ; } if ( len > 0 ) { req . length ( len ) ; } TempBuffer tBuf = TempBuffer . create ( ) ; byte [ ] buffer = tBuf . buffer ( ) ; int sublen ; while ( ( sublen = is . read ( buffer , 0 , buffer . length ) ) > 0 ) { req . write ( buffer , 0 , sublen ) ; } tBuf . free ( ) ; } catch ( IOException e ) { req . fail ( e ) ; } req . ok ( ) ; }
Service a request.

@param request the http request facade
@param response the http response facade