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 package org.apache.commons.httpclient;
28
29 import java.io.IOException;
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 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, HttpException {
64 addRequestHeaders(state, conn);
65 Header[] headers = getRequestHeaders();
66 for (int i = 0; i < headers.length; i++) {
67 Header header = headers[i];
68
69 if (!header.getName().equalsIgnoreCase("Expect") ) {
70 conn.print(header.toExternalForm(), "US-ASCII");
71 }
72 }
73 }
74
75 }