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