1 | |
package org.apache.maven.wagon.shared.http; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.commons.httpclient.HttpMethod; |
23 | |
import org.apache.commons.httpclient.methods.GetMethod; |
24 | |
import org.apache.commons.httpclient.methods.HeadMethod; |
25 | |
import org.apache.commons.httpclient.methods.PutMethod; |
26 | |
import org.apache.commons.httpclient.params.HttpClientParams; |
27 | |
|
28 | 4 | public class HttpConfiguration |
29 | |
{ |
30 | |
|
31 | 1 | private static final HttpMethodConfiguration DEFAULT_PUT = |
32 | |
new HttpMethodConfiguration().addParam( HttpClientParams.USE_EXPECT_CONTINUE, "%b,true" ); |
33 | |
|
34 | |
private HttpMethodConfiguration all; |
35 | |
|
36 | |
private HttpMethodConfiguration get; |
37 | |
|
38 | |
private HttpMethodConfiguration put; |
39 | |
|
40 | |
private HttpMethodConfiguration head; |
41 | |
|
42 | |
public HttpMethodConfiguration getAll() |
43 | |
{ |
44 | 0 | return all; |
45 | |
} |
46 | |
|
47 | |
public HttpConfiguration setAll( HttpMethodConfiguration all ) |
48 | |
{ |
49 | 4 | this.all = all; |
50 | 4 | return this; |
51 | |
} |
52 | |
|
53 | |
public HttpMethodConfiguration getGet() |
54 | |
{ |
55 | 0 | return get; |
56 | |
} |
57 | |
|
58 | |
public HttpConfiguration setGet( HttpMethodConfiguration get ) |
59 | |
{ |
60 | 0 | this.get = get; |
61 | 0 | return this; |
62 | |
} |
63 | |
|
64 | |
public HttpMethodConfiguration getPut() |
65 | |
{ |
66 | 0 | return put; |
67 | |
} |
68 | |
|
69 | |
public HttpConfiguration setPut( HttpMethodConfiguration put ) |
70 | |
{ |
71 | 0 | this.put = put; |
72 | 0 | return this; |
73 | |
} |
74 | |
|
75 | |
public HttpMethodConfiguration getHead() |
76 | |
{ |
77 | 0 | return head; |
78 | |
} |
79 | |
|
80 | |
public HttpConfiguration setHead( HttpMethodConfiguration head ) |
81 | |
{ |
82 | 0 | this.head = head; |
83 | 0 | return this; |
84 | |
} |
85 | |
|
86 | |
public HttpMethodConfiguration getMethodConfiguration( HttpMethod method ) |
87 | |
{ |
88 | 4 | if ( method instanceof GetMethod ) |
89 | |
{ |
90 | 0 | return HttpMethodConfiguration.merge( all, get ); |
91 | |
} |
92 | 4 | else if ( method instanceof PutMethod ) |
93 | |
{ |
94 | 0 | return HttpMethodConfiguration.merge( DEFAULT_PUT, all, put ); |
95 | |
} |
96 | 4 | else if ( method instanceof HeadMethod ) |
97 | |
{ |
98 | 4 | return HttpMethodConfiguration.merge( all, head ); |
99 | |
} |
100 | |
|
101 | 0 | return all; |
102 | |
} |
103 | |
|
104 | |
} |