Package org.apache.http.client.methods

Examples of org.apache.http.client.methods.HttpGet.addHeader()


      DefaultHttpClient httpclient = new DefaultHttpClient();
      HttpResponse response;
      //HttpGet httpget = new HttpGet("http://localhost:8080/" + DEP2 + "/");
      HttpGet httpget = new HttpGet(URL2.toString());
      httpget.addHeader("Authorization", "Basic Yzpj");//I'm not sure why this have to be here, however it does not work without it
      String text;

      try {
         response = httpclient.execute(httpget);
         text = Utils.getContent(response);
View Full Code Here


    URIBuilder builder = new URIBuilder(url);
    HttpGet method = new HttpGet(builder.build());
    if (headers != null) {
      for (String headerName : headers.keySet())
        method.addHeader(headerName, headers.get(headerName));
    }
    try {

      BasicHttpContext localcontext = new BasicHttpContext();
      if (isAuthConfigured) {
View Full Code Here

            StringBuffer ob = new StringBuffer();
            for (String requestOrigin : requestOrigins) {
                ob.append(requestOrigin);
                ob.append(" "); // extra trailing space won't hurt.
            }
            httpget.addHeader("Origin", ob.toString());
        }
        HttpResponse response = httpclient.execute(httpget);
        assertEquals(200, response.getStatusLine().getStatusCode());
        HttpEntity entity = response.getEntity();
        String e = IOUtils.toString(entity.getContent(), "utf-8");
View Full Code Here

                .accept("text/plain").post(null, String.class);
        assertEquals("ok", r);
       
        HttpClient httpclient = new DefaultHttpClient();
        HttpGet httpget = new HttpGet("http://localhost:" + PORT + "/untest/simpleGet/HelloThere");
        httpget.addHeader("Origin", "http://localhost:" + PORT);

        HttpResponse response = httpclient.execute(httpget);
        assertEquals(200, response.getStatusLine().getStatusCode());
        assertAllowCredentials(response, true);
    }
View Full Code Here

                .accept("text/plain").post(null, String.class);
        assertEquals("ok", r);
       
        HttpClient httpclient = new DefaultHttpClient();
        HttpGet httpget = new HttpGet("http://localhost:" + PORT + "/untest/simpleGet/HelloThere");
        httpget.addHeader("Origin", "http://localhost:" + PORT);

        HttpResponse response = httpclient.execute(httpget);
        assertEquals(200, response.getStatusLine().getStatusCode());
        assertAllowCredentials(response, false);
    }
View Full Code Here

            .accept("text/plain").post(null, String.class);
        assertEquals("ok", r);
        HttpClient httpclient = new DefaultHttpClient();
        HttpGet httpget = new HttpGet("http://localhost:" + PORT + "/untest/annotatedGet/HelloThere");
        // this is the origin we expect to get.
        httpget.addHeader("Origin", "http://area51.mil:31415");
        HttpResponse response = httpclient.execute(httpget);
        assertEquals(200, response.getStatusLine().getStatusCode());
        assertOriginResponse(false, new String[]{"http://area51.mil:31415"}, true, response);
        assertAllowCredentials(response, false);
        List<String> exposeHeadersValues
View Full Code Here

   
    @Test
    public void testAnnotatedClassCorrectOrigin() throws Exception {
        HttpClient httpclient = new DefaultHttpClient();
        HttpGet httpget = new HttpGet("http://localhost:" + PORT + "/antest/simpleGet/HelloThere");
        httpget.addHeader("Origin", "http://area51.mil:31415");

        HttpResponse response = httpclient.execute(httpget);
        assertEquals(200, response.getStatusLine().getStatusCode());
        HttpEntity entity = response.getEntity();
        String e = IOUtils.toString(entity.getContent(), "utf-8");
View Full Code Here

   
    @Test
    public void testAnnotatedClassWrongOrigin() throws Exception {
        HttpClient httpclient = new DefaultHttpClient();
        HttpGet httpget = new HttpGet("http://localhost:" + PORT + "/antest/simpleGet/HelloThere");
        httpget.addHeader("Origin", "http://su.us:1001");

        HttpResponse response = httpclient.execute(httpget);
        assertEquals(200, response.getStatusLine().getStatusCode());
        HttpEntity entity = response.getEntity();
        String e = IOUtils.toString(entity.getContent(), "utf-8");
View Full Code Here

    }
    // END SNIPPET: example
   
    private void invokeGetCustomer(String uri, String expect) throws Exception {
        HttpGet get = new HttpGet(uri);
        get.addHeader("Accept" , "application/json");
        HttpClient httpclient = new DefaultHttpClient();

        try {
            HttpResponse response = httpclient.execute(get);
            assertEquals(200, response.getStatusLine().getStatusCode());
View Full Code Here

        endpoint.assertIsSatisfied();
    }
   
    private void invokeRsService(String getUrl, String expected) throws Exception {
        HttpGet get = new HttpGet(getUrl);
        get.addHeader("Accept" , "application/json");
        get.addHeader("key", "customer");
        HttpClient httpclient = new DefaultHttpClient();

        try {
            HttpResponse response = httpclient.execute(get);
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.