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