View Javadoc
1   package org.apache.maven.wagon.shared.http;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
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 }