92 * @since 1.5
93 */
94 protected int fixedContentLength = -1;
95
96 /**
97 * The fixed content-length when using fixed-length streaming mode.
98 * A value of {@code -1} means fixed-length streaming mode is disabled
99 * for output.
100 *
101 * @since 1.7
102 */
103 protected long fixedContentLengthLong = -1;
104
105 /**
106 * Returns the key for the <code>n</code><sup>th</sup> header field.
107 * Some implementations may treat the <code>0</code><sup>th</sup>
108 * header field as special, i.e. as the status line returned by the HTTP
109 * server. In this case, {@link #getHeaderField(int) getHeaderField(0)} returns the status
110 * line, but <code>getHeaderFieldKey(0)</code> returns null.
111 *
112 * @param n an index, where n >=0.
113 * @return the key for the <code>n</code><sup>th</sup> header field,
114 * or <code>null</code> if the key does not exist.
115 */
116 public String getHeaderFieldKey (int n) {
117 return null;
118 }
119
120 /**
121 * This method is used to enable streaming of a HTTP request body
122 * without internal buffering, when the content length is known in
123 * advance.
124 * <p>
125 * An exception will be thrown if the application
126 * attempts to write more data than the indicated
127 * content-length, or if the application closes the OutputStream
128 * before writing the indicated amount.
129 * <p>
130 * When output streaming is enabled, authentication
131 * and redirection cannot be handled automatically.
132 * A HttpRetryException will be thrown when reading
243 public void setChunkedStreamingMode (int chunklen) {
244 if (connected) {
245 throw new IllegalStateException ("Can't set streaming mode: already connected");
246 }
247 if (fixedContentLength != -1 || fixedContentLengthLong != -1) {
248 throw new IllegalStateException ("Fixed length streaming mode set");
249 }
250 chunkLength = chunklen <=0? DEFAULT_CHUNK_SIZE : chunklen;
251 }
252
253 /**
254 * Returns the value for the <code>n</code><sup>th</sup> header field.
255 * Some implementations may treat the <code>0</code><sup>th</sup>
256 * header field as special, i.e. as the status line returned by the HTTP
257 * server.
258 * <p>
259 * This method can be used in conjunction with the
260 * {@link #getHeaderFieldKey getHeaderFieldKey} method to iterate through all
261 * the headers in the message.
262 *
263 * @param n an index, where n>=0.
264 * @return the value of the <code>n</code><sup>th</sup> header field,
265 * or <code>null</code> if the value does not exist.
266 * @see java.net.HttpURLConnection#getHeaderFieldKey(int)
267 */
268 public String getHeaderField(int n) {
269 return null;
270 }
271
272 /**
273 * An <code>int</code> representing the three digit HTTP Status-Code.
274 * <ul>
275 * <li> 1xx: Informational
276 * <li> 2xx: Success
277 * <li> 3xx: Redirection
278 * <li> 4xx: Client Error
279 * <li> 5xx: Server Error
280 * </ul>
281 */
282 protected int responseCode = -1;
283
|
92 * @since 1.5
93 */
94 protected int fixedContentLength = -1;
95
96 /**
97 * The fixed content-length when using fixed-length streaming mode.
98 * A value of {@code -1} means fixed-length streaming mode is disabled
99 * for output.
100 *
101 * @since 1.7
102 */
103 protected long fixedContentLengthLong = -1;
104
105 /**
106 * Returns the key for the <code>n</code><sup>th</sup> header field.
107 * Some implementations may treat the <code>0</code><sup>th</sup>
108 * header field as special, i.e. as the status line returned by the HTTP
109 * server. In this case, {@link #getHeaderField(int) getHeaderField(0)} returns the status
110 * line, but <code>getHeaderFieldKey(0)</code> returns null.
111 *
112 * @param n an index, where {@code n >=0}.
113 * @return the key for the <code>n</code><sup>th</sup> header field,
114 * or <code>null</code> if the key does not exist.
115 */
116 public String getHeaderFieldKey (int n) {
117 return null;
118 }
119
120 /**
121 * This method is used to enable streaming of a HTTP request body
122 * without internal buffering, when the content length is known in
123 * advance.
124 * <p>
125 * An exception will be thrown if the application
126 * attempts to write more data than the indicated
127 * content-length, or if the application closes the OutputStream
128 * before writing the indicated amount.
129 * <p>
130 * When output streaming is enabled, authentication
131 * and redirection cannot be handled automatically.
132 * A HttpRetryException will be thrown when reading
243 public void setChunkedStreamingMode (int chunklen) {
244 if (connected) {
245 throw new IllegalStateException ("Can't set streaming mode: already connected");
246 }
247 if (fixedContentLength != -1 || fixedContentLengthLong != -1) {
248 throw new IllegalStateException ("Fixed length streaming mode set");
249 }
250 chunkLength = chunklen <=0? DEFAULT_CHUNK_SIZE : chunklen;
251 }
252
253 /**
254 * Returns the value for the <code>n</code><sup>th</sup> header field.
255 * Some implementations may treat the <code>0</code><sup>th</sup>
256 * header field as special, i.e. as the status line returned by the HTTP
257 * server.
258 * <p>
259 * This method can be used in conjunction with the
260 * {@link #getHeaderFieldKey getHeaderFieldKey} method to iterate through all
261 * the headers in the message.
262 *
263 * @param n an index, where {@code n>=0}.
264 * @return the value of the <code>n</code><sup>th</sup> header field,
265 * or <code>null</code> if the value does not exist.
266 * @see java.net.HttpURLConnection#getHeaderFieldKey(int)
267 */
268 public String getHeaderField(int n) {
269 return null;
270 }
271
272 /**
273 * An <code>int</code> representing the three digit HTTP Status-Code.
274 * <ul>
275 * <li> 1xx: Informational
276 * <li> 2xx: Success
277 * <li> 3xx: Redirection
278 * <li> 4xx: Client Error
279 * <li> 5xx: Server Error
280 * </ul>
281 */
282 protected int responseCode = -1;
283
|