ro.pippo.core.Response.getStatus()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(190)

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

Response.getStatus介绍

[英]Gets the status code of the response.
[中]获取响应的状态代码。

代码示例

代码示例来源:origin: pippo-java/pippo

protected void updateStatusCodeMetrics(Response response) {
  allRequestsMeter.mark();
  switch (response.getStatus()) {
    case HttpConstants.StatusCode.BAD_REQUEST:
      badRequests.mark();
      break;
    case HttpConstants.StatusCode.UNAUTHORIZED:
      unauthorizedRequests.mark();
      break;
    case HttpConstants.StatusCode.FORBIDDEN:
      forbiddenRequests.mark();
      break;
    case HttpConstants.StatusCode.NOT_FOUND:
      routesNotFound.mark();
      break;
    case HttpConstants.StatusCode.CONFLICT:
      conflictRequests.mark();
      break;
    case HttpConstants.StatusCode.INTERNAL_ERROR:
      internalServerErrors.mark();
      break;
    default:
      break;
  }
}

代码示例来源:origin: pippo-java/pippo

private void finalizeResponse() {
  // add headers
  for (Map.Entry<String, String> header : getHeaderMap().entrySet()) {
    httpServletResponse.setHeader(header.getKey(), header.getValue());
  }
  // add cookies
  for (Cookie cookie : getCookies()) {
    httpServletResponse.addCookie(cookie);
  }
  // set status to OK if it's not set
  if (getStatus() == 0 || getStatus() == Integer.MAX_VALUE) {
    ok();
  }
  // call finalize listeners
  if ((finalizeListeners != null) && !finalizeListeners.isEmpty()) {
    finalizeListeners.onFinalize(this);
  }
}

代码示例来源:origin: pippo-java/pippo

errorHandler.handle(HttpServletResponse.SC_NOT_FOUND, routeContext);
  ROUTE_CONTEXT_THREAD_LOCAL.remove();
  log.debug("Returned status code {} for {} '{}' (IGNORED)", response.getStatus(), requestMethod, requestPath);
    if (response.getStatus() == 0) {
      log.debug("Status code not set for {} '{}'", requestMethod, requestPath);
      response.notFound();
    if (response.getStatus() >= HttpServletResponse.SC_BAD_REQUEST) {
      errorHandler.handle(response.getStatus(), routeContext);
    } else {
      response.commit();
} finally {
  routeContext.runFinallyRoutes();
  log.debug("Returned status code {} for {} '{}'", response.getStatus(), requestMethod, requestPath);
  ROUTE_CONTEXT_THREAD_LOCAL.remove();

代码示例来源:origin: pippo-java/pippo

protected void streamResource(URL resourceUrl, RouteContext routeContext) {
  try {
    long lastModified = resourceUrl.openConnection().getLastModified();
    routeContext.getApplication().getHttpCacheToolkit().addEtag(routeContext, lastModified);
    if (routeContext.getResponse().getStatus() == HttpConstants.StatusCode.NOT_MODIFIED) {
      // do not stream anything out, simply return 304
      routeContext.getResponse().commit();
    } else {
      sendResource(resourceUrl, routeContext);
    }
  } catch (Exception e) {
    throw new PippoRuntimeException(e, "Failed to stream resource {}", resourceUrl);
  }
}

代码示例来源:origin: pippo-java/pippo

protected void streamResource(URL resourceUrl, RouteContext routeContext) {
  try {
    setResponseHeaders(resourceUrl, routeContext);
    if (routeContext.getResponse().getStatus() == HttpConstants.StatusCode.NOT_MODIFIED) {
      // do not stream anything out, simply return 304
      routeContext.getResponse().commit();
    } else {
      sendResource(resourceUrl, routeContext);
    }
  } catch (IOException e) {
    String message = e.getMessage();
    if (!StringUtils.isNullOrEmpty(message)) {
      log.warn("Error sending resource {} to {}: {}",
        resourceUrl, routeContext.getRequest().getClientIp(), message);
    } else {
      throw new PippoRuntimeException(e, "Failed to stream resource {}", resourceUrl);
    }
  } catch (Exception e) {
    throw new PippoRuntimeException(e, "Failed to stream resource {}", resourceUrl);
  }
}

代码示例来源:origin: pippo-java/pippo

int preInterceptStatus = routeContext.getResponse().getStatus();
processRouteInterceptors(routeContext);
int postInterceptStatus = routeContext.getResponse().getStatus();
if (routeContext.getResponse().isCommitted()) {
  log.debug("Response committed by interceptor");
} else if (preInterceptStatus != postInterceptStatus && postInterceptStatus >= 300) {
  log.debug("Interceptor set status code to {}, committing response",
      routeContext.getResponse().getStatus());
  routeContext.getResponse().commit();
  routeContext.next();

代码示例来源:origin: ro.pippo/pippo-metrics

protected void updateStatusCodeMetrics(Response response) {
  allRequestsMeter.mark();
  switch (response.getStatus()) {
    case HttpConstants.StatusCode.BAD_REQUEST:
      badRequests.mark();
      break;
    case HttpConstants.StatusCode.UNAUTHORIZED:
      unauthorizedRequests.mark();
      break;
    case HttpConstants.StatusCode.FORBIDDEN:
      forbiddenRequests.mark();
      break;
    case HttpConstants.StatusCode.NOT_FOUND:
      routesNotFound.mark();
      break;
    case HttpConstants.StatusCode.CONFLICT:
      conflictRequests.mark();
      break;
    case HttpConstants.StatusCode.INTERNAL_ERROR:
      internalServerErrors.mark();
      break;
    default:
      break;
  }
}

代码示例来源:origin: ro.pippo/pippo-controller

int preInterceptStatus = routeContext.getResponse().getStatus();
processRouteInterceptors(routeContext);
int postInterceptStatus = routeContext.getResponse().getStatus();
if (routeContext.getResponse().isCommitted()) {
  log.debug("Response committed by interceptor");
} else if (preInterceptStatus != postInterceptStatus && postInterceptStatus >= 300) {
  log.debug("Interceptor set status code to {}, committing response",
      routeContext.getResponse().getStatus());
  routeContext.getResponse().commit();
  routeContext.next();

代码示例来源:origin: com.gitblit.fathom/fathom-rest

int preInterceptStatus = context.getResponse().getStatus();
processRouteInterceptors(context);
int postInterceptStatus = context.getResponse().getStatus();
if (context.getResponse().isCommitted()) {
  log.debug("Response committed by RouteInterceptor");
} else if (preInterceptStatus != postInterceptStatus && postInterceptStatus >= 300) {
  log.debug("RouteInterceptor set status code to {}, committing response",
      context.getResponse().getStatus());
  context.getResponse().commit();
  context.next();

代码示例来源:origin: gitblit/fathom

int preInterceptStatus = context.getResponse().getStatus();
processRouteInterceptors(context);
int postInterceptStatus = context.getResponse().getStatus();
if (context.getResponse().isCommitted()) {
  log.debug("Response committed by RouteInterceptor");
} else if (preInterceptStatus != postInterceptStatus && postInterceptStatus >= 300) {
  log.debug("RouteInterceptor set status code to {}, committing response",
      context.getResponse().getStatus());
  context.getResponse().commit();
  context.next();

相关文章