Examples of OptionsMethod


Examples of org.apache.commons.httpclient.methods.OptionsMethod

        }
    }

    public void testAllowHeaders() throws Exception {
        try {
            OptionsMethod httpMethod = new OptionsMethod();
            httpMethod.setURI(new URI(getBaseURI() + "/headersallow1/allow1", false));
            httpClient = new HttpClient();
            try {
                int result = httpClient.executeMethod(httpMethod);
                assertEquals(204, result);
                assertNotNull(httpMethod.getResponseHeader("Allow"));
                List<String> allowedMethods =
                    Arrays.asList(httpMethod.getResponseHeader("Allow").getValue().split(", "));
                System.out.println(allowedMethods);
                assertEquals(3, allowedMethods.size());
                assertTrue(allowedMethods.contains("HEAD"));
                assertTrue(allowedMethods.contains("OPTIONS"));
                assertTrue(allowedMethods.contains("GET"));
            } catch (IOException ioe) {
                ioe.printStackTrace();
                fail(ioe.getMessage());
            } finally {
                httpMethod.releaseConnection();
            }
        } catch (URIException e) {
            e.printStackTrace();
            fail(e.getMessage());
        }

        try {
            OptionsMethod httpMethod = new OptionsMethod();
            httpMethod.setURI(new URI(getBaseURI() + "/headersallow2", false));
            httpClient = new HttpClient();
            try {
                int result = httpClient.executeMethod(httpMethod);
                assertEquals(204, result);
                assertNotNull(httpMethod.getResponseHeader("Allow"));
                List<String> allowedMethods =
                    Arrays.asList(httpMethod.getResponseHeader("Allow").getValue().split(", "));
                System.out.println(allowedMethods);
                assertEquals(6, allowedMethods.size());
                assertTrue(allowedMethods.contains("HEAD"));
                assertTrue(allowedMethods.contains("OPTIONS"));
                assertTrue(allowedMethods.contains("GET"));
                assertTrue(allowedMethods.contains("PUT"));
                assertTrue(allowedMethods.contains("POST"));
                assertTrue(allowedMethods.contains("DELETE"));
            } catch (IOException ioe) {
                ioe.printStackTrace();
                fail(ioe.getMessage());
            } finally {
                httpMethod.releaseConnection();
            }
        } catch (URIException e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
View Full Code Here

Examples of org.apache.commons.httpclient.methods.OptionsMethod

        } else if (method.equals(HEAD)) {
            httpMethod = new HeadMethod(urlStr);
        } else if (method.equals(TRACE)) {
            httpMethod = new TraceMethod(urlStr);
        } else if (method.equals(OPTIONS)) {
            httpMethod = new OptionsMethod(urlStr);
        } else if (method.equals(DELETE)) {
            httpMethod = new DeleteMethod(urlStr);
        } else if (method.equals(GET)) {
            httpMethod = new GetMethod(urlStr);
        } else {
View Full Code Here

Examples of org.apache.commons.httpclient.methods.OptionsMethod

        case GET:     httpMethod = new GetMethod(uri); break;
        case POST:    httpMethod = getMethod(new PostMethod(uri), entity); break;
        case PUT:     httpMethod = getMethod(new PutMethod(uri), entity); break;
        case DELETE:  httpMethod = new DeleteMethod(uri); break;
        case HEAD:    httpMethod = new HeadMethod(uri); break;
        case OPTIONS: httpMethod = new OptionsMethod(uri); break;
        case TRACE:   httpMethod = new TraceMethod(uri); break;
        default:      httpMethod = getMethod(new ExtensionMethod(method,uri), entity);
      }
      initHeaders(options, httpMethod);
      return httpMethod;
View Full Code Here

Examples of org.apache.commons.httpclient.methods.OptionsMethod

     * but Tomcat 3.x is not.
     */
    public void testMethodsOptions() {

        HttpClient client = createHttpClient();
        OptionsMethod method = new OptionsMethod("/");

        try {
            client.executeMethod(method);
        } catch (Throwable t) {
            t.printStackTrace();
            fail("Unable to execute method : " + t.toString());
        }

        Enumeration methodsAllowed = method.getAllowedMethods();
        // This enumeration musn't be empty
        assertTrue("No HTTP method allowed : result of OPTIONS is incorrect "
               + "(make sure the webserver running on port " + getPort()
               + " supports OPTIONS properly)",
               methodsAllowed.hasMoreElements());
View Full Code Here

Examples of org.apache.commons.httpclient.methods.OptionsMethod

    public void testMethodsHead() {

        HttpClient client = createHttpClient();

        OptionsMethod opmethod = new OptionsMethod("/");

        try {
            client.executeMethod(opmethod);
        } catch (Throwable t) {
            t.printStackTrace();
View Full Code Here

Examples of org.apache.commons.httpclient.methods.OptionsMethod

     * but Tomcat 3.x is not.
     */
    public void testMethodsOptions() {

        HttpClient client = createHttpClient();
        OptionsMethod method = new OptionsMethod("/");

        try {
            client.executeMethod(method);
        } catch (Throwable t) {
            t.printStackTrace();
            fail("Unable to execute method : " + t.toString());
        }

        Enumeration methodsAllowed = method.getAllowedMethods();
        // This enumeration musn't be empty
        assertTrue("No HTTP method allowed : result of OPTIONS is incorrect "
               + "(make sure the webserver running on port " + getPort()
               + " supports OPTIONS properly)",
               methodsAllowed.hasMoreElements());
View Full Code Here

Examples of org.apache.commons.httpclient.methods.OptionsMethod

    public void testMethodsHead() {

        HttpClient client = createHttpClient();

        OptionsMethod opmethod = new OptionsMethod("/");

        try {
            client.executeMethod(opmethod);
        } catch (Throwable t) {
            t.printStackTrace();
View Full Code Here

Examples of org.apache.commons.httpclient.methods.OptionsMethod

     * but Tomcat 3.x is not.
     */
    public void testMethodsOptions() {

        HttpClient client = new HttpClient();
        OptionsMethod method = new OptionsMethod("/");

        try {
          client.getHostConfiguration().setHost(host, port, "http");
            client.executeMethod(method);
        } catch (Throwable t) {
            t.printStackTrace();
            fail("Unable to execute method : " + t.toString());
        }

        Enumeration methodsAllowed = method.getAllowedMethods();
        // This enumeration musn't be empty
        assertTrue("No HTTP method allowed : result of OPTIONS is incorrect "
               + "(make sure the webserver running on port " + port
               + " supports OPTIONS properly)",
               methodsAllowed.hasMoreElements());
View Full Code Here

Examples of org.apache.commons.httpclient.methods.OptionsMethod

    public void testMethodsHead() {

        HttpClient client = new HttpClient();
      client.getHostConfiguration().setHost(host, port, "http");

        OptionsMethod opmethod = new OptionsMethod("/");

        try {
            client.executeMethod(opmethod);
        } catch (Throwable t) {
            t.printStackTrace();
View Full Code Here

Examples of org.apache.commons.httpclient.methods.OptionsMethod

            } else if (method.equals(HEAD)){
                httpMethod = new HeadMethod(urlStr);
            } else if (method.equals(TRACE)){
                httpMethod = new TraceMethod(urlStr);
            } else if (method.equals(OPTIONS)){
                httpMethod = new OptionsMethod(urlStr);
            } else if (method.equals(DELETE)){
                httpMethod = new DeleteMethod(urlStr);
            } else if (method.equals(GET)){
                httpMethod = new GetMethod(urlStr);
            } else {
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.