View Javadoc
1   /*
2    * ====================================================================
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   * ====================================================================
20   *
21   * This software consists of voluntary contributions made by many
22   * individuals on behalf of the Apache Software Foundation.  For more
23   * information on the Apache Software Foundation, please see
24   * <http://www.apache.org/>.
25   *
26   */
27  package org.apache.http.impl.client.cache;
28  
29  import java.util.Locale;
30  
31  import org.apache.http.Header;
32  import org.apache.http.HeaderIterator;
33  import org.apache.http.HttpEntity;
34  import org.apache.http.HttpResponse;
35  import org.apache.http.HttpStatus;
36  import org.apache.http.HttpVersion;
37  import org.apache.http.ProtocolVersion;
38  import org.apache.http.StatusLine;
39  import org.apache.http.annotation.Contract;
40  import org.apache.http.annotation.ThreadingBehavior;
41  import org.apache.http.message.AbstractHttpMessage;
42  import org.apache.http.message.BasicStatusLine;
43  import org.apache.http.params.BasicHttpParams;
44  import org.apache.http.params.HttpParams;
45  
46  /**
47   * @since 4.1
48   */
49  @SuppressWarnings("deprecation")
50  @Contract(threading = ThreadingBehavior.IMMUTABLE)
51  final class OptionsHttp11Response extends AbstractHttpMessage implements HttpResponse {
52  
53      private final StatusLine statusLine = new BasicStatusLine(HttpVersion.HTTP_1_1,
54              HttpStatus.SC_NOT_IMPLEMENTED, "");
55      private final ProtocolVersion version = HttpVersion.HTTP_1_1;
56  
57      @Override
58      public StatusLine getStatusLine() {
59          return statusLine;
60      }
61  
62      @Override
63      public void setStatusLine(final StatusLine statusline) {
64          // No-op on purpose, this class is not going to be doing any work.
65      }
66  
67      @Override
68      public void setStatusLine(final ProtocolVersion ver, final int code) {
69          // No-op on purpose, this class is not going to be doing any work.
70      }
71  
72      @Override
73      public void setStatusLine(final ProtocolVersion ver, final int code, final String reason) {
74          // No-op on purpose, this class is not going to be doing any work.
75      }
76  
77      @Override
78      public void setStatusCode(final int code) throws IllegalStateException {
79          // No-op on purpose, this class is not going to be doing any work.
80      }
81  
82      @Override
83      public void setReasonPhrase(final String reason) throws IllegalStateException {
84          // No-op on purpose, this class is not going to be doing any work.
85      }
86  
87      @Override
88      public HttpEntity getEntity() {
89          return null;
90      }
91  
92      @Override
93      public void setEntity(final HttpEntity entity) {
94          // No-op on purpose, this class is not going to be doing any work.
95      }
96  
97      @Override
98      public Locale getLocale() {
99          return null;
100     }
101 
102     @Override
103     public void setLocale(final Locale loc) {
104         // No-op on purpose, this class is not going to be doing any work.
105     }
106 
107     @Override
108     public ProtocolVersion getProtocolVersion() {
109         return version;
110     }
111 
112     @Override
113     public boolean containsHeader(final String name) {
114         return this.headergroup.containsHeader(name);
115     }
116 
117     @Override
118     public Header[] getHeaders(final String name) {
119         return this.headergroup.getHeaders(name);
120     }
121 
122     @Override
123     public Header getFirstHeader(final String name) {
124         return this.headergroup.getFirstHeader(name);
125     }
126 
127     @Override
128     public Header getLastHeader(final String name) {
129         return this.headergroup.getLastHeader(name);
130     }
131 
132     @Override
133     public Header[] getAllHeaders() {
134         return this.headergroup.getAllHeaders();
135     }
136 
137     @Override
138     public void addHeader(final Header header) {
139         // No-op on purpose, this class is not going to be doing any work.
140     }
141 
142     @Override
143     public void addHeader(final String name, final String value) {
144         // No-op on purpose, this class is not going to be doing any work.
145     }
146 
147     @Override
148     public void setHeader(final Header header) {
149         // No-op on purpose, this class is not going to be doing any work.
150     }
151 
152     @Override
153     public void setHeader(final String name, final String value) {
154         // No-op on purpose, this class is not going to be doing any work.
155     }
156 
157     @Override
158     public void setHeaders(final Header[] headers) {
159         // No-op on purpose, this class is not going to be doing any work.
160     }
161 
162     @Override
163     public void removeHeader(final Header header) {
164         // No-op on purpose, this class is not going to be doing any work.
165     }
166 
167     @Override
168     public void removeHeaders(final String name) {
169         // No-op on purpose, this class is not going to be doing any work.
170     }
171 
172     @Override
173     public HeaderIterator headerIterator() {
174         return this.headergroup.iterator();
175     }
176 
177     @Override
178     public HeaderIterator headerIterator(final String name) {
179         return this.headergroup.iterator(name);
180     }
181 
182     @Override
183     public HttpParams getParams() {
184         if (this.params == null) {
185             this.params = new BasicHttpParams();
186         }
187         return this.params;
188     }
189 
190     @Override
191     public void setParams(final HttpParams params) {
192         // No-op on purpose, this class is not going to be doing any work.
193     }
194 }