Package org.apache.http.client

Examples of org.apache.http.client.HttpResponseException


        public AnalysedText handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
            StatusLine statusLine = response.getStatusLine();
            HttpEntity entity = response.getEntity();
            if (statusLine.getStatusCode() >= 300) {
                EntityUtils.consume(entity);
                throw new HttpResponseException(statusLine.getStatusCode(),
                    statusLine.getReasonPhrase());
            }
            //parse the results
            InputStream in = null;
            try {
View Full Code Here


    public String handleResponse(final HttpResponse response) throws IOException {
        StatusLine statusLine = response.getStatusLine();
        HttpEntity entity = response.getEntity();
        if (statusLine.getStatusCode() >= 300) {
            EntityUtils.consume(entity);
            throw new HttpResponseException(statusLine.getStatusCode(),
                                            statusLine.getReasonPhrase());
        }
        return entity == null ? null : EntityUtils.toString(entity, encoding);
    }
View Full Code Here

        response = client.execute(httpget, context);
        int code = response.getStatusLine().getStatusCode();
        if (code == HttpStatus.SC_NOT_MODIFIED) {
          throw new NotModifiedException("'304 - not modified' http code received");
        } else if (code >= 300) {
          throw new HttpResponseException(code, "Server returned HTTP error code " + code);
        }

      } catch (HttpResponseException e) {
        if (e.getStatusCode() == HttpStatus.SC_NOT_MODIFIED) {
          throw new NotModifiedException("'304 - not modified' http code received");
View Full Code Here

        final StatusLine statusLine = response.getStatusLine();
        final HttpEntity entity = response.getEntity();
        final String str = entity == null ? null : EntityUtils.toString(entity);

        if (statusLine.getStatusCode() >= 300) {
            throw new HttpResponseException(statusLine.getStatusCode(), str);
        }

        return str;
    }
View Full Code Here

            }
       
        if (status >= 200 && status < 300) {
          entity = new BufferedHttpEntity(entity);
        } else {
          throw new HttpResponseException(status,phrase);
        }
        return entity;
      }
    };
   
View Full Code Here

    {
        try {
            return super.fetchSearchResponse();
        } catch (Exception e) {
            if (e instanceof HttpResponseException) {
                HttpResponseException httpException = (HttpResponseException) e;
                int sCode = httpException.getStatusCode();
                if (sCode == 302 || sCode == 403) {
                    throw new IpBannedException(httpException);
                }
            }
            throw e;
View Full Code Here

            metadata.put(SearchEngineResponse.COMPRESSION_KEY, response.compression);
            return xmlDocumentSourceHelper.loadProcessingResult(carrot2XmlStream, stylesheet, xsltParameters);
        }
        else
        {
            throw new HttpResponseException(statusCode, response.statusMessage);
        }
    }
View Full Code Here

            throws HttpResponseException, IOException {
        final StatusLine statusLine = response.getStatusLine();
        final HttpEntity entity = response.getEntity();
        if (statusLine.getStatusCode() >= 300) {
            EntityUtils.consume(entity);
            throw new HttpResponseException(statusLine.getStatusCode(),
                    statusLine.getReasonPhrase());
        }
        return entity == null ? null : handleEntity(entity);
    }
View Full Code Here

    StatusLine s = response.getStatusLine();
    if (s.getStatusCode() == 200) {
      return processResponse(response);
    } else {
      // If we get anything other than 200 throw it so we can handle it
      throw new HttpResponseException(s.getStatusCode(), s.toString());
    }
  }
View Full Code Here

            throws HttpResponseException, IOException {
        final StatusLine statusLine = response.getStatusLine();
        final HttpEntity entity = response.getEntity();
        if (statusLine.getStatusCode() >= 300) {
            EntityUtils.consume(entity);
            throw new HttpResponseException(statusLine.getStatusCode(),
                    statusLine.getReasonPhrase());
        }
        return entity == null ? null : EntityUtils.toString(entity);
    }
View Full Code Here

TOP

Related Classes of org.apache.http.client.HttpResponseException

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.