Tabnine Logo
StaticFileHandler
Code IndexAdd Tabnine to your IDE (free)

How to use
StaticFileHandler
in
cc.blynk.core.http.handlers

Best Java code snippets using cc.blynk.core.http.handlers.StaticFileHandler (Showing top 5 results out of 315)

origin: blynkkk/blynk-server

@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
  if (!(msg instanceof FullHttpRequest)) {
    return;
  }
  FullHttpRequest req = (FullHttpRequest) msg;
  StaticFile staticFile = getStaticPath(req.uri());
  if (staticFile != null) {
    try {
      serveStatic(ctx, req, staticFile);
    } finally {
      ReferenceCountUtil.release(req);
    }
    return;
  }
  ctx.fireChannelRead(req);
}
origin: blynkkk/blynk-server

/**
 * When file timestamp is the same as what the browser is sending up, send a "304 Not Modified"
 *
 * @param ctx
 *            Context
 */
private static void sendNotModified(ChannelHandlerContext ctx) {
  FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, NOT_MODIFIED);
  setDateHeader(response);
  // Close the connection as soon as the error message is sent.
  ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
}
origin: blynkkk/blynk-server

private void serveStatic(ChannelHandlerContext ctx, FullHttpRequest request, StaticFile staticFile)
    throws Exception {
  if (!request.decoderResult().isSuccess()) {
    sendError(ctx, BAD_REQUEST);
    return;
  String uri = request.uri();
  if (isNotSecure(uri)) {
    sendError(ctx, NOT_FOUND);
    return;
    sendError(ctx, NOT_FOUND);
    return;
    long fileLastModifiedSeconds = file.lastModified() / 1000;
    if (ifModifiedSinceDateSeconds == fileLastModifiedSeconds) {
      sendNotModified(ctx);
      return;
    raf = new RandomAccessFile(file, "r");
  } catch (FileNotFoundException ignore) {
    sendError(ctx, NOT_FOUND);
    return;
  setDateAndCacheHeaders(response, file);
  if (HttpUtil.isKeepAlive(request)) {
    response.headers().set(CONNECTION, HttpHeaderValues.KEEP_ALIVE);
origin: blynkkk/blynk-server

private void initAdminPipeline(ChannelHandlerContext ctx) {
  if (!ipFilterHandler.accept(ctx)) {
    ctx.close();
    return;
  }
  var pipeline = ctx.pipeline();
  pipeline.addLast(new UploadHandler(holder.props.jarPath, "/upload", "/static/ota"))
      .addLast(new OTAHandler(holder, rootPath + "/ota/start", "/static/ota"))
      .addLast(adminAuthHandler)
      .addLast(authCookieHandler)
      .addLast(cookieBasedUrlReWriterHandler);
  pipeline.remove(StaticFileHandler.class);
  pipeline.addLast(new StaticFileHandler(holder.props, new NoCacheStaticFile("/static")))
      .addLast(otaLogic)
      .addLast(usersLogic)
      .addLast(statsLogic)
      .addLast(configsLogic)
      .addLast(hardwareStatsLogic)
      .addLast(httpAPILogic)
      .addLast(noMatchHandler)
      .remove(this);
  if (log.isTraceEnabled()) {
    log.trace("Initialized admin pipeline. {}", ctx.pipeline().names());
  }
}
origin: blynkkk/blynk-server

private void initHttpPipeline(ChannelHandlerContext ctx) {
  ctx.pipeline()
      .addLast(letsEncryptHandler)
      .addLast("HttpChunkedWrite", new ChunkedWriteHandler())
      .addLast("HttpUrlMapper", new UrlReWriterHandler("/favicon.ico", "/static/favicon.ico"))
      .addLast("HttpStaticFile", new StaticFileHandler(holder.props, new StaticFile("/static"),
              new StaticFileEdsWith(FileUtils.CSV_DIR, ".gz"),
              new StaticFileEdsWith(FileUtils.CSV_DIR, ".zip")))
      .addLast(resetPasswordLogic)
      .addLast(httpAPILogic)
      .addLast(noMatchHandler)
      .remove(this);
  if (log.isTraceEnabled()) {
    log.trace("Initialized http pipeline. {}", ctx.pipeline().names());
  }
}
cc.blynk.core.http.handlersStaticFileHandler

Javadoc

The Blynk Project. Created by Dmitriy Dumanskiy. Created on 10.12.15.

Most used methods

  • <init>
  • getStaticPath
  • isNotSecure
  • sendError
  • sendNotModified
    When file timestamp is the same as what the browser is sending up, send a "304 Not Modified"
  • serveStatic
  • setDateAndCacheHeaders
    Sets the Date and Cache headers for the HTTP Response
  • setDateHeader
    Sets the Date header for the HTTP response

Popular in Java

  • Finding current android device location
  • setScale (BigDecimal)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • startActivity (Activity)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • JComboBox (javax.swing)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now