186187188189190191192
|| response.getStatusLine().getStatusCode() != HttpStatus.SC_PARTIAL_CONTENT) { return; } consumeBody(response); throw new ClientProtocolException(UNEXPECTED_PARTIAL_CONTENT); }
236237238239240241242
if (((HttpEntityEnclosingRequest)originalRequest).expectContinue()) { return; } } consumeBody(response); throw new ClientProtocolException(UNEXPECTED_100_CONTINUE); }
8384858687888990919293
final URI requestURI = request.getURI(); if (requestURI.isAbsolute()) { target = URIUtils.extractHost(requestURI); if (target == null) { throw new ClientProtocolException("URI does not specify a valid host name: " + requestURI); } } return target; }
547548549550551552553554555556557
} @Test public void testNonCompliantRequestWrapsAndReThrowsProtocolException() throws Exception { final ClientProtocolException expected = new ClientProtocolException("ouch"); requestIsFatallyNonCompliant(null); mockRequestProtocolCompliance.makeRequestCompliant((HttpRequestWrapper)anyObject()); expectLastCall().andThrow(expected);
6061626364656667686970
int status = response.getStatusLine().getStatusCode(); if (status >= 200 && status < 300) { HttpEntity entity = response.getEntity(); return entity != null ? EntityUtils.toString(entity) : null; } else { throw new ClientProtocolException("Unexpected response status: " + status); } } }; String responseBody = httpclient.execute(httpget, responseHandler);
473474475476477478479480
} return revalidateCacheEntry(target, request, context, entry); } catch (IOException ioex) { return handleRevalidationFailure(request, context, entry, now); } catch (ProtocolException e) { throw new ClientProtocolException(e); } }
567568569570571572573574575576577
URI requestURI = request.getURI(); if (requestURI.isAbsolute()) { target = URIUtils.extractHost(requestURI); if (target == null) { throw new ClientProtocolException( "URI does not specify a valid host name: " + requestURI); } } return target; }
484485486487488489490491
872873874875876877878879880881882
} @Test public void testNonCompliantRequestWrapsAndReThrowsProtocolException() throws Exception { ClientProtocolException expected = new ClientProtocolException("ouch"); requestIsFatallyNonCompliant(null); requestCannotBeMadeCompliantThrows(expected); boolean gotException = false;
549550551552553554555556
} try { return director.execute(target, request, execContext); } catch(HttpException httpException) { throw new ClientProtocolException(httpException); } } // execute