public Multistatus handleResponse(HttpResponse response) throws SardineException, IOException { super.validateResponse(response); // Process the response from the server. HttpEntity entity = response.getEntity(); StatusLine statusLine = response.getStatusLine(); if (entity == null) { throw new SardineException( "No entity found in response", statusLine.getStatusCode(), statusLine.getReasonPhrase()); } return this.getMultistatus(entity.getContent()); }
// Interface to AsyncHttpRequest void sendResponseMessage(HttpResponse response) { StatusLine status = response.getStatusLine(); String responseBody = null; try { HttpEntity entity = null; HttpEntity temp = response.getEntity(); if (temp != null) { entity = new BufferedHttpEntity(temp); responseBody = EntityUtils.toString(entity, "UTF-8"); } } catch (IOException e) { sendFailureMessage(e, (String) null); } if (status.getStatusCode() >= 300) { sendFailureMessage( new HttpResponseException(status.getStatusCode(), status.getReasonPhrase()), responseBody); } else { sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), responseBody); } }