2 Copyright (C) 2004 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package gnu
.java
.net
.protocol
.http
;
41 import java
.io
.InputStream
;
42 import java
.util
.Date
;
47 * @author Chris Burdess (dog@gnu.org)
53 * The HTTP major version of the server issuing the response.
55 protected final int majorVersion
;
58 * The HTTP minor version of the server issuing the response.
60 protected final int minorVersion
;
63 * The HTTP status code of the response.
65 protected final int code
;
68 * Human-readable text of the response.
70 protected final String message
;
73 * The response headers.
75 protected final Headers headers
;
78 * An InputStream that returns the body of the response.
80 protected final InputStream body
;
83 * Constructs a new response with the specified parameters.
85 protected Response(int majorVersion
, int minorVersion
, int code
,
86 String message
, Headers headers
, InputStream body
)
88 this.majorVersion
= majorVersion
;
89 this.minorVersion
= minorVersion
;
91 this.message
= message
;
92 this.headers
= headers
;
97 * Returns the HTTP major version of the server issuing the response.
100 public int getMajorVersion()
106 * Returns the HTTP minor version of the server issuing the response.
109 public int getMinorVersion()
115 * Returns the HTTP status code of the response.
124 * Returns the class of the response. This is the most significant
125 * digit of the status code.
127 * <dt><code>1xx</code></dt> <dd>Informational response</dd>
128 * <dt><code>2xx</code></dt> <dd>Success</dd>
129 * <dt><code>3xx</code></dt> <dd>Redirection</dd>
130 * <dt><code>4xx</code></dt> <dd>Client error</dd>
131 * <dt><code>5xx</code></dt> <dd>Server error</dd>
134 public int getCodeClass()
140 * Returns the human-readable text of the response.
143 public String
getMessage()
149 * Returns the headers in the response.
151 public Headers
getHeaders()
157 * Returns the header value for the specified name.
158 * @param name the header name
160 public String
getHeader(String name
)
162 return headers
.getValue(name
);
166 * Returns the header value for the specified name as an integer.
167 * @param name the header name
169 public int getIntHeader(String name
)
171 return headers
.getIntValue(name
);
175 * Returns the header value for the specified name as a long.
176 * @param name the header name
178 public long getLongHeader(String name
)
180 return headers
.getLongValue(name
);
184 * Returns the header value for the specified name as a date.
185 * @param name the header name
187 public Date
getDateHeader(String name
)
189 return headers
.getDateValue(name
);
193 * Returns an InputStream that returns the body of the response.
195 * @return the body of the response
197 public InputStream
getBody()