Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.URI$CharsetChanged


    }

    public void testGetWithAccept() throws Exception {
        try {
            GetMethod httpMethod = new GetMethod();
            httpMethod.setURI(new URI(getBaseURI() + "/headers/accept", false));
            httpClient = new HttpClient();
            httpMethod.setRequestHeader("Accept", "text/*, text/html, text/html;level=1, */*");
            try {
                int result = httpClient.executeMethod(httpMethod);
                System.out.println("Response status code: " + result);
View Full Code Here


    }

    public void testGetWithAcceptLanguage() throws Exception {
        try {
            GetMethod httpMethod = new GetMethod();
            httpMethod.setURI(new URI(getBaseURI() + "/headers/acceptlang", false));
            httpClient = new HttpClient();
            httpMethod.setRequestHeader("Accept-Language", "fr");
            try {
                int result = httpClient.executeMethod(httpMethod);
                System.out.println("Response status code: " + result);
View Full Code Here

    }

    public void testGetHeadersWithCase() throws Exception {
        try {
            GetMethod httpMethod = new GetMethod();
            httpMethod.setURI(new URI(getBaseURI() + "/headers/headercase", false));
            httpClient = new HttpClient();
            httpMethod.setRequestHeader("Custom-Header", "MyValue");
            try {
                int result = httpClient.executeMethod(httpMethod);
                System.out.println("Response status code: " + result);
View Full Code Here

    }

    public void testGetHeadersAcceptAsParam() throws Exception {
        try {
            GetMethod httpMethod = new GetMethod();
            httpMethod.setURI(new URI(getBaseURI() + "/headers/headeraccept", false));
            httpClient = new HttpClient();
            httpMethod.setRequestHeader("Accept", "text/xml");
            try {
                int result = httpClient.executeMethod(httpMethod);
                System.out.println("Response status code: " + result);
View Full Code Here

    }

    public void testGetHeadersAcceptAsArg() throws Exception {
        try {
            GetMethod httpMethod = new GetMethod();
            httpMethod.setURI(new URI(getBaseURI() + "/headers/headersasarg", false));
            httpClient = new HttpClient();
            httpMethod.setRequestHeader("Accept", "text/xml application/xml");
            httpMethod.setRequestHeader("Content-Type", "application/xml");
            try {
                int result = httpClient.executeMethod(httpMethod);
View Full Code Here

    }

    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"));
View Full Code Here

    public void testHttpHeadersGetCookie() throws Exception {
        setCookies();
        // call get to exercise HttpHeaders.getCookies()
        GetMethod getHttpMethod = new GetMethod();
        getHttpMethod.getParams().setCookiePolicy(CookiePolicy.RFC_2965);
        getHttpMethod.setURI(new URI(BASE_URI + "/getAll", false));
        System.out.println("Request headers:");
        System.out.println(Arrays.asList(getHttpMethod.getRequestHeaders()));
        try {
            int result = httpclient.executeMethod(getHttpMethod);
            System.out.println("Response status code: " + result);
View Full Code Here

     */
    public void testCookieParamPrivateVar() throws Exception {
        setCookies();
        GetMethod getHttpMethod = new GetMethod();
        getHttpMethod.getParams().setCookiePolicy(CookiePolicy.RFC_2965);
        getHttpMethod.setURI(new URI(BASE_URI + "/getValue2", false));
        System.out.println("Request headers:");
        System.out.println(Arrays.asList(getHttpMethod.getRequestHeaders()));
        try {
            int result = httpclient.executeMethod(getHttpMethod);
            System.out.println("Response status code: " + result);
View Full Code Here

    // }
    private void setCookies() throws Exception {
        // call put to set the cookies
        PutMethod putHttpMethod = new PutMethod();
        putHttpMethod.getParams().setCookiePolicy(CookiePolicy.RFC_2965);
        putHttpMethod.setURI(new URI(BASE_URI, false));
        System.out.println("Request headers:");
        System.out.println(Arrays.asList(putHttpMethod.getRequestHeaders()));
        try {
            int result = httpclient.executeMethod(putHttpMethod);
            System.out.println("Response status code: " + result);
View Full Code Here

   {
      // for each content element, check resource type and classify
      for (Enumeration e = propFind.getAllResponseURLs(); e.hasMoreElements(); )
      {
         String href = (String) e.nextElement();
         URI uri = new URI(propFind.getURI(), href);
        
         String key = uri.toString();
         List properties = (List)this.resourceMap.get(key);
         if (properties == null) {
            properties = new ArrayList();
            this.resourceMap.put(key, properties);
         }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.URI$CharsetChanged

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.