HttpOptions extends HttpRequestBase { public Set<String> getAllowedMethods(final HttpResponse response) { if (response == null) { throw new IllegalArgumentException("HTTP response may not be null"); } HeaderIterator it = response.headerIterator("Allow"); Set<String> methods = new HashSet<String>(); while (it.hasNext()) { Header header = it.nextHeader(); HeaderElement[] elements = header.getElements(); for (HeaderElement element : elements) { methods.add(element.getName()); } } return methods; } HttpOptions();  HttpOptions(final URI uri);  HttpOptions(final String uri); @Override String getMethod(); Set<String> getAllowedMethods(final HttpResponse response); final static String METHOD_NAME; }
@Test public void testMultipleAllows() { ProtocolVersion proto = new ProtocolVersion("HTTP", 1, 1); BasicStatusLine line = new BasicStatusLine(proto, 200, "test reason"); BasicHttpResponse resp = new BasicHttpResponse(line); resp.addHeader("Allow", "POST"); resp.addHeader("Allow", "GET"); HttpOptions opt = new HttpOptions(); Set<String> methodsName = opt.getAllowedMethods(resp); Assert.assertTrue(methodsName.contains("POST")); Assert.assertTrue(methodsName.contains("GET")); }