gpt4 book ai didi

com.jetdrone.vertx.yoke.middleware.YokeResponse.putHeader()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 08:50:49 26 4
gpt4 key购买 nike

本文整理了Java中com.jetdrone.vertx.yoke.middleware.YokeResponse.putHeader()方法的一些代码示例,展示了YokeResponse.putHeader()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YokeResponse.putHeader()方法的具体详情如下:
包路径:com.jetdrone.vertx.yoke.middleware.YokeResponse
类名称:YokeResponse
方法名:putHeader

YokeResponse.putHeader介绍

暂无

代码示例

代码示例来源:origin: pmlopes/yoke

public YokeResponse setContentType(String contentType, String contentEncoding) {
  if (contentEncoding == null) {
    putHeader("content-type", contentType);
  } else {
    putHeader("content-type", contentType + ";charset=" + contentEncoding);
  }
  return this;
}

代码示例来源:origin: pmlopes/yoke

@Override
  public void handle(Void event) {
    long duration = System.currentTimeMillis() - start;
    response.putHeader("x-response-time", duration + "ms");
  }
});

代码示例来源:origin: pmlopes/yoke

@Override
  public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
    request.response().putHeader("Cache-Control", "no-store, no-cache");
    next.handle(null);
  }
}

代码示例来源:origin: pmlopes/yoke

@Override
  public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
    request.response().putHeader("X-Download-Options", "noopen");
    next.handle(null);
  }
}

代码示例来源:origin: pmlopes/yoke

@Override
  public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
    request.response().putHeader("X-FRAME-OPTIONS", header);
    next.handle(null);
  }
}

代码示例来源:origin: pmlopes/yoke

@Override
  public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
    request.response().putHeader("X-Content-Type-Options", "nosniff");
    next.handle(null);
  }
}

代码示例来源:origin: pmlopes/yoke

static void setNoCacheHeaders(YokeRequest rc) {
 rc.response().putHeader("Cache-Control", "no-store, no-cache, must-revalidate, max-age=0");
}

代码示例来源:origin: pmlopes/yoke

@Override
  public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
    if ("/crossdomain.xml".equals(request.path())) {
      request.response().putHeader("Content-Type", "text/x-cross-domain-policy");
      request.response().end(DATA);
    } else {
      next.handle(null);
    }
  }
}

代码示例来源:origin: pmlopes/yoke

@Override
  public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
    boolean isSecure = (request.isSSL())
        || ("on".equals(request.getHeader("front-end-https")))
        || ("https".equals(request.getHeader("x-forwarded-proto")));

    if (isSecure) {
      request.response().putHeader("Strict-Transport-Security", header);
    }

    next.handle(null);
  }
}

代码示例来源:origin: pmlopes/yoke

@Override
 public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
  request.response().putHeader("Allow", "GET").setStatusCode(405).end();
 }
});

代码示例来源:origin: pmlopes/yoke

@Override
 public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
  if (log.isTraceEnabled()) log.trace("In CORS options handler");
  request.response().putHeader("Cache-Control", "public,max-age=31536000");
  long oneYearSeconds = 365 * 24 * 60 * 60;
  long oneYearms = oneYearSeconds * 1000;
  String expires = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz").format(new Date(System.currentTimeMillis() + oneYearms));
  request.response().putHeader("Expires", expires)
    .putHeader("Access-Control-Allow-Methods", methods)
    .putHeader("Access-Control-Max-Age", String.valueOf(oneYearSeconds));
  setCORS(request);
  setJSESSIONID(options, request);
  request.response().setStatusCode(204);
  request.response().end();
 }
};

代码示例来源:origin: pmlopes/yoke

/**
 * Handle all forbidden errors, in this case we need to add a special header to the response
 *
 * @param request yoke request
 * @param next middleware to be called next
 */
private void handle401(final YokeRequest request, final Handler<Object> next) {
  YokeResponse response = request.response();
  response.putHeader("WWW-Authenticate", "Basic realm=\"" + getRealm(request) + "\"");
  response.setStatusCode(401);
  next.handle("No authorization token");
}

代码示例来源:origin: pmlopes/yoke

