Dead
[official-gcc.git] / gomp-20050608-branch / libjava / classpath / gnu / java / net / protocol / http / Response.java
blob58d74542c308ce91a9abee086d65faa5b1b984c7
1 /* Response.java --
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)
9 any later version.
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
19 02110-1301 USA.
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
24 combination.
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;
44 /**
45 * An HTTP response.
47 * @author Chris Burdess (dog@gnu.org)
49 public class Response
52 /**
53 * The HTTP major version of the server issuing the response.
55 protected final int majorVersion;
57 /**
58 * The HTTP minor version of the server issuing the response.
60 protected final int minorVersion;
62 /**
63 * The HTTP status code of the response.
64 */
65 protected final int code;
67 /**
68 * Human-readable text of the response.
70 protected final String message;
72 /**
73 * The response headers.
75 protected final Headers headers;
77 /**
78 * An InputStream that returns the body of the response.
80 protected final InputStream body;
82 /**
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;
90 this.code = code;
91 this.message = message;
92 this.headers = headers;
93 this.body = body;
96 /**
97 * Returns the HTTP major version of the server issuing the response.
98 * @see #majorVersion
100 public int getMajorVersion()
102 return majorVersion;
106 * Returns the HTTP minor version of the server issuing the response.
107 * @see #minorVersion
109 public int getMinorVersion()
111 return minorVersion;
115 * Returns the HTTP status code of the response.
116 * @see #code
118 public int getCode()
120 return code;
124 * Returns the class of the response. This is the most significant
125 * digit of the status code.
126 * <dl>
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>
132 * </dl>
134 public int getCodeClass()
136 return code / 100;
140 * Returns the human-readable text of the response.
141 * @see #message
143 public String getMessage()
145 return message;
149 * Returns the headers in the response.
151 public Headers getHeaders()
153 return headers;
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()
199 return body;