gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-15 09:20:49 24 4
gpt4 key购买 nike

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

YokeResponse.setStatusCode介绍

暂无

代码示例

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

@Override
public void setResponseStatus(int code) {
  response.setStatusCode(code);
}

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

@Override
 public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
  request.response().setStatusCode(400).end("Can \"Upgrade\" only to \"WebSocket\".");
 }
});

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

@Override
  public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
    if (dt - 500 * 1000000 > highWaterMark) {
      final YokeResponse response = request.response();

      response.setStatusCode(503);
      response.setStatusMessage(message);
      response.end();
    } else {
      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

/**
 * 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) {
  if (log.isTraceEnabled()) log.trace("WS, all: " + request.uri());
  request.response().putHeader("Allow", "GET").setStatusCode(405).end();
 }
});

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

private void handlePreflightRequest(final YokeRequest request)
{
  if (isValidOrigin(request.getHeader(ORIGIN)))
  {
    addCorsResponseHeaders(request.getHeader(ORIGIN),
      request.response().setStatusCode(204).setStatusMessage("No Content")).end();
  }
  else
  {
    request.response().setStatusCode(403).setStatusMessage("CORS Rejected").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

@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 redirect(int status, String url) {
  setStatusCode(status);
  setStatusMessage(HttpResponseStatus.valueOf(status).reasonPhrase());
  putHeader("location", url);
  end();
}

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

urlEncoded = false;
} else {
 rc.response().setStatusCode(500);
 rc.response().end("Invalid Content-Type");
 return;
 rc.response().setStatusCode(500).end("Payload expected.");
 return;

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

@Override
  public void handle(JsonObject user) {
    if (user != null) {
      JsonObject session = request.createSession();
      session.put("user", request.getFormAttribute("username"));
      // get the redirect_url parameter
      String redirect = request.getParam("redirect_url", "/");
      request.response().redirect(Utils.decodeURIComponent(redirect));
    } else {
      if (loginTemplate != null) {
        // render internal login
        request.response().setContentType("text/html");
        request.response().setStatusCode(401);
        request.response().end(
            loginTemplate.replace("{title}", (String) request.get("title"))
                .replace("{action}", loginURI + "?redirect_url=" + Utils.encodeURIComponent(request.getParam("redirect_url", "/")))
                .replace("{message}", "Invalid username and/or password, please try again."));
      } else {
        next.handle(401);
      }
    }
  }
});

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

@Override
  public void handle(Object error) {
    if (error != null) {
      int errorCode;
      // if the error was set on the response use it
      if (getStatusCode() >= 400) {
        errorCode = getStatusCode();
      } else {
        // if it was set as the error object use it
        if (error instanceof Number) {
          errorCode = ((Number) error).intValue();
        } else if (error instanceof YokeException) {
          errorCode = ((YokeException) error).getErrorCode().intValue();
        } else {
          // default error code
          errorCode = 500;
        }
      }
      setStatusCode(errorCode);
      setStatusMessage(HttpResponseStatus.valueOf(errorCode).reasonPhrase());
      end(HttpResponseStatus.valueOf(errorCode).reasonPhrase());
    }
  }
});

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

String connectionHeader = request.headers().get(io.vertx.core.http.HttpHeaders.CONNECTION);
 if (connectionHeader == null || !connectionHeader.toLowerCase().contains("upgrade")) {
  request.response().setStatusCode(400);
  request.response().end("Can \"Upgrade\" only to \"WebSocket\".");
 } else {
 request.response().setStatusCode(400);
 request.response().end("Can \"Upgrade\" only to \"WebSocket\".");
});

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

public XhrTransport(Vertx vertx, Router router, LocalMap<String, SockJSSession> sessions, SockJSHandlerOptions options,
       Handler<SockJSSocket> sockHandler) {
 super(vertx, sessions, options);
 String xhrBase = COMMON_PATH_ELEMENT_RE;
 String xhrRE = xhrBase + "xhr";
 String xhrStreamRE = xhrBase + "xhr_streaming";
 Middleware xhrOptionsHandler = createCORSOptionsHandler(options, "OPTIONS, POST");
 router.options(Pattern.compile(xhrRE), xhrOptionsHandler);
 router.options(Pattern.compile(xhrStreamRE), xhrOptionsHandler);
 registerHandler(router, sockHandler, xhrRE, false, options);
 registerHandler(router, sockHandler, xhrStreamRE, true, options);
 String xhrSendRE = COMMON_PATH_ELEMENT_RE + "xhr_send";
 router.options(Pattern.compile(xhrSendRE), xhrOptionsHandler);
 router.post(Pattern.compile(xhrSendRE), (request, next) -> {
  if (log.isTraceEnabled()) log.trace("XHR send, post, " + request.uri());
  String sessionID = request.getParam("param0");
  final SockJSSession session = sessions.get(sessionID);
  if (session != null && !session.isClosed()) {
   handleSend(request, session);
  } else {
   request.response().setStatusCode(404);
   setJSESSIONID(options, request);
   request.response().end();
  }
 });
}

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

private void handleSend(YokeRequest rc, SockJSSession session) {
 rc.bodyHandler(buff -> {
  String msgs = buff.toString();
  if (msgs.equals("")) {
   rc.response().setStatusCode(500);
   rc.response().end("Payload expected.");
   return;
  }
  if (!session.handleMessages(msgs)) {
   sendInvalidJSON(rc.response());
  } else {
   rc.response().putHeader("Content-Type", "text/plain; charset=UTF-8");
   setNoCacheHeaders(rc);
   setJSESSIONID(options, rc);
   setCORS(rc);
   rc.response().setStatusCode(204);
   rc.response().end();
  }
  if (log.isTraceEnabled()) log.trace("XHR send processed ok");
 });
}

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

public void handle(HttpClientResponse cRes) {
  req.response().setStatusCode(cRes.statusCode());
  req.response().headers().setAll(cRes.headers());
  req.response().setChunked(true);
  cRes.handler(new Handler<Buffer>() {
   public void handle(Buffer data) {
    req.response().write(data);
   }
  });
  cRes.endHandler(new VoidHandler() {
   public void handle() {
    req.response().end();
   }
  });
  cRes.exceptionHandler(new Handler<Throwable>() {
   public void handle(Throwable t) {
    next.handle(t);
   }
  });
 }
});

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

response.setStatusCode(getErrorCode(request.get("error")));

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

callback = request.getParam("c");
 if (callback == null) {
  request.response().setStatusCode(500);
  request.response().end("\"callback\" parameter required\n");
  return;
 handleSend(request, session);
} else {
 request.response().setStatusCode(404);
 setJSESSIONID(options, request);
 request.response().end();

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

public HtmlFileTransport(Vertx vertx, Router router, LocalMap<String, SockJSSession> sessions, SockJSHandlerOptions options,
         Handler<SockJSSocket> sockHandler) {
 super(vertx, sessions, options);
 String htmlFileRE = COMMON_PATH_ELEMENT_RE + "htmlfile.*";
 router.get(Pattern.compile(htmlFileRE), (request, next) -> {
  if (log.isTraceEnabled()) log.trace("HtmlFile, get: " + request.uri());
  String callback = request.getParam("callback");
  if (callback == null) {
   callback = request.getParam("c");
   if (callback == null) {
    request.response().setStatusCode(500).end("\"callback\" parameter required\n");
    return;
   }
  }
  String sessionID = request.params().get("param0");
  SockJSSession session = getSession(request, options.getSessionTimeout(), options.getHeartbeatInterval(), sessionID, sockHandler);
  session.setInfo(request.localAddress(), request.remoteAddress(), request.uri(), request.headers());
  session.register(new HtmlFileListener(options.getMaxBytesStreaming(), request, callback, session));
 });
}

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