KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > httpclient > NoncompliantPostMethod


1 /*
2  * ====================================================================
3  *
4  * Copyright 2003-2004 The Apache Software Foundation
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  * ====================================================================
18  *
19  * This software consists of voluntary contributions made by many
20  * individuals on behalf of the Apache Software Foundation. For more
21  * information on the Apache Software Foundation, please see
22  * <http://www.apache.org/>.
23  *
24  * [Additional notices, if required by prior licensing conditions]
25  *
26  */

27 package org.apache.commons.httpclient;
28
29 import java.io.IOException JavaDoc;
30 import org.apache.commons.httpclient.methods.PostMethod;
31
32 /**
33  * HTTP POST methid intended to simulate side-effects of
34  * interaction with non-compiant HTTP servers or proxies
35  *
36  * @author Oleg Kalnichevski
37  */

38
39 public class NoncompliantPostMethod extends PostMethod {
40
41     public NoncompliantPostMethod(){
42         super();
43     }
44
45     public NoncompliantPostMethod(String JavaDoc uri) {
46         super(uri);
47     }
48
49     /**
50      * NoncompliantPostMethod class skips "Expect: 100-continue"
51      * header when sending request headers to an HTTP server.
52      *
53      * <p>
54      * That makes the server expect the request body to follow
55      * immediately after the request head. The HTTP server does not
56      * send status code 100 expected by the client. The client should
57      * be able to recover gracefully by sending the request body
58      * after a defined timeout without having received "continue"
59      * code.
60      * </p>
61      */

62     protected void writeRequestHeaders(HttpState state, HttpConnection conn)
63         throws IOException JavaDoc, HttpException {
64         addRequestHeaders(state, conn);
65         Header[] headers = getRequestHeaders();
66         for (int i = 0; i < headers.length; i++) {
67             Header header = headers[i];
68             // Write all the headers but "Expect"
69
if (!header.getName().equalsIgnoreCase("Expect") ) {
70                 conn.print(header.toExternalForm());
71             }
72         }
73     }
74
75 }
76
Popular Tags