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.http.client.methods.HttpGet;
23 import org.apache.http.client.methods.HttpHead;
24 import org.apache.http.client.methods.HttpPut;
25 import org.apache.http.client.methods.HttpUriRequest;
26
27
28
29
30 public class HttpConfiguration
31 {
32
33 private static final HttpMethodConfiguration DEFAULT_PUT =
34 new HttpMethodConfiguration().addParam( "http.protocol.expect-continue", "%b,true" );
35
36 private HttpMethodConfiguration all;
37
38 private HttpMethodConfiguration get;
39
40 private HttpMethodConfiguration put;
41
42 private HttpMethodConfiguration head;
43
44 public HttpMethodConfiguration getAll()
45 {
46 return all;
47 }
48
49 public HttpConfiguration setAll( HttpMethodConfiguration all )
50 {
51 this.all = all;
52 return this;
53 }
54
55 public HttpMethodConfiguration getGet()
56 {
57 return get;
58 }
59
60 public HttpConfiguration setGet( HttpMethodConfiguration get )
61 {
62 this.get = get;
63 return this;
64 }
65
66 public HttpMethodConfiguration getPut()
67 {
68 return put;
69 }
70
71 public HttpConfiguration setPut( HttpMethodConfiguration put )
72 {
73 this.put = put;
74 return this;
75 }
76
77 public HttpMethodConfiguration getHead()
78 {
79 return head;
80 }
81
82 public HttpConfiguration setHead( HttpMethodConfiguration head )
83 {
84 this.head = head;
85 return this;
86 }
87
88 public HttpMethodConfiguration getMethodConfiguration( HttpUriRequest method )
89 {
90 if ( method instanceof HttpGet )
91 {
92 return ConfigurationUtils.merge( all, get );
93 }
94 else if ( method instanceof HttpPut )
95 {
96 return ConfigurationUtils.merge( DEFAULT_PUT, all, put );
97 }
98 else if ( method instanceof HttpHead )
99 {
100 return ConfigurationUtils.merge( all, head );
101 }
102
103 return all;
104 }
105
106 }