001package org.apache.maven.wagon.providers.http;
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
028/**
029 * 
030 */
031public class HttpConfiguration
032{
033    
034    private static final HttpMethodConfiguration DEFAULT_PUT =
035        new HttpMethodConfiguration().addParam( HTTP.EXPECT_CONTINUE, "%b,true" );
036
037    private HttpMethodConfiguration all;
038
039    private HttpMethodConfiguration get;
040
041    private HttpMethodConfiguration put;
042
043    private HttpMethodConfiguration head;
044
045    public HttpMethodConfiguration getAll()
046    {
047        return all;
048    }
049
050    public HttpConfiguration setAll( HttpMethodConfiguration all )
051    {
052        this.all = all;
053        return this;
054    }
055
056    public HttpMethodConfiguration getGet()
057    {
058        return get;
059    }
060
061    public HttpConfiguration setGet( HttpMethodConfiguration get )
062    {
063        this.get = get;
064        return this;
065    }
066
067    public HttpMethodConfiguration getPut()
068    {
069        return put;
070    }
071
072    public HttpConfiguration setPut( HttpMethodConfiguration put )
073    {
074        this.put = put;
075        return this;
076    }
077
078    public HttpMethodConfiguration getHead()
079    {
080        return head;
081    }
082
083    public HttpConfiguration setHead( HttpMethodConfiguration head )
084    {
085        this.head = head;
086        return this;
087    }
088
089    public HttpMethodConfiguration getMethodConfiguration( HttpUriRequest method )
090    {
091        if ( method instanceof HttpGet )
092        {
093            return ConfigurationUtils.merge( all, get );
094        }
095        else if ( method instanceof HttpPut )
096        {
097            return ConfigurationUtils.merge( DEFAULT_PUT, all, put );
098        }
099        else if ( method instanceof HttpHead )
100        {
101            return ConfigurationUtils.merge( all, head );
102        }
103
104        return all;
105    }
106
107}