Package org.apache.http.client.methods

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


     * @throws IOException
     */
    @Test
    public void testCookiesManyGiven() throws IOException {
        final HttpPost post = new HttpPost(uri("/context/httpheaders/cookies"));
        post.addHeader("Cookie", "foo=bar");
        post.addHeader("Cookie", "foo2=bar2");

        final HttpResponse response = client.execute(post);
        assertEquals(response.getStatusLine().getStatusCode(), 200);
        String responseBody = asString(response);
View Full Code Here


     */
    @Test
    public void testCookiesManyGiven() throws IOException {
        final HttpPost post = new HttpPost(uri("/context/httpheaders/cookies"));
        post.addHeader("Cookie", "foo=bar");
        post.addHeader("Cookie", "foo2=bar2");

        final HttpResponse response = client.execute(post);
        assertEquals(response.getStatusLine().getStatusCode(), 200);
        String responseBody = asString(response);
        assertEquals("cookies:foo=bar:foo2=bar2:", responseBody);
View Full Code Here

        }
        log.info("Saw JSESSIONID=" + sessionID);

        // Submit the login form
        HttpPost formPost = new HttpPost(baseURLNoAuth + "j_security_check");
        formPost.addHeader("Referer", baseURLNoAuth + "restricted/login.html");

        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("j_username", "baduser"));
        formparams.add(new BasicNameValuePair("j_password", "badpass"));
        formPost.setEntity(new UrlEncodedFormEntity(formparams, "UTF-8"));
View Full Code Here

        }
        log.info("Saw JSESSIONID=" + sessionID);

        // Submit the login form
        HttpPost formPost = new HttpPost(baseURLNoAuth + "j_security_check");
        formPost.addHeader("Referer", baseURLNoAuth + "restricted/login.html");

        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("j_username", "user1"));
        formparams.add(new BasicNameValuePair("j_password", "password1"));
        formPost.setEntity(new UrlEncodedFormEntity(formparams, "UTF-8"));
View Full Code Here

        }
        log.info("Saw JSESSIONID=" + sessionID);

        // Submit the login form
        HttpPost formPost = new HttpPost(baseURLNoAuth + "j_security_check");
        formPost.addHeader("Referer", baseURLNoAuth + "restricted/login.html");

        List<NameValuePair> formparams = new ArrayList<NameValuePair>();
        formparams.add(new BasicNameValuePair("j_username", username));
        formparams.add(new BasicNameValuePair("j_password", password));
        formPost.setEntity(new UrlEncodedFormEntity(formparams, "UTF-8"));
View Full Code Here

        Assert.assertTrue(exists);

        // Prepare HTTP post
        // PostMethod post = new PostMethod( colUri.toString() );
        HttpPost post = new HttpPost(providerURI);
        post.addHeader("Content-Type", "image/gif");
        post.addHeader("Title", "Title " + receiptName + "");
        post.addHeader("Slug", "Slug " + receiptName + "");

        post.setEntity(new FileEntity(input, "image/gif"));
View Full Code Here

        // Prepare HTTP post
        // PostMethod post = new PostMethod( colUri.toString() );
        HttpPost post = new HttpPost(providerURI);
        post.addHeader("Content-Type", "image/gif");
        post.addHeader("Title", "Title " + receiptName + "");
        post.addHeader("Slug", "Slug " + receiptName + "");

        post.setEntity(new FileEntity(input, "image/gif"));

        // Get HTTP client
View Full Code Here

        // Prepare HTTP post
        // PostMethod post = new PostMethod( colUri.toString() );
        HttpPost post = new HttpPost(providerURI);
        post.addHeader("Content-Type", "image/gif");
        post.addHeader("Title", "Title " + receiptName + "");
        post.addHeader("Slug", "Slug " + receiptName + "");

        post.setEntity(new FileEntity(input, "image/gif"));

        // Get HTTP client
        org.apache.http.client.HttpClient httpclient = new HttpClientFactory().createHttpClient();
View Full Code Here

    }

    public static HttpPost getHttpPost(String uri, Map<String, String> parameters) throws UnsupportedEncodingException {

        HttpPost httpPost = new HttpPost(uri);
        httpPost.addHeader("User-Agent", "HTTP Client");
        httpPost.addHeader("Content-type", "application/x-www-form-urlencoded");
        //postMethod.addHeader("Content-Length", "0");

        HttpParams params = new BasicHttpParams();
        httpPost.setParams(params);
View Full Code Here

    public static HttpPost getHttpPost(String uri, Map<String, String> parameters) throws UnsupportedEncodingException {

        HttpPost httpPost = new HttpPost(uri);
        httpPost.addHeader("User-Agent", "HTTP Client");
        httpPost.addHeader("Content-type", "application/x-www-form-urlencoded");
        //postMethod.addHeader("Content-Length", "0");

        HttpParams params = new BasicHttpParams();
        httpPost.setParams(params);
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.