@Override
 public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
  try {
   if (log.isTraceEnabled()) log.trace("In Iframe handler");
   if (etag != null && etag.equals(request.getHeader("if-none-match"))) {
    request.response().setStatusCode(304);
    request.response().end();
   } else {
    long oneYear = 365 * 24 * 60 * 60 * 1000L;
    String expires = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz").format(new Date(System.currentTimeMillis() + oneYear));
    request.response().putHeader("Content-Type", "text/html; charset=UTF-8")
      .putHeader("Cache-Control", "public,max-age=31536000")
      .putHeader("Expires", expires).putHeader("ETag", etag).end(iframeHTML);
   }
  } catch (Exception e) {
   log.error("Failed to server iframe", e);
  }
 }
};

代码示例来源:origin: pmlopes/yoke

public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
  if (log.isTraceEnabled()) log.trace("In Info handler");
  request.response().putHeader("Content-Type", "application/json; charset=UTF-8");
  setNoCacheHeaders(request);
  JsonObject json = new JsonObject();
  json.put("websocket", websocket);
  json.put("cookie_needed", options.isInsertJSESSIONID());
  json.put("origins", new JsonArray().add("*:*"));
  // Java ints are signed, so we need to use a long and add the offset so
  // the result is not negative
  json.put("entropy", RAND_OFFSET + new Random().nextInt());
  setCORS(request);
  request.response().end(json.encode());
 }
};

代码示例来源:origin: pmlopes/yoke

@Override
  public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
    final WebClient webClient = WebClient.detect(request.getHeader("user-agent"));

    boolean isIE = webClient.getUserAgent() == WebClient.UserAgent.IE;
    int majorVersion = webClient.getMajorVersion();

    String value;

    if ((!isIE) || (majorVersion >= 9) || (setOnOldIE)) {
      value = "1; mode=block";
    } else {
      value = "0";
    }

    request.response().putHeader("X-XSS-Protection", value);
    next.handle(null);
  }
}

代码示例来源:origin: pmlopes/yoke

@Override
 public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
  if (log.isTraceEnabled()) log.trace("WS, all: " + request.uri());
  request.response().putHeader("Allow", "GET").setStatusCode(405).end();
 }
});

代码示例来源:origin: pmlopes/yoke

public void sendFrame(String body) {
 if (log.isTraceEnabled()) log.trace("JsonP, sending frame");
 if (!headersWritten) {
  rc.response().setChunked(true).putHeader("Content-Type", "application/javascript; charset=UTF-8");
  setNoCacheHeaders(rc);
  setJSESSIONID(options, rc);
  headersWritten = true;
 }
 body = escapeForJavaScript(body);
 StringBuilder sb = new StringBuilder();
 sb.append(callback).append("(\"");
 sb.append(body);
 sb.append("\");\r\n");
 //End the response and close the HTTP connection
 rc.response().write(sb.toString());
 close();
}

代码示例来源:origin: pmlopes/yoke

public void redirect(int status, String url) {
  setStatusCode(status);
  setStatusMessage(HttpResponseStatus.valueOf(status).reasonPhrase());
  putHeader("location", url);
  end();
}

代码示例来源:origin: pmlopes/yoke

public void sendFrame(String body) {
 if (log.isTraceEnabled()) log.trace("XHR sending frame");
 if (!headersWritten) {
  rc.response().putHeader("Content-Type", "application/javascript; charset=UTF-8");
  setJSESSIONID(options, rc);
  setCORS(rc);
  rc.response().setChunked(true);
  headersWritten = true;
 }
}

代码示例来源:origin: pmlopes/yoke

/**
 * Write a file into the response body
 *
 * @param request
 * @param file
 * @param props
 */
private void sendFile(final YokeRequest request, final String file, final FileProps props) {
  // write content type
  String contentType = MimeType.getMime(file);
  String charset = MimeType.getCharset(contentType);
  request.response().setContentType(contentType, charset);
  request.response().putHeader("Content-Length", Long.toString(props.size()));
  // head support
  if (HttpMethod.HEAD.equals(request.method())) {
    request.response().end();
  } else {
    request.response().sendFile(file);
  }
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com