1 /******************************************************************************* 2 * Copyright (c) 2011 Michael Mimo Moratti. 3 * 4 * Michael Mimo Moratti licenses this file to you under the Apache License, version 2.0 5 * (the "License"); you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at: 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * Unless required by applicable law or agreed to in writing, software 9 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 10 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 11 * License for the specific language governing permissions and limitations 12 * under the License. 13 *******************************************************************************/ 14 package ch.mimo.netty.handler.codec.icap; 15 16 17 /** 18 * Main Icap Request implementation. This is the starting point to create a Icap request. 19 * 20 * @author Michael Mimo Moratti (mimo@mimo.ch) 21 * 22 */ 23 public class DefaultIcapRequest extends AbstractIcapMessage implements IcapRequest { 24 25 private IcapMethod method; 26 private String uri; 27 28 /** 29 * This will create an initial icap request with all necessary details. 30 * 31 * @param icapVersion the version of this request. 32 * @param method the method. 33 * @param uri the uri to reach with this request. 34 * @param host the host from where this request originates from. Because this is a mandatory Icap header 35 * you have to give a value and it will be directly added to the icap request as Host: header. 36 */ 37 public DefaultIcapRequest(IcapVersion icapVersion, IcapMethod method, String uri, String host) { 38 super(icapVersion); 39 this.method = method; 40 this.uri = uri; 41 addHeader(IcapHeaders.Names.HOST,host); 42 } 43 44 public IcapMessage setMethod(IcapMethod method) { 45 this.method = method; 46 return this; 47 } 48 49 public IcapMethod getMethod() { 50 return method; 51 } 52 53 public IcapMessage setUri(String uri) { 54 this.uri = uri; 55 return this; 56 } 57 58 public String getUri() { 59 return uri; 60 } 61 }