View Javadoc

1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License.
18   *
19   */
20  package org.apache.mina.proxy.handlers.http;
21  
22  import java.util.List;
23  import java.util.Map;
24  
25  /**
26   * HttpProxyResponse.java - Wrapper class for HTTP requests.
27   * 
28   * @author The Apache MINA Project (dev@mina.apache.org)
29   * @version $Rev: 685703 $, $Date: 2008-08-14 00:14:47 +0200 (Thu, 14 Aug 2008) $
30   * @since MINA 2.0.0-M3
31   */
32  public class HttpProxyResponse {
33      public final String httpVersion;
34  
35      public final String statusLine;
36  
37      public final int statusCode;
38  
39      public final Map<String, List<String>> headers;
40  
41      public String body;
42  
43      protected HttpProxyResponse(final String httpVersion,
44              final String statusLine, final Map<String, List<String>> headers) {
45          this.httpVersion = httpVersion;
46          this.statusLine = statusLine;
47  
48          this.statusCode = statusLine.charAt(0) == ' ' ? Integer
49                  .parseInt(statusLine.substring(1, 4)) : Integer
50                  .parseInt(statusLine.substring(0, 3));
51  
52          this.headers = headers;
53      }
54  
55      /**
56       * The HTTP version.
57       */
58      public final String getHttpVersion() {
59          return httpVersion;
60      }
61  
62      /**
63       * The HTTP status code.
64       */
65      public final int getStatusCode() {
66          return statusCode;
67      }
68  
69      /**
70       * The HTTP status line.
71       */
72      public final String getStatusLine() {
73          return statusLine;
74      }
75  
76      /**
77       * The HTTP entity body.
78       */
79      public String getBody() {
80          return body;
81      }
82  
83      /**
84       * Sets the HTTP entity body.
85       */
86      public void setBody(String body) {
87          this.body = body;
88      }
89  
90      /**
91       * HTTP headers.
92       */
93      public final Map<String, List<String>> getHeaders() {
94          return headers;
95      }
96  }