jdk/src/share/classes/java/net/HttpURLConnection.java
author xdono
Thu, 02 Oct 2008 19:58:32 -0700
changeset 1247 b4c26443dee5
parent 2 90ce3da70b43
child 1576 b697b141012d
permissions -rw-r--r--
6754988: Update copyright year Summary: Update for files that have been modified starting July 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1996-2007 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.net;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.InputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.security.Permission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Date;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * A URLConnection with support for HTTP-specific features. See
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <A HREF="http://www.w3.org/pub/WWW/Protocols/"> the spec </A> for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Each HttpURLConnection instance is used to make a single request
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * but the underlying network connection to the HTTP server may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * transparently shared by other instances. Calling the close() methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * on the InputStream or OutputStream of an HttpURLConnection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * after a request may free network resources associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * instance but has no effect on any shared persistent connection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * Calling the disconnect() method may close the underlying socket
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * if a persistent connection is otherwise idle at that time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * <P>The HTTP protocol handler has a few settings that can be accessed through
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * System Properties. This covers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <a href="doc-files/net-properties.html#Proxies">Proxy settings</a> as well as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <a href="doc-files/net-properties.html#MiscHTTP"> various other settings</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * </P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * @see     java.net.HttpURLConnection#disconnect()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * @since JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
abstract public class HttpURLConnection extends URLConnection {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /* instance variables */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * The HTTP method (GET,POST,PUT,etc.).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    protected String method = "GET";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * The chunk-length when using chunked encoding streaming mode for output.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * A value of <code>-1</code> means chunked encoding is disabled for output.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    protected int chunkLength = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * The fixed content-length when using fixed-length streaming mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * A value of <code>-1</code> means fixed-length streaming mode is disabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * for output.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    protected int fixedContentLength = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * Returns the key for the <code>n</code><sup>th</sup> header field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * Some implementations may treat the <code>0</code><sup>th</sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * header field as special, i.e. as the status line returned by the HTTP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * server. In this case, {@link #getHeaderField(int) getHeaderField(0)} returns the status
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * line, but <code>getHeaderFieldKey(0)</code> returns null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * @param   n   an index, where n >=0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * @return  the key for the <code>n</code><sup>th</sup> header field,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *          or <code>null</code> if the key does not exist.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    public String getHeaderFieldKey (int n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * This method is used to enable streaming of a HTTP request body
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * without internal buffering, when the content length is known in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * advance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * An exception will be thrown if the application
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * attempts to write more data than the indicated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * content-length, or if the application closes the OutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * before writing the indicated amount.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * When output streaming is enabled, authentication
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * and redirection cannot be handled automatically.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * A HttpRetryException will be thrown when reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * the response if authentication or redirection are required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * This exception can be queried for the details of the error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * This method must be called before the URLConnection is connected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @param   contentLength The number of bytes which will be written
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *          to the OutputStream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @throws  IllegalStateException if URLConnection is already connected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     *          or if a different streaming mode is already enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @throws  IllegalArgumentException if a content length less than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     *          zero is specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @see     #setChunkedStreamingMode(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    public void setFixedLengthStreamingMode (int contentLength) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        if (connected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            throw new IllegalStateException ("Already connected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        if (chunkLength != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            throw new IllegalStateException ("Chunked encoding streaming mode set");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        if (contentLength < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            throw new IllegalArgumentException ("invalid content length");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        fixedContentLength = contentLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    /* Default chunk size (including chunk header) if not specified;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * we want to keep this in sync with the one defined in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * sun.net.www.http.ChunkedOutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    private static final int DEFAULT_CHUNK_SIZE = 4096;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * This method is used to enable streaming of a HTTP request body
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * without internal buffering, when the content length is <b>not</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * known in advance. In this mode, chunked transfer encoding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * is used to send the request body. Note, not all HTTP servers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * support this mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * When output streaming is enabled, authentication
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * and redirection cannot be handled automatically.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * A HttpRetryException will be thrown when reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * the response if authentication or redirection are required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * This exception can be queried for the details of the error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * This method must be called before the URLConnection is connected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * @param   chunklen The number of bytes to write in each chunk.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     *          If chunklen is less than or equal to zero, a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *          value will be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @throws  IllegalStateException if URLConnection is already connected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *          or if a different streaming mode is already enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @see     #setFixedLengthStreamingMode(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    public void setChunkedStreamingMode (int chunklen) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        if (connected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            throw new IllegalStateException ("Can't set streaming mode: already connected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        if (fixedContentLength != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            throw new IllegalStateException ("Fixed length streaming mode set");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        chunkLength = chunklen <=0? DEFAULT_CHUNK_SIZE : chunklen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * Returns the value for the <code>n</code><sup>th</sup> header field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * Some implementations may treat the <code>0</code><sup>th</sup>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * header field as special, i.e. as the status line returned by the HTTP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * This method can be used in conjunction with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * {@link #getHeaderFieldKey getHeaderFieldKey} method to iterate through all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * the headers in the message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @param   n   an index, where n>=0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @return  the value of the <code>n</code><sup>th</sup> header field,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *          or <code>null</code> if the value does not exist.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @see     java.net.HttpURLConnection#getHeaderFieldKey(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    public String getHeaderField(int n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * An <code>int</code> representing the three digit HTTP Status-Code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * <li> 1xx: Informational
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * <li> 2xx: Success
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * <li> 3xx: Redirection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * <li> 4xx: Client Error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * <li> 5xx: Server Error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    protected int responseCode = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * The HTTP response message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    protected String responseMessage = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    /* static variables */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    /* do we automatically follow redirects? The default is true. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    private static boolean followRedirects = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * If <code>true</code>, the protocol will automatically follow redirects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * If <code>false</code>, the protocol will not automatically follow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * redirects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * This field is set by the <code>setInstanceFollowRedirects</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * method. Its value is returned by the <code>getInstanceFollowRedirects</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * Its default value is based on the value of the static followRedirects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * at HttpURLConnection construction time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * @see     java.net.HttpURLConnection#setInstanceFollowRedirects(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * @see     java.net.HttpURLConnection#getInstanceFollowRedirects()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * @see     java.net.HttpURLConnection#setFollowRedirects(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    protected boolean instanceFollowRedirects = followRedirects;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /* valid HTTP methods */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    private static final String[] methods = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        "GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * Constructor for the HttpURLConnection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * @param u the URL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    protected HttpURLConnection (URL u) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        super(u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * Sets whether HTTP redirects  (requests with response code 3xx) should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * be automatically followed by this class.  True by default.  Applets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * cannot change this variable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * If there is a security manager, this method first calls
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * the security manager's <code>checkSetFactory</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * to ensure the operation is allowed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * This could result in a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * @param set a <code>boolean</code> indicating whether or not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * to follow HTTP redirects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * @exception  SecurityException  if a security manager exists and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     *             <code>checkSetFactory</code> method doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     *             allow the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * @see        SecurityManager#checkSetFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * @see #getFollowRedirects()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    public static void setFollowRedirects(boolean set) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        SecurityManager sec = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        if (sec != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            // seems to be the best check here...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            sec.checkSetFactory();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        followRedirects = set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * Returns a <code>boolean</code> indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * whether or not HTTP redirects (3xx) should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * be automatically followed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @return <code>true</code> if HTTP redirects should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * be automatically followed, <tt>false</tt> if not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * @see #setFollowRedirects(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    public static boolean getFollowRedirects() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        return followRedirects;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * Sets whether HTTP redirects (requests with response code 3xx) should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * be automatically followed by this <code>HttpURLConnection</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * The default value comes from followRedirects, which defaults to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * @param followRedirects a <code>boolean</code> indicating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * whether or not to follow HTTP redirects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * @see    java.net.HttpURLConnection#instanceFollowRedirects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * @see #getInstanceFollowRedirects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     public void setInstanceFollowRedirects(boolean followRedirects) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        instanceFollowRedirects = followRedirects;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * Returns the value of this <code>HttpURLConnection</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * <code>instanceFollowRedirects</code> field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * @return  the value of this <code>HttpURLConnection</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     *          <code>instanceFollowRedirects</code> field.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * @see     java.net.HttpURLConnection#instanceFollowRedirects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * @see #setInstanceFollowRedirects(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     public boolean getInstanceFollowRedirects() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
         return instanceFollowRedirects;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * Set the method for the URL request, one of:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * <UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     *  <LI>GET
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     *  <LI>POST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     *  <LI>HEAD
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     *  <LI>OPTIONS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     *  <LI>PUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     *  <LI>DELETE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     *  <LI>TRACE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * </UL> are legal, subject to protocol restrictions.  The default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * method is GET.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * @param method the HTTP method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * @exception ProtocolException if the method cannot be reset or if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     *              the requested method isn't valid for HTTP.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * @see #getRequestMethod()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    public void setRequestMethod(String method) throws ProtocolException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        if (connected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            throw new ProtocolException("Can't reset method: already connected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        // This restriction will prevent people from using this class to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        // experiment w/ new HTTP methods using java.  But it should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        // be placed for security - the request String could be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        // arbitrarily long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        for (int i = 0; i < methods.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            if (methods[i].equals(method)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                this.method = method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        throw new ProtocolException("Invalid HTTP method: " + method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * Get the request method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * @return the HTTP request method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * @see #setRequestMethod(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    public String getRequestMethod() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        return method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * Gets the status code from an HTTP response message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * For example, in the case of the following status lines:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * HTTP/1.0 200 OK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * HTTP/1.0 401 Unauthorized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * It will return 200 and 401 respectively.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * Returns -1 if no code can be discerned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * from the response (i.e., the response is not valid HTTP).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * @throws IOException if an error occurred connecting to the server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * @return the HTTP Status-Code, or -1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    public int getResponseCode() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
         * We're got the response code already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        if (responseCode != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            return responseCode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
         * Ensure that we have connected to the server. Record
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
         * exception as we need to re-throw it if there isn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
         * a status line.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        Exception exc = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            getInputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            exc = e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
         * If we can't a status-line then re-throw any exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
         * that getInputStream threw.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        String statusLine = getHeaderField(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        if (statusLine == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            if (exc != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                if (exc instanceof RuntimeException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                    throw (RuntimeException)exc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                    throw (IOException)exc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
         * Examine the status-line - should be formatted as per
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
         * section 6.1 of RFC 2616 :-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
         * Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
         * If status line can't be parsed return -1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        if (statusLine.startsWith("HTTP/1.")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
            int codePos = statusLine.indexOf(' ');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            if (codePos > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                int phrasePos = statusLine.indexOf(' ', codePos+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                if (phrasePos > 0 && phrasePos < statusLine.length()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                    responseMessage = statusLine.substring(phrasePos+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                // deviation from RFC 2616 - don't reject status line
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                // if SP Reason-Phrase is not included.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                if (phrasePos < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                    phrasePos = statusLine.length();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                    responseCode = Integer.parseInt
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                            (statusLine.substring(codePos+1, phrasePos));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                    return responseCode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                } catch (NumberFormatException e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * Gets the HTTP response message, if any, returned along with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * response code from a server.  From responses like:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * HTTP/1.0 200 OK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * HTTP/1.0 404 Not Found
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * Extracts the Strings "OK" and "Not Found" respectively.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * Returns null if none could be discerned from the responses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * (the result was not valid HTTP).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * @throws IOException if an error occurred connecting to the server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * @return the HTTP response message, or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    public String getResponseMessage() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        getResponseCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        return responseMessage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    public long getHeaderFieldDate(String name, long Default) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        String dateString = getHeaderField(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            if (dateString.indexOf("GMT") == -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                dateString = dateString+" GMT";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            return Date.parse(dateString);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        return Default;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * Indicates that other requests to the server
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * are unlikely in the near future. Calling disconnect()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * should not imply that this HttpURLConnection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * instance can be reused for other requests.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    public abstract void disconnect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * Indicates if the connection is going through a proxy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * @return a boolean indicating if the connection is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * using a proxy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    public abstract boolean usingProxy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * Returns a {@link SocketPermission} object representing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * permission necessary to connect to the destination host and port.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * @exception IOException if an error occurs while computing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     *            the permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * @return a <code>SocketPermission</code> object representing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     *         permission necessary to connect to the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     *         host and port.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    public Permission getPermission() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        int port = url.getPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        port = port < 0 ? 80 : port;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        String host = url.getHost() + ":" + port;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        Permission permission = new SocketPermission(host, "connect");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        return permission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    * Returns the error stream if the connection failed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    * but the server sent useful data nonetheless. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    * typical example is when an HTTP server responds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    * with a 404, which will cause a FileNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    * to be thrown in connect, but the server sent an HTML
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    * help page with suggestions as to what to do.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    * <p>This method will not cause a connection to be initiated.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    * the connection was not connected, or if the server did not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
    * an error while connecting or if the server had an error but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    * no error data was sent, this method will return null. This is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    * the default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    * @return an error stream if any, null if there have been no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    * errors, the connection is not connected or the server sent no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    * useful data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    public InputStream getErrorStream() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * The response codes for HTTP, as of version 1.1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    // REMIND: do we want all these??
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    // Others not here that we do want??
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    /* 2XX: generally "OK" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * HTTP Status-Code 200: OK.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    public static final int HTTP_OK = 200;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * HTTP Status-Code 201: Created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    public static final int HTTP_CREATED = 201;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * HTTP Status-Code 202: Accepted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    public static final int HTTP_ACCEPTED = 202;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * HTTP Status-Code 203: Non-Authoritative Information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    public static final int HTTP_NOT_AUTHORITATIVE = 203;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * HTTP Status-Code 204: No Content.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
    public static final int HTTP_NO_CONTENT = 204;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * HTTP Status-Code 205: Reset Content.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    public static final int HTTP_RESET = 205;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * HTTP Status-Code 206: Partial Content.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    public static final int HTTP_PARTIAL = 206;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    /* 3XX: relocation/redirect */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * HTTP Status-Code 300: Multiple Choices.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    public static final int HTTP_MULT_CHOICE = 300;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * HTTP Status-Code 301: Moved Permanently.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    public static final int HTTP_MOVED_PERM = 301;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * HTTP Status-Code 302: Temporary Redirect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    public static final int HTTP_MOVED_TEMP = 302;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * HTTP Status-Code 303: See Other.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    public static final int HTTP_SEE_OTHER = 303;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * HTTP Status-Code 304: Not Modified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    public static final int HTTP_NOT_MODIFIED = 304;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * HTTP Status-Code 305: Use Proxy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    public static final int HTTP_USE_PROXY = 305;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    /* 4XX: client error */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * HTTP Status-Code 400: Bad Request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    public static final int HTTP_BAD_REQUEST = 400;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * HTTP Status-Code 401: Unauthorized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    public static final int HTTP_UNAUTHORIZED = 401;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * HTTP Status-Code 402: Payment Required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    public static final int HTTP_PAYMENT_REQUIRED = 402;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * HTTP Status-Code 403: Forbidden.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
    public static final int HTTP_FORBIDDEN = 403;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * HTTP Status-Code 404: Not Found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    public static final int HTTP_NOT_FOUND = 404;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * HTTP Status-Code 405: Method Not Allowed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    public static final int HTTP_BAD_METHOD = 405;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * HTTP Status-Code 406: Not Acceptable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    public static final int HTTP_NOT_ACCEPTABLE = 406;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * HTTP Status-Code 407: Proxy Authentication Required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    public static final int HTTP_PROXY_AUTH = 407;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     * HTTP Status-Code 408: Request Time-Out.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    public static final int HTTP_CLIENT_TIMEOUT = 408;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     * HTTP Status-Code 409: Conflict.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    public static final int HTTP_CONFLICT = 409;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     * HTTP Status-Code 410: Gone.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    public static final int HTTP_GONE = 410;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     * HTTP Status-Code 411: Length Required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    public static final int HTTP_LENGTH_REQUIRED = 411;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * HTTP Status-Code 412: Precondition Failed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    public static final int HTTP_PRECON_FAILED = 412;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * HTTP Status-Code 413: Request Entity Too Large.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    public static final int HTTP_ENTITY_TOO_LARGE = 413;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * HTTP Status-Code 414: Request-URI Too Large.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    public static final int HTTP_REQ_TOO_LONG = 414;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * HTTP Status-Code 415: Unsupported Media Type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    public static final int HTTP_UNSUPPORTED_TYPE = 415;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
    /* 5XX: server error */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * HTTP Status-Code 500: Internal Server Error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * @deprecated   it is misplaced and shouldn't have existed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    public static final int HTTP_SERVER_ERROR = 500;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * HTTP Status-Code 500: Internal Server Error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
    public static final int HTTP_INTERNAL_ERROR = 500;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * HTTP Status-Code 501: Not Implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    public static final int HTTP_NOT_IMPLEMENTED = 501;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     * HTTP Status-Code 502: Bad Gateway.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    public static final int HTTP_BAD_GATEWAY = 502;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * HTTP Status-Code 503: Service Unavailable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    public static final int HTTP_UNAVAILABLE = 503;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * HTTP Status-Code 504: Gateway Timeout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    public static final int HTTP_GATEWAY_TIMEOUT = 504;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     * HTTP Status-Code 505: HTTP Version Not Supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    public static final int HTTP_VERSION = 505;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
}