Examples of HttpResponseException


Examples of org.apache.http.client.HttpResponseException

    StatusLine statusline = response.getStatusLine();
    if (statusline.getStatusCode() == HttpStatus.SC_NOT_FOUND) {
      return null;
    }
    if (statusline.getStatusCode() != HttpStatus.SC_OK) {
      throw new HttpResponseException(
          statusline.getStatusCode(), statusline.getReasonPhrase());
    }
    HttpEntity entity = response.getEntity();
    if (entity != null) {
      return entity.getContent();
View Full Code Here

Examples of org.apache.http.client.HttpResponseException

    HttpGet httpget = new HttpGet(uri);
    HttpResponse response = getHttpClient().execute(httpget);
    StatusLine statusline = response.getStatusLine();
    if (statusline.getStatusCode() >= HttpStatus.SC_BAD_REQUEST) {
      httpget.abort();
      throw new HttpResponseException(
          statusline.getStatusCode(), statusline.getReasonPhrase());
    }
    HttpEntity entity = response.getEntity();
    if (entity == null) {
      // Should _almost_ never happen with HTTP GET requests.
View Full Code Here

Examples of org.broad.igv.exceptions.HttpResponseException

                    message = conn.getResponseMessage();
                }
                String details = readErrorStream(conn);
                log.error("URL: " + url.toExternalForm() + ". error stream: " + details);
                log.error("Code: " + code + ". " + message);
                HttpResponseException exc = new HttpResponseException(code);
                throw exc;
            }
        }
        return conn;
    }
View Full Code Here

Examples of org.eclipse.jetty.client.HttpResponseException

        HttpExchange exchange = getHttpExchange();
        if (exchange != null)
        {
            HttpResponse response = exchange.getResponse();
            response.status(status).reason(reason);
            failAndClose(new HttpResponseException("HTTP protocol violation: bad response on " + getHttpConnection(), response));
        }
    }
View Full Code Here

Examples of org.jclouds.http.HttpResponseException

   public void handleError(HttpCommand command, HttpResponse response) {
      // it is important to always read fully and close streams
      byte[] data = closeClientButKeepContentStream(response);
      String message = data != null ? new String(data) : null;

      Exception exception = message != null ? new HttpResponseException(command, response, message)
               : new HttpResponseException(command, response);
      message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
               response.getStatusLine());
      switch (response.getStatusCode()) {
         case 400:
            break;
View Full Code Here

Examples of org.jclouds.http.HttpResponseException

   protected Logger logger = Logger.NULL;

   public void handleError(HttpCommand command, HttpResponse response) {
      // it is important to always read fully and close streams
      String message = parseMessage(response);
      Exception exception = message != null ? new HttpResponseException(command, response, message)
               : new HttpResponseException(command, response);
      try {
         message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
                  response.getStatusLine());
         switch (response.getStatusCode()) {
            case 400:
View Full Code Here

Examples of org.jclouds.http.HttpResponseException

         }
      } finally {
         releasePayload(from);
      }
      throw new HttpResponseException("not found ", null, from);
   }
View Full Code Here

Examples of org.jclouds.http.HttpResponseException

            if (ms.find() && mm.find()) {
               String status = ms.group(1);
               String errorMessage = mm.group(1);
               // revert status code to 200 to match actual server's return status
               response = response.toBuilder().statusCode(200).build();
               exception = refineException(new HttpResponseException(command, response, status + ": " + errorMessage));
            }
         }
      } catch (UnsupportedEncodingException e) {
         // should never happen as UTF-8 is always supported
      } finally {
         if (exception == null) {
            exception = new HttpResponseException(command, response);
         }
         command.setException(exception);
         releasePayload(response);
      }
   }
View Full Code Here

Examples of org.jclouds.http.HttpResponseException

      // Create default exception
      String message = data != null
            ? new String(data)
            : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine());
      Exception exception = new HttpResponseException(command, response, message);
     
      // Try to create a VCloudDirectorException from XML payload, if it exists
      if (response.getPayload() != null && response.getPayload().getContentMetadata().getContentType().startsWith(VCloudDirectorMediaType.ERROR)) {
        try {
           Error error = JAXB.unmarshal(new ByteArrayInputStream(data), Error.class);
View Full Code Here

Examples of org.jclouds.http.HttpResponseException

   public void handleError(HttpCommand command, HttpResponse response) {
      // it is important to always read fully and close streams
      byte[] data = closeClientButKeepContentStream(response);
      String message = data != null ? new String(data) : null;

      Exception exception = message != null ? new HttpResponseException(command, response, message)
               : new HttpResponseException(command, response);
      message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
               response.getStatusLine());
      switch (response.getStatusCode()) {
         case 400:
            break;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.