private int getHttpResponseStatus(boolean isSuccess, Request request, ErrorMessage mainError, List<ErrorMessage> errors) { if (isBenchmarking(request)) return VespaHeaders.getEagerErrorStatus(mainError,errors.iterator()); return VespaHeaders.getStatus(isSuccess, mainError, errors.iterator()); }
/** * (during normal execution) return 200 unless this is not a success or a 4xx error is requested. * * @param isSuccess Whether or not the response represents a success. * @param mainError The main error of the response, if any. * @param allErrors All the errors of the response, if any. * @return The status code of the given response. */ public static int getStatus(boolean isSuccess, ErrorMessage mainError, Iterator<? extends ErrorMessage> allErrors) { // Do note, SearchResponse has its own implementation of isSuccess() if (isSuccess) { Tuple2<Boolean, Integer> status = webServiceCodes(mainError, allErrors); if (status.first) { return status.second; } else { return Response.Status.OK; } } return getEagerErrorStatus(mainError, allErrors); }
private int getHttpResponseStatus(com.yahoo.container.jdisc.HttpRequest httpRequest, Result result) { boolean benchmarkOutput = VespaHeaders.benchmarkOutput(httpRequest); if (benchmarkOutput) { return VespaHeaders.getEagerErrorStatus(result.hits().getError(), SearchResponse.getErrorIterator(result.hits().getErrorHit())); } else { return VespaHeaders.getStatus(SearchResponse.isSuccess(result), result.hits().getError(), SearchResponse.getErrorIterator(result.hits().getErrorHit())); } }