Package org.springframework.http

Examples of org.springframework.http.HttpStatus


  protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {

    response.setContentType("application/json");


    HttpStatus code = (HttpStatus) model.get("code");
    if (code == null) {
      code = HttpStatus.OK; // default to 200
    }

    response.setStatus(code.value());

    try {

      Writer out = response.getWriter();
View Full Code Here


  protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) {

    response.setContentType("application/json");


    HttpStatus code = (HttpStatus) model.get("code");
    if (code == null) {
      code = HttpStatus.OK; // default to 200
    }

    response.setStatus(code.value());

    try {

      Writer out = response.getWriter();
      Object obj = model.get("entity");
View Full Code Here

  public boolean hasError(ClientHttpResponse response) throws IOException {
    return hasError(getHttpStatusCode(response));
  }

  private HttpStatus getHttpStatusCode(ClientHttpResponse response) throws IOException {
    HttpStatus statusCode;
    try {
      statusCode = response.getStatusCode();
    }
    catch (IllegalArgumentException ex) {
      throw new UnknownHttpStatusCodeException(response.getRawStatusCode(),
View Full Code Here

   * is {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}, a {@link HttpServerErrorException}
   * if it is {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR},
   * and a {@link RestClientException} in other cases.
   */
  public void handleError(ClientHttpResponse response) throws IOException {
    HttpStatus statusCode = getHttpStatusCode(response);
    switch (statusCode.series()) {
      case CLIENT_ERROR:
        throw new HttpClientErrorException(statusCode, response.getStatusText(),
            response.getHeaders(), getResponseBody(response), getCharset(response));
      case SERVER_ERROR:
        throw new HttpServerErrorException(statusCode, response.getStatusText(),
View Full Code Here

   * @param response the response to check for a message body
   * @return {@code true} if the response has a body, {@code false} otherwise
   * @throws IOException in case of I/O errors
   */
  protected boolean hasMessageBody(ClientHttpResponse response) throws IOException {
    HttpStatus responseStatus = response.getStatusCode();
    if (responseStatus == HttpStatus.NO_CONTENT ||
        responseStatus == HttpStatus.NOT_MODIFIED) {
      return false;
    }
    long contentLength = response.getHeaders().getContentLength();
View Full Code Here

        // Send status code 302 by default.
        response.sendRedirect(encodedRedirectURL);
      }
    }
    else {
      HttpStatus statusCode = getHttp11StatusCode(request, response, targetUrl);
      response.setStatus(statusCode.value());
      response.setHeader("Location", encodedRedirectURL);
    }
  }
View Full Code Here

      HttpServletRequest request, HttpServletResponse response, String targetUrl) {

    if (this.statusCode != null) {
      return this.statusCode;
    }
    HttpStatus attributeStatusCode = (HttpStatus) request.getAttribute(View.RESPONSE_STATUS_ATTRIBUTE);
    if (attributeStatusCode != null) {
      return attributeStatusCode;
    }
    return HttpStatus.SEE_OTHER;
  }
View Full Code Here

   * @param response the response to check for a message body
   * @return {@code true} if the response has a body, {@code false} otherwise
   * @throws IOException in case of I/O errors
   */
  protected boolean hasMessageBody(ClientHttpResponse response) throws IOException {
    HttpStatus responseStatus = response.getStatusCode();
    if (responseStatus == HttpStatus.NO_CONTENT || responseStatus == HttpStatus.NOT_MODIFIED) {
      return false;
    }
    long contentLength = response.getHeaders().getContentLength();
    return contentLength != 0;
View Full Code Here

   * is {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}, a {@link HttpServerErrorException}
   * if it is {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR},
   * and a {@link RestClientException} in other cases.
   */
  public void handleError(ClientHttpResponse response) throws IOException {
    HttpStatus statusCode = response.getStatusCode();
    MediaType contentType = response.getHeaders().getContentType();
    Charset charset = contentType != null ? contentType.getCharSet() : null;
    byte[] body = getResponseBody(response);
    switch (statusCode.series()) {
      case CLIENT_ERROR:
        throw new HttpClientErrorException(statusCode, response.getStatusText(), body, charset);
      case SERVER_ERROR:
        throw new HttpServerErrorException(statusCode, response.getStatusText(), body, charset);
      default:
View Full Code Here

        // Send status code 302 by default.
        response.sendRedirect(encodedRedirectURL);
      }
    }
    else {
      HttpStatus statusCode = getHttp11StatusCode(request, response, targetUrl);
      response.setStatus(statusCode.value());
      response.setHeader("Location", encodedRedirectURL);
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.http.HttpStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.