Package org.apache.commons.httpclient.methods

Examples of org.apache.commons.httpclient.methods.PostMethod.addRequestHeader()


     * @throws IOException
     * @throws HttpException
     */
    public void testCookiesOneGiven() throws HttpException, IOException {
        PostMethod postMethod = new PostMethod(getBaseURI() + "/context/httpheaders/cookies");
        postMethod.addRequestHeader("Cookie", "foo=bar");
        try {
            client.executeMethod(postMethod);
            assertEquals(200, postMethod.getStatusCode());
            String responseBody = postMethod.getResponseBodyAsString();
            assertEquals("cookies:foo=bar:", responseBody);
View Full Code Here


     * @throws IOException
     * @throws HttpException
     */
    public void testCookiesManyGiven() throws HttpException, IOException {
        PostMethod postMethod = new PostMethod(getBaseURI() + "/context/httpheaders/cookies");
        postMethod.addRequestHeader("Cookie", "foo=bar");
        postMethod.addRequestHeader("Cookie", "foo2=bar2");
        try {
            client.executeMethod(postMethod);
            assertEquals(200, postMethod.getStatusCode());
            String responseBody = postMethod.getResponseBodyAsString();
View Full Code Here

     * @throws HttpException
     */
    public void testCookiesManyGiven() throws HttpException, IOException {
        PostMethod postMethod = new PostMethod(getBaseURI() + "/context/httpheaders/cookies");
        postMethod.addRequestHeader("Cookie", "foo=bar");
        postMethod.addRequestHeader("Cookie", "foo2=bar2");
        try {
            client.executeMethod(postMethod);
            assertEquals(200, postMethod.getStatusCode());
            String responseBody = postMethod.getResponseBodyAsString();
            assertEquals("cookies:foo=bar:foo2=bar2:", responseBody);
View Full Code Here

        postMethod =
            new PostMethod(
                           getBaseURI() + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
        postMethod.setRequestEntity(new StringRequestEntity("Hello World!", "custom/exception",
                                                            "UTF-8"));
        postMethod.addRequestHeader("myCustomHeaderToappend", "abcdefgh");
        postMethod.addRequestHeader("MYCUSTOMHEADERTOAPPEND", "wxyz");
        postMethod.addRequestHeader("mycustomheadertoappend", "12345");
        try {
            client.executeMethod(postMethod);
View Full Code Here

            new PostMethod(
                           getBaseURI() + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
        postMethod.setRequestEntity(new StringRequestEntity("Hello World!", "custom/exception",
                                                            "UTF-8"));
        postMethod.addRequestHeader("myCustomHeaderToappend", "abcdefgh");
        postMethod.addRequestHeader("MYCUSTOMHEADERTOAPPEND", "wxyz");
        postMethod.addRequestHeader("mycustomheadertoappend", "12345");
        try {
            client.executeMethod(postMethod);

            assertEquals(200, postMethod.getStatusCode());
View Full Code Here

                           getBaseURI() + "/jaxrs/tests/providers/messagebodyreader/reader/readfrom");
        postMethod.setRequestEntity(new StringRequestEntity("Hello World!", "custom/exception",
                                                            "UTF-8"));
        postMethod.addRequestHeader("myCustomHeaderToappend", "abcdefgh");
        postMethod.addRequestHeader("MYCUSTOMHEADERTOAPPEND", "wxyz");
        postMethod.addRequestHeader("mycustomheadertoappend", "12345");
        try {
            client.executeMethod(postMethod);

            assertEquals(200, postMethod.getStatusCode());
View Full Code Here

            }
        }

        if(requestHeaders != null) {
            for(Map.Entry<String,String> e : requestHeaders.entrySet()) {
                post.addRequestHeader(e.getKey(), e.getValue());
            }
        }

        final int status = httpClient.executeMethod(post);
        if(status!=302) {
View Full Code Here

    public void testGetPlainLong() throws Exception {
        String endpointAddress =
            "http://localhost:" + PORT + "/bookstore/booksplain";

        PostMethod post = new PostMethod(endpointAddress);
        post.addRequestHeader("Content-Type" , "text/plain");
        post.addRequestHeader("Accept" , "text/plain");
        post.setRequestBody("12345");
        HttpClient httpclient = new HttpClient();
       
        try {
View Full Code Here

        String endpointAddress =
            "http://localhost:" + PORT + "/bookstore/booksplain";

        PostMethod post = new PostMethod(endpointAddress);
        post.addRequestHeader("Content-Type" , "text/plain");
        post.addRequestHeader("Accept" , "text/plain");
        post.setRequestBody("12345");
        HttpClient httpclient = new HttpClient();
       
        try {
            int result = httpclient.executeMethod(post);
View Full Code Here

    private String createRelationship(String nodeFrom, String nodeTo,
            String type) {
        try {
            String relationshipUrl = nodeFrom + "/relationships";
            PostMethod method = new PostMethod(relationshipUrl);
            method.addRequestHeader("Accept", this.contentType);
            method.addRequestHeader("Content-Type", this.contentType);
            String body = "{ \"to\": \"" + nodeTo + "\",\"type\":\"" + type
                    + "\"}";
            method.setRequestEntity(new StringRequestEntity(body,
                    this.contentType, "UTF-8"));
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.