001package org.apache.maven.wagon.shared.http4;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *   http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.http.client.methods.HttpGet;
023import org.apache.http.client.methods.HttpHead;
024import org.apache.http.client.methods.HttpPut;
025import org.apache.http.client.methods.HttpUriRequest;
026import org.apache.http.protocol.HTTP;
027
028public class HttpConfiguration
029{
030    
031    private static final HttpMethodConfiguration DEFAULT_PUT =
032        new HttpMethodConfiguration().addParam( HTTP.EXPECT_CONTINUE, "%b,true" );
033
034    private HttpMethodConfiguration all;
035
036    private HttpMethodConfiguration get;
037
038    private HttpMethodConfiguration put;
039
040    private HttpMethodConfiguration head;
041
042    public HttpMethodConfiguration getAll()
043    {
044        return all;
045    }
046
047    public HttpConfiguration setAll( HttpMethodConfiguration all )
048    {
049        this.all = all;
050        return this;
051    }
052
053    public HttpMethodConfiguration getGet()
054    {
055        return get;
056    }
057
058    public HttpConfiguration setGet( HttpMethodConfiguration get )
059    {
060        this.get = get;
061        return this;
062    }
063
064    public HttpMethodConfiguration getPut()
065    {
066        return put;
067    }
068
069    public HttpConfiguration setPut( HttpMethodConfiguration put )
070    {
071        this.put = put;
072        return this;
073    }
074
075    public HttpMethodConfiguration getHead()
076    {
077        return head;
078    }
079
080    public HttpConfiguration setHead( HttpMethodConfiguration head )
081    {
082        this.head = head;
083        return this;
084    }
085
086    public HttpMethodConfiguration getMethodConfiguration( HttpUriRequest method )
087    {
088        if ( method instanceof HttpGet )
089        {
090            return HttpMethodConfiguration.merge( all, get );
091        }
092        else if ( method instanceof HttpPut )
093        {
094            return HttpMethodConfiguration.merge( DEFAULT_PUT, all, put );
095        }
096        else if ( method instanceof HttpHead )
097        {
098            return HttpMethodConfiguration.merge( all, head );
099        }
100
101        return all;
102    }
103
104}