1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package org.apache.commons.httpclient;
29
30 import java.io.IOException;
31 import org.apache.commons.httpclient.methods.PostMethod;
32
33 /***
34 * HTTP POST methid intended to simulate side-effects of
35 * interaction with non-compiant HTTP servers or proxies
36 *
37 * @author Oleg Kalnichevski
38 */
39
40 public class NoncompliantPostMethod extends PostMethod {
41
42 public NoncompliantPostMethod(){
43 super();
44 }
45
46 public NoncompliantPostMethod(String uri) {
47 super(uri);
48 }
49
50 /***
51 * NoncompliantPostMethod class skips "Expect: 100-continue"
52 * header when sending request headers to an HTTP server.
53 *
54 * <p>
55 * That makes the server expect the request body to follow
56 * immediately after the request head. The HTTP server does not
57 * send status code 100 expected by the client. The client should
58 * be able to recover gracefully by sending the request body
59 * after a defined timeout without having received "continue"
60 * code.
61 * </p>
62 */
63 protected void writeRequestHeaders(HttpState state, HttpConnection conn)
64 throws IOException, HttpException {
65 addRequestHeaders(state, conn);
66 Header[] headers = getRequestHeaders();
67 for (int i = 0; i < headers.length; i++) {
68 Header header = headers[i];
69
70 if (!header.getName().equalsIgnoreCase("Expect") ) {
71 conn.print(header.toExternalForm(), "US-ASCII");
72 }
73 }
74 }
75
76 }