Package org.apache.http.client.methods

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


        resp2.setHeader("Date", DateUtils.formatDate(now));
        resp2.setHeader("Vary", "Accept-Encoding");
        resp2.setHeader("Cache-Control", "public, max-age=3600");

        HttpRequest req4 = new HttpGet("http://foo.example.com");
        req4.addHeader("Accept-Encoding", "gzip,identity");
        req4.addHeader("If-None-Match", "\"gzip_etag\"");

        HttpRequest req4Server = new HttpGet("http://foo.example.com");
        req4Server.addHeader("Accept-Encoding", "gzip,identity");
        req4Server.addHeader("If-None-Match", "\"gzip_etag\"");
View Full Code Here


        resp2.setHeader("Vary", "Accept-Encoding");
        resp2.setHeader("Cache-Control", "public, max-age=3600");

        HttpRequest req4 = new HttpGet("http://foo.example.com");
        req4.addHeader("Accept-Encoding", "gzip,identity");
        req4.addHeader("If-None-Match", "\"gzip_etag\"");

        HttpRequest req4Server = new HttpGet("http://foo.example.com");
        req4Server.addHeader("Accept-Encoding", "gzip,identity");
        req4Server.addHeader("If-None-Match", "\"gzip_etag\"");
View Full Code Here

        HttpRequest req4 = new HttpGet("http://foo.example.com");
        req4.addHeader("Accept-Encoding", "gzip,identity");
        req4.addHeader("If-None-Match", "\"gzip_etag\"");

        HttpRequest req4Server = new HttpGet("http://foo.example.com");
        req4Server.addHeader("Accept-Encoding", "gzip,identity");
        req4Server.addHeader("If-None-Match", "\"gzip_etag\"");

        HttpResponse resp4 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not Modified");
        resp4.setHeader("Etag", "\"gzip_etag\"");
        resp4.setHeader("Date", DateUtils.formatDate(now));
View Full Code Here

        req4.addHeader("Accept-Encoding", "gzip,identity");
        req4.addHeader("If-None-Match", "\"gzip_etag\"");

        HttpRequest req4Server = new HttpGet("http://foo.example.com");
        req4Server.addHeader("Accept-Encoding", "gzip,identity");
        req4Server.addHeader("If-None-Match", "\"gzip_etag\"");

        HttpResponse resp4 = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_NOT_MODIFIED, "Not Modified");
        resp4.setHeader("Etag", "\"gzip_etag\"");
        resp4.setHeader("Date", DateUtils.formatDate(now));
        resp4.setHeader("Vary", "Accept-Encoding");
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");
        CloseableHttpClient httpclient = HttpClientBuilder.create().build();

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

     * @throws IOException
     */
    @Test
    public void testRequestHeaderSingleValue() throws IOException {
        HttpGet getMethod = new HttpGet(uri("/context/httpheaders/?name=foo"));
        getMethod.addHeader("foo", "bar");
        final HttpResponse response = client.execute(getMethod);
        assertStatusCode(200, response);
        String responseBody = asString(response);
        assertEquals("requestheader:[bar]", responseBody);
    }
View Full Code Here

     * @throws IOException
     */
    @Test
    public void testRequestHeaderMultipleValue() throws IOException {
        HttpGet getMethod = new HttpGet(uri("/context/httpheaders/?name=foo"));
        getMethod.addHeader("foo", "bar");
        getMethod.addHeader("foo", "bar2");
        final HttpResponse response = client.execute(getMethod);
        assertStatusCode(200, response);
        String responseBody = asString(response);
        assertEquals("requestheader:[bar, bar2]", responseBody);
View Full Code Here

     */
    @Test
    public void testRequestHeaderMultipleValue() throws IOException {
        HttpGet getMethod = new HttpGet(uri("/context/httpheaders/?name=foo"));
        getMethod.addHeader("foo", "bar");
        getMethod.addHeader("foo", "bar2");
        final HttpResponse response = client.execute(getMethod);
        assertStatusCode(200, response);
        String responseBody = asString(response);
        assertEquals("requestheader:[bar, bar2]", responseBody);
    }
View Full Code Here

     * @throws IOException
     */
    @Test
    public void testRequestHeaderCaseInsensitive() throws IOException {
        HttpGet getMethod = new HttpGet(uri("/context/httpheaders/?name=foo"));
        getMethod.addHeader("FOO", "bar");
        getMethod.addHeader("FoO", "bar2");
        final HttpResponse response = client.execute(getMethod);
        assertStatusCode(200, response);
        String responseBody = asString(response);
        assertEquals("requestheader:[bar, bar2]", responseBody);
View Full Code Here

     */
    @Test
    public void testRequestHeaderCaseInsensitive() throws IOException {
        HttpGet getMethod = new HttpGet(uri("/context/httpheaders/?name=foo"));
        getMethod.addHeader("FOO", "bar");
        getMethod.addHeader("FoO", "bar2");
        final HttpResponse response = client.execute(getMethod);
        assertStatusCode(200, response);
        String responseBody = asString(response);
        assertEquals("requestheader:[bar, bar2]", responseBody);
    }
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.