Package org.springframework.web.client

Examples of org.springframework.web.client.HttpServerErrorException


    HttpStatus statusCode = response.getStatusCode();
    switch (statusCode.series()) {
      case CLIENT_ERROR:
        throw getException(response);
      case SERVER_ERROR:
        throw new HttpServerErrorException(statusCode, response.getStatusText());
      default:
        throw new RestClientException("Unknown status code [" + statusCode + "]");
    }
  }
View Full Code Here


    ResponseEntity<String> response = executeInfoRequestInternal(infoUrl);
    if (response.getStatusCode() != HttpStatus.OK) {
      if (logger.isErrorEnabled()) {
        logger.error("SockJS Info request (url=" + infoUrl + ") failed: " + response);
      }
      throw new HttpServerErrorException(response.getStatusCode());
    }
    if (logger.isTraceEnabled()) {
      logger.trace("SockJS Info request (url=" + infoUrl + ") response: " + response);
    }
    return response.getBody();
View Full Code Here

    ResponseEntity<String> response = executeSendRequestInternal(url, this.xhrSendRequestHeaders, message);
    if (response.getStatusCode() != HttpStatus.NO_CONTENT) {
      if (logger.isErrorEnabled()) {
        logger.error("XHR send request (url=" + url + ") failed: " + response);
      }
      throw new HttpServerErrorException(response.getStatusCode());
    }
    if (logger.isTraceEnabled()) {
      logger.trace("XHR send request (url=" + url + ") response: " + response);
    }
  }
View Full Code Here

            ClientResponse response = result.getResponse();
            if (response.getResponseCode() != 200) {
              HttpStatus status = HttpStatus.valueOf(response.getResponseCode());
              IoUtils.safeClose(result.getConnection());
              onFailure(new HttpServerErrorException(status, "Unexpected XHR receive status"));
            }
            else {
              SockJsResponseListener listener = new SockJsResponseListener(result.getConnection(),
                  url, headers, sockJsSession, connectFuture);
              listener.setup(result.getResponseChannel());
View Full Code Here

    @Override
    public void onBegin(Response response) {
      if (response.getStatus() != 200) {
        HttpStatus status = HttpStatus.valueOf(response.getStatus());
        response.abort(new HttpServerErrorException(status, "Unexpected XHR receive status"));
      }
    }
View Full Code Here

    }

    @Override
    public Object extractData(ClientHttpResponse response) throws IOException {
      if (!HttpStatus.OK.equals(response.getStatusCode())) {
        throw new HttpServerErrorException(response.getStatusCode());
      }
      if (logger.isTraceEnabled()) {
        logger.trace("XHR receive headers: " + response.getHeaders());
      }
      InputStream is = response.getBody();
View Full Code Here

    verifyNoMoreInteractions(this.webSocketHandler);
  }

  @Test
  public void connectFailure() throws Exception {
    final HttpServerErrorException expected = new HttpServerErrorException(HttpStatus.INTERNAL_SERVER_ERROR);
    RestOperations restTemplate = mock(RestOperations.class);
    given(restTemplate.execute((URI) any(), eq(HttpMethod.POST), any(), any())).willThrow(expected);

    final CountDownLatch latch = new CountDownLatch(1);
    connect(restTemplate).addCallback(
View Full Code Here

    verify(this.infoReceiver, times(1)).executeInfoRequest(any());
  }

  @Test
  public void connectInfoRequestFailure() throws URISyntaxException {
    HttpServerErrorException exception = new HttpServerErrorException(HttpStatus.SERVICE_UNAVAILABLE);
    given(this.infoReceiver.executeInfoRequest(any())).willThrow(exception);
    this.sockJsClient.doHandshake(handler, URL).addCallback(this.connectCallback);
    verify(this.connectCallback).onFailure(exception);
    assertFalse(this.webSocketTransport.invoked());
    assertFalse(this.xhrTransport.invoked());
View Full Code Here

TOP

Related Classes of org.springframework.web.client.HttpServerErrorException

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.