-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathRoResponse.java
More file actions
183 lines (168 loc) · 6.71 KB
/
RoResponse.java
File metadata and controls
183 lines (168 loc) · 6.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
* @(#)RoResponse.java 0.3-3 06/05/2001
*
* This file is part of the HTTPClient package
* Copyright (C) 1996-2001 Ronald Tschal�r
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307, USA
*
* For questions, suggestions, bug-reports, enhancement-requests etc.
* I may be contacted at:
*
* ronald@innovation.ch
*
* The HTTPClient's home page is located at:
*
* http://www.innovation.ch/java/HTTPClient/
*
*/
package HTTPClient;
import java.io.InputStream;
import java.io.IOException;
import java.util.Date;
/**
* This interface represents read-only interface of an intermediate http
* response. It is the compile-time type passed to various handlers which
* might the response info but musn't modify the response.
*
* @version 0.3-3 06/05/2001
* @author Ronald Tschal�r
*/
public interface RoResponse
{
/**
* give the status code for this request. These are grouped as follows:
* <UL>
* <LI> 1xx - Informational (new in HTTP/1.1)
* <LI> 2xx - Success
* <LI> 3xx - Redirection
* <LI> 4xx - Client Error
* <LI> 5xx - Server Error
* </UL>
*
* @return the status code
* @exception IOException If any exception occurs on the socket.
*/
public int getStatusCode() throws IOException;
/**
* @return the reason line associated with the status code.
* @exception IOException If any exception occurs on the socket.
*/
public String getReasonLine() throws IOException;
/**
* @return the HTTP version returned by the server.
* @exception IOException If any exception occurs on the socket.
*/
public String getVersion() throws IOException;
/**
* retrieves the field for a given header.
*
* @param hdr the header name.
* @return the value for the header, or null if non-existent.
* @exception IOException If any exception occurs on the socket.
*/
public String getHeader(String hdr) throws IOException;
/**
* retrieves the field for a given header. The value is parsed as an
* int.
*
* @param hdr the header name.
* @return the value for the header if the header exists
* @exception NumberFormatException if the header's value is not a number
* or if the header does not exist.
* @exception IOException if any exception occurs on the socket.
*/
public int getHeaderAsInt(String hdr)
throws IOException, NumberFormatException;
/**
* retrieves the field for a given header. The value is parsed as a
* date; if this fails it is parsed as a long representing the number
* of seconds since 12:00 AM, Jan 1st, 1970. If this also fails an
* IllegalArgumentException is thrown.
*
* @param hdr the header name.
* @return the value for the header, or null if non-existent.
* @exception IOException If any exception occurs on the socket.
* @exception IllegalArgumentException If the header cannot be parsed
* as a date or time.
*/
public Date getHeaderAsDate(String hdr)
throws IOException, IllegalArgumentException;
/**
* Retrieves the field for a given trailer. Note that this should not
* be invoked until all the response data has been read. If invoked
* before, it will force the data to be read via <code>getData()</code>.
*
* @param trailer the trailer name.
* @return the value for the trailer, or null if non-existent.
* @exception IOException If any exception occurs on the socket.
*/
public String getTrailer(String trailer) throws IOException;
/**
* Retrieves the field for a given tailer. The value is parsed as an
* int.
*
* @param trailer the tailer name.
* @return the value for the trailer if the trailer exists
* @exception NumberFormatException if the trailer's value is not a number
* or if the trailer does not exist.
* @exception IOException if any exception occurs on the socket.
*/
public int getTrailerAsInt(String trailer)
throws IOException, NumberFormatException;
/**
* Retrieves the field for a given trailer. The value is parsed as a
* date; if this fails it is parsed as a long representing the number
* of seconds since 12:00 AM, Jan 1st, 1970. If this also fails an
* IllegalArgumentException is thrown.
* <br>Note: When sending dates use Util.httpDate().
*
* @param trailer the trailer name.
* @return the value for the trailer, or null if non-existent.
* @exception IllegalArgumentException if the trailer's value is neither a
* legal date nor a number.
* @exception IOException if any exception occurs on the socket.
* @exception IllegalArgumentException If the header cannot be parsed
* as a date or time.
*/
public Date getTrailerAsDate(String trailer)
throws IOException, IllegalArgumentException;
/**
* Reads all the response data into a byte array. Note that this method
* won't return until <em>all</em> the data has been received (so for
* instance don't invoke this method if the server is doing a server
* push). If getInputStream() had been previously called then this method
* only returns any unread data remaining on the stream and then closes
* it.
*
* @see #getInputStream()
* @return an array containing the data (body) returned. If no data
* was returned then it's set to a zero-length array.
* @exception IOException If any io exception occured while reading
* the data
*/
public byte[] getData() throws IOException;
/**
* Gets an input stream from which the returned data can be read. Note
* that if getData() had been previously called it will actually return
* a ByteArrayInputStream created from that data.
*
* @see #getData()
* @return the InputStream.
* @exception IOException If any exception occurs on the socket.
*/
public InputStream getInputStream() throws IOException;
}