src/java.base/share/classes/java/net/HttpURLConnection.java
author jboes
Fri, 01 Nov 2019 12:57:01 +0000
changeset 58896 bd9daab73a8e
parent 58242 94bb65cb37d3
permissions -rw-r--r--
8231632: HttpURLConnection::usingProxy could specify that it may lazily evaluate the fact Summary: Modified method description to disambiguate when false is returned and altered implementation Reviewed-by: dfuchs, chegar, vtewari
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 47216
diff changeset
     2
 * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
2
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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    23
 * questions.
2
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>
17473
35cd9b3a98ff 8010464: Evolve java networking same origin policy
michaelm
parents: 10596
diff changeset
    53
 * <p>
35cd9b3a98ff 8010464: Evolve java networking same origin policy
michaelm
parents: 10596
diff changeset
    54
 * <b>Security permissions</b>
35cd9b3a98ff 8010464: Evolve java networking same origin policy
michaelm
parents: 10596
diff changeset
    55
 * <p>
35cd9b3a98ff 8010464: Evolve java networking same origin policy
michaelm
parents: 10596
diff changeset
    56
 * If a security manager is installed, and if a method is called which results in an
44864
86b9c60f4817 8179512: Typo in HttpURLConnection documentation
msheppar
parents: 42351
diff changeset
    57
 * attempt to open a connection, the caller must possess either:
17473
35cd9b3a98ff 8010464: Evolve java networking same origin policy
michaelm
parents: 10596
diff changeset
    58
 * <ul><li>a "connect" {@link SocketPermission} to the host/port combination of the
35cd9b3a98ff 8010464: Evolve java networking same origin policy
michaelm
parents: 10596
diff changeset
    59
 * destination URL or</li>
20787
ab071ce90368 8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents: 19069
diff changeset
    60
 * <li>a {@link URLPermission} that permits this request.</li>
17473
35cd9b3a98ff 8010464: Evolve java networking same origin policy
michaelm
parents: 10596
diff changeset
    61
 * </ul><p>
35cd9b3a98ff 8010464: Evolve java networking same origin policy
michaelm
parents: 10596
diff changeset
    62
 * If automatic redirection is enabled, and this request is redirected to another
35cd9b3a98ff 8010464: Evolve java networking same origin policy
michaelm
parents: 10596
diff changeset
    63
 * destination, then the caller must also have permission to connect to the
35cd9b3a98ff 8010464: Evolve java networking same origin policy
michaelm
parents: 10596
diff changeset
    64
 * redirected host/URL.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * @see     java.net.HttpURLConnection#disconnect()
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 20787
diff changeset
    67
 * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 25859
diff changeset
    69
public abstract class HttpURLConnection extends URLConnection {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /* instance variables */
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 HTTP method (GET,POST,PUT,etc.).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    protected String method = "GET";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * The chunk-length when using chunked encoding streaming mode for output.
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
    79
     * A value of {@code -1} means chunked encoding is disabled for output.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    protected int chunkLength = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * The fixed content-length when using fixed-length streaming mode.
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
    86
     * A value of {@code -1} means fixed-length streaming mode is disabled
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * for output.
1576
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
    88
     *
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
    89
     * <P> <B>NOTE:</B> {@link #fixedContentLengthLong} is recommended instead
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
    90
     * of this field, as it allows larger content lengths to be set.
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
    91
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    protected int fixedContentLength = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
1576
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
    97
     * The fixed content-length when using fixed-length streaming mode.
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
    98
     * A value of {@code -1} means fixed-length streaming mode is disabled
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
    99
     * for output.
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   100
     *
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   101
     * @since 1.7
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   102
     */
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   103
    protected long fixedContentLengthLong = -1;
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   104
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   105
    /**
42351
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   106
     * Supplies an {@link java.net.Authenticator Authenticator} to be used
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   107
     * when authentication is requested through the HTTP protocol for
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   108
     * this {@code HttpURLConnection}.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   109
     * If no authenticator is supplied, the
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   110
     * {@linkplain Authenticator#setDefault(java.net.Authenticator) default
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   111
     * authenticator} will be used.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   112
     *
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   113
     * @implSpec The default behavior of this method is to unconditionally
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   114
     *           throw {@link UnsupportedOperationException}. Concrete
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   115
     *           implementations of {@code HttpURLConnection}
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   116
     *           which support supplying an {@code Authenticator} for a
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   117
     *           specific {@code HttpURLConnection} instance should
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   118
     *           override this method to implement a different behavior.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   119
     *
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   120
     * @implNote Depending on authentication schemes, an implementation
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   121
     *           may or may not need to use the provided authenticator
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   122
     *           to obtain a password. For instance, an implementation that
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   123
     *           relies on third-party security libraries may still invoke the
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   124
     *           default authenticator if these libraries are configured
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   125
     *           to do so.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   126
     *           Likewise, an implementation that supports transparent
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   127
     *           NTLM authentication may let the system attempt
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   128
     *           to connect using the system user credentials first,
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   129
     *           before invoking the provided authenticator.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   130
     *           <br>
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   131
     *           However, if an authenticator is specifically provided,
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   132
     *           then the underlying connection may only be reused for
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   133
     *           {@code HttpURLConnection} instances which share the same
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   134
     *           {@code Authenticator} instance, and authentication information,
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   135
     *           if cached, may only be reused for an {@code HttpURLConnection}
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   136
     *           sharing that same {@code Authenticator}.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   137
     *
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   138
     * @param auth The {@code Authenticator} that should be used by this
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   139
     *           {@code HttpURLConnection}.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   140
     *
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   141
     * @throws  UnsupportedOperationException if setting an Authenticator is
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   142
     *          not supported by the underlying implementation.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   143
     * @throws  IllegalStateException if URLConnection is already connected.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   144
     * @throws  NullPointerException if the supplied {@code auth} is {@code null}.
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   145
     * @since 9
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   146
     */
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   147
    public void setAuthenticator(Authenticator auth) {
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   148
        throw new UnsupportedOperationException("Supplying an authenticator"
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   149
                    + " is not supported by " + this.getClass());
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   150
    }
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   151
85ed90be0ae1 8169495: Add a method to set an Authenticator on a HttpURLConnection.
dfuchs
parents: 32649
diff changeset
   152
    /**
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   153
     * Returns the key for the {@code n}<sup>th</sup> header field.
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   154
     * Some implementations may treat the {@code 0}<sup>th</sup>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * header field as special, i.e. as the status line returned by the HTTP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * server. In this case, {@link #getHeaderField(int) getHeaderField(0)} returns the status
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   157
     * line, but {@code getHeaderFieldKey(0)} returns null.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *
18156
edb590d448c5 8016217: More javadoc warnings
alanb
parents: 17473
diff changeset
   159
     * @param   n   an index, where {@code n >=0}.
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   160
     * @return  the key for the {@code n}<sup>th</sup> header field,
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   161
     *          or {@code null} if the key does not exist.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public String getHeaderFieldKey (int n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * This method is used to enable streaming of a HTTP request body
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * without internal buffering, when the content length is known in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * advance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * An exception will be thrown if the application
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * attempts to write more data than the indicated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * content-length, or if the application closes the OutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * before writing the indicated amount.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * When output streaming is enabled, authentication
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * and redirection cannot be handled automatically.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * A HttpRetryException will be thrown when reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * the response if authentication or redirection are required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * This exception can be queried for the details of the error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * This method must be called before the URLConnection is connected.
1576
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   184
     * <p>
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   185
     * <B>NOTE:</B> {@link #setFixedLengthStreamingMode(long)} is recommended
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   186
     * instead of this method as it allows larger content lengths to be set.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @param   contentLength The number of bytes which will be written
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *          to the OutputStream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @throws  IllegalStateException if URLConnection is already connected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *          or if a different streaming mode is already enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @throws  IllegalArgumentException if a content length less than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     *          zero is specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @see     #setChunkedStreamingMode(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    public void setFixedLengthStreamingMode (int contentLength) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        if (connected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            throw new IllegalStateException ("Already connected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        if (chunkLength != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            throw new IllegalStateException ("Chunked encoding streaming mode set");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        if (contentLength < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            throw new IllegalArgumentException ("invalid content length");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        fixedContentLength = contentLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
1576
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   213
    /**
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   214
     * This method is used to enable streaming of a HTTP request body
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   215
     * without internal buffering, when the content length is known in
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   216
     * advance.
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   217
     *
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   218
     * <P> An exception will be thrown if the application attempts to write
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   219
     * more data than the indicated content-length, or if the application
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   220
     * closes the OutputStream before writing the indicated amount.
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   221
     *
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   222
     * <P> When output streaming is enabled, authentication and redirection
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   223
     * cannot be handled automatically. A {@linkplain HttpRetryException} will
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   224
     * be thrown when reading the response if authentication or redirection
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   225
     * are required. This exception can be queried for the details of the
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   226
     * error.
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   227
     *
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   228
     * <P> This method must be called before the URLConnection is connected.
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   229
     *
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   230
     * <P> The content length set by invoking this method takes precedence
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   231
     * over any value set by {@link #setFixedLengthStreamingMode(int)}.
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   232
     *
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   233
     * @param  contentLength
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   234
     *         The number of bytes which will be written to the OutputStream.
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   235
     *
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   236
     * @throws  IllegalStateException
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   237
     *          if URLConnection is already connected or if a different
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   238
     *          streaming mode is already enabled.
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   239
     *
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   240
     * @throws  IllegalArgumentException
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   241
     *          if a content length less than zero is specified.
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   242
     *
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   243
     * @since 1.7
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   244
     */
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   245
    public void setFixedLengthStreamingMode(long contentLength) {
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   246
        if (connected) {
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   247
            throw new IllegalStateException("Already connected");
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   248
        }
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   249
        if (chunkLength != -1) {
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   250
            throw new IllegalStateException(
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   251
                "Chunked encoding streaming mode set");
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   252
        }
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   253
        if (contentLength < 0) {
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   254
            throw new IllegalArgumentException("invalid content length");
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   255
        }
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   256
        fixedContentLengthLong = contentLength;
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   257
    }
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   258
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    /* Default chunk size (including chunk header) if not specified;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * we want to keep this in sync with the one defined in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * sun.net.www.http.ChunkedOutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    private static final int DEFAULT_CHUNK_SIZE = 4096;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * This method is used to enable streaming of a HTTP request body
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * without internal buffering, when the content length is <b>not</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * known in advance. In this mode, chunked transfer encoding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * is used to send the request body. Note, not all HTTP servers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * support this mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * When output streaming is enabled, authentication
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * and redirection cannot be handled automatically.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * A HttpRetryException will be thrown when reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * the response if authentication or redirection are required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * This exception can be queried for the details of the error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * This method must be called before the URLConnection is connected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * @param   chunklen The number of bytes to write in each chunk.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     *          If chunklen is less than or equal to zero, a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     *          value will be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * @throws  IllegalStateException if URLConnection is already connected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     *          or if a different streaming mode is already enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * @see     #setFixedLengthStreamingMode(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    public void setChunkedStreamingMode (int chunklen) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        if (connected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            throw new IllegalStateException ("Can't set streaming mode: already connected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        }
1576
b697b141012d 6755625: Add HttpURLConnection.setFixedLengthStreamingMode(long)
chegar
parents: 2
diff changeset
   294
        if (fixedContentLength != -1 || fixedContentLengthLong != -1) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            throw new IllegalStateException ("Fixed length streaming mode set");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        chunkLength = chunklen <=0? DEFAULT_CHUNK_SIZE : chunklen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    /**
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   301
     * Returns the value for the {@code n}<sup>th</sup> header field.
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   302
     * Some implementations may treat the {@code 0}<sup>th</sup>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * header field as special, i.e. as the status line returned by the HTTP
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * This method can be used in conjunction with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * {@link #getHeaderFieldKey getHeaderFieldKey} method to iterate through all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * the headers in the message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     *
18156
edb590d448c5 8016217: More javadoc warnings
alanb
parents: 17473
diff changeset
   310
     * @param   n   an index, where {@code n>=0}.
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   311
     * @return  the value of the {@code n}<sup>th</sup> header field,
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   312
     *          or {@code null} if the value does not exist.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * @see     java.net.HttpURLConnection#getHeaderFieldKey(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    public String getHeaderField(int n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    /**
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   320
     * An {@code int} representing the three digit HTTP Status-Code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * <li> 1xx: Informational
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * <li> 2xx: Success
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * <li> 3xx: Redirection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * <li> 4xx: Client Error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * <li> 5xx: Server Error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    protected int responseCode = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * The HTTP response message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    protected String responseMessage = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    /* static variables */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    /* do we automatically follow redirects? The default is true. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    private static boolean followRedirects = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    /**
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   342
     * If {@code true}, the protocol will automatically follow redirects.
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   343
     * If {@code false}, the protocol will not automatically follow
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * redirects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * <p>
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   346
     * This field is set by the {@code setInstanceFollowRedirects}
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   347
     * method. Its value is returned by the {@code getInstanceFollowRedirects}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * Its default value is based on the value of the static followRedirects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * at HttpURLConnection construction time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * @see     java.net.HttpURLConnection#setInstanceFollowRedirects(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * @see     java.net.HttpURLConnection#getInstanceFollowRedirects()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * @see     java.net.HttpURLConnection#setFollowRedirects(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    protected boolean instanceFollowRedirects = followRedirects;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    /* valid HTTP methods */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    private static final String[] methods = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        "GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * Constructor for the HttpURLConnection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * @param u the URL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    protected HttpURLConnection (URL u) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        super(u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * Sets whether HTTP redirects  (requests with response code 3xx) should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * be automatically followed by this class.  True by default.  Applets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * cannot change this variable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * If there is a security manager, this method first calls
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   378
     * the security manager's {@code checkSetFactory} method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * to ensure the operation is allowed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * This could result in a SecurityException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     *
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   382
     * @param set a {@code boolean} indicating whether or not
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * to follow HTTP redirects.
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 47216
diff changeset
   384
     * @throws     SecurityException  if a security manager exists and its
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   385
     *             {@code checkSetFactory} method doesn't
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     *             allow the operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * @see        SecurityManager#checkSetFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * @see #getFollowRedirects()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    public static void setFollowRedirects(boolean set) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        SecurityManager sec = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        if (sec != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            // seems to be the best check here...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            sec.checkSetFactory();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        followRedirects = set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    /**
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   400
     * Returns a {@code boolean} indicating
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * whether or not HTTP redirects (3xx) should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * be automatically followed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     *
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   404
     * @return {@code true} if HTTP redirects should
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   405
     * be automatically followed, {@code false} if not.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * @see #setFollowRedirects(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    public static boolean getFollowRedirects() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        return followRedirects;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * Sets whether HTTP redirects (requests with response code 3xx) should
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   414
     * be automatically followed by this {@code HttpURLConnection}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * The default value comes from followRedirects, which defaults to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     *
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   420
     * @param followRedirects a {@code boolean} indicating
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * whether or not to follow HTTP redirects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * @see    java.net.HttpURLConnection#instanceFollowRedirects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * @see #getInstanceFollowRedirects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     public void setInstanceFollowRedirects(boolean followRedirects) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        instanceFollowRedirects = followRedirects;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     /**
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   432
     * Returns the value of this {@code HttpURLConnection}'s
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   433
     * {@code instanceFollowRedirects} field.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     *
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   435
     * @return  the value of this {@code HttpURLConnection}'s
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   436
     *          {@code instanceFollowRedirects} field.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * @see     java.net.HttpURLConnection#instanceFollowRedirects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * @see #setInstanceFollowRedirects(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     public boolean getInstanceFollowRedirects() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
         return instanceFollowRedirects;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * Set the method for the URL request, one of:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * <UL>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     *  <LI>GET
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     *  <LI>POST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     *  <LI>HEAD
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     *  <LI>OPTIONS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     *  <LI>PUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     *  <LI>DELETE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     *  <LI>TRACE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * </UL> are legal, subject to protocol restrictions.  The default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * method is GET.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * @param method the HTTP method
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 47216
diff changeset
   459
     * @throws    ProtocolException if the method cannot be reset or if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     *              the requested method isn't valid for HTTP.
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 47216
diff changeset
   461
     * @throws    SecurityException if a security manager is set and the
8566
e2df5f8fa082 7024264: HttpURLConnection/NetPermission doc issue
michaelm
parents: 7668
diff changeset
   462
     *              method is "TRACE", but the "allowHttpTrace"
e2df5f8fa082 7024264: HttpURLConnection/NetPermission doc issue
michaelm
parents: 7668
diff changeset
   463
     *              NetPermission is not granted.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * @see #getRequestMethod()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    public void setRequestMethod(String method) throws ProtocolException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        if (connected) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
            throw new ProtocolException("Can't reset method: already connected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        // This restriction will prevent people from using this class to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        // experiment w/ new HTTP methods using java.  But it should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        // be placed for security - the request String could be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        // arbitrarily long.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        for (int i = 0; i < methods.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            if (methods[i].equals(method)) {
6875
81d6ec3397e5 6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents: 5506
diff changeset
   477
                if (method.equals("TRACE")) {
81d6ec3397e5 6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents: 5506
diff changeset
   478
                    SecurityManager s = System.getSecurityManager();
81d6ec3397e5 6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents: 5506
diff changeset
   479
                    if (s != null) {
81d6ec3397e5 6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents: 5506
diff changeset
   480
                        s.checkPermission(new NetPermission("allowHttpTrace"));
81d6ec3397e5 6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents: 5506
diff changeset
   481
                    }
81d6ec3397e5 6981426: limit use of TRACE method in HttpURLConnection
michaelm
parents: 5506
diff changeset
   482
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                this.method = method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        throw new ProtocolException("Invalid HTTP method: " + method);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * Get the request method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * @return the HTTP request method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * @see #setRequestMethod(java.lang.String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    public String getRequestMethod() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        return method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * Gets the status code from an HTTP response message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * For example, in the case of the following status lines:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * HTTP/1.0 200 OK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * HTTP/1.0 401 Unauthorized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * It will return 200 and 401 respectively.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * Returns -1 if no code can be discerned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * from the response (i.e., the response is not valid HTTP).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * @throws IOException if an error occurred connecting to the server.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * @return the HTTP Status-Code, or -1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    public int getResponseCode() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
         * We're got the response code already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        if (responseCode != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            return responseCode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
         * Ensure that we have connected to the server. Record
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
         * exception as we need to re-throw it if there isn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
         * a status line.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        Exception exc = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            getInputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
            exc = e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
         * If we can't a status-line then re-throw any exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
         * that getInputStream threw.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        String statusLine = getHeaderField(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        if (statusLine == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            if (exc != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                if (exc instanceof RuntimeException)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
                    throw (RuntimeException)exc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
                    throw (IOException)exc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
            return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
         * Examine the status-line - should be formatted as per
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
         * section 6.1 of RFC 2616 :-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
         * Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
         * If status line can't be parsed return -1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        if (statusLine.startsWith("HTTP/1.")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            int codePos = statusLine.indexOf(' ');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
            if (codePos > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                int phrasePos = statusLine.indexOf(' ', codePos+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                if (phrasePos > 0 && phrasePos < statusLine.length()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                    responseMessage = statusLine.substring(phrasePos+1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                // deviation from RFC 2616 - don't reject status line
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                // if SP Reason-Phrase is not included.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                if (phrasePos < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                    phrasePos = statusLine.length();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                    responseCode = Integer.parseInt
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                            (statusLine.substring(codePos+1, phrasePos));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                    return responseCode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                } catch (NumberFormatException e) { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * Gets the HTTP response message, if any, returned along with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * response code from a server.  From responses like:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * HTTP/1.0 200 OK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * HTTP/1.0 404 Not Found
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * Extracts the Strings "OK" and "Not Found" respectively.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * Returns null if none could be discerned from the responses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * (the result was not valid HTTP).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * @throws IOException if an error occurred connecting to the server.
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   590
     * @return the HTTP response message, or {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    public String getResponseMessage() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        getResponseCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        return responseMessage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
10596
39b3a979e600 7090158: Networking Libraries don't build with javac -Werror
chegar
parents: 9035
diff changeset
   597
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    public long getHeaderFieldDate(String name, long Default) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        String dateString = getHeaderField(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
            if (dateString.indexOf("GMT") == -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                dateString = dateString+" GMT";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
            return Date.parse(dateString);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        return Default;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * Indicates that other requests to the server
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     * are unlikely in the near future. Calling disconnect()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * should not imply that this HttpURLConnection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * instance can be reused for other requests.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    public abstract void disconnect();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * Indicates if the connection is going through a proxy.
58896
bd9daab73a8e 8231632: HttpURLConnection::usingProxy could specify that it may lazily evaluate the fact
jboes
parents: 58242
diff changeset
   621
     *
bd9daab73a8e 8231632: HttpURLConnection::usingProxy could specify that it may lazily evaluate the fact
jboes
parents: 58242
diff changeset
   622
     * This method returns {@code true} if the connection is known
bd9daab73a8e 8231632: HttpURLConnection::usingProxy could specify that it may lazily evaluate the fact
jboes
parents: 58242
diff changeset
   623
     * to be going or has gone through proxies, and returns {@code false}
bd9daab73a8e 8231632: HttpURLConnection::usingProxy could specify that it may lazily evaluate the fact
jboes
parents: 58242
diff changeset
   624
     * if the connection will never go through a proxy or if
bd9daab73a8e 8231632: HttpURLConnection::usingProxy could specify that it may lazily evaluate the fact
jboes
parents: 58242
diff changeset
   625
     * the use of a proxy cannot be determined.
bd9daab73a8e 8231632: HttpURLConnection::usingProxy could specify that it may lazily evaluate the fact
jboes
parents: 58242
diff changeset
   626
     *
bd9daab73a8e 8231632: HttpURLConnection::usingProxy could specify that it may lazily evaluate the fact
jboes
parents: 58242
diff changeset
   627
     * @return a boolean indicating if the connection is using a proxy.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    public abstract boolean usingProxy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * Returns a {@link SocketPermission} object representing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * permission necessary to connect to the destination host and port.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     *
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 47216
diff changeset
   635
     * @throws    IOException if an error occurs while computing
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     *            the permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     *
19069
1d9cb0d080e3 8021833: javadoc cleanup in java.net
juh
parents: 18156
diff changeset
   638
     * @return a {@code SocketPermission} object representing the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     *         permission necessary to connect to the destination
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     *         host and port.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    public Permission getPermission() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
        int port = url.getPort();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        port = port < 0 ? 80 : port;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        String host = url.getHost() + ":" + port;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        Permission permission = new SocketPermission(host, "connect");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        return permission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    * Returns the error stream if the connection failed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    * but the server sent useful data nonetheless. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    * typical example is when an HTTP server responds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    * with a 404, which will cause a FileNotFoundException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    * to be thrown in connect, but the server sent an HTML
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    * help page with suggestions as to what to do.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    * <p>This method will not cause a connection to be initiated.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    * the connection was not connected, or if the server did not have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    * an error while connecting or if the server had an error but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    * no error data was sent, this method will return null. This is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    * the default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    * @return an error stream if any, null if there have been no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    * errors, the connection is not connected or the server sent no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    * useful data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    public InputStream getErrorStream() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * The response codes for HTTP, as of version 1.1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    // REMIND: do we want all these??
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    // Others not here that we do want??
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    /* 2XX: generally "OK" */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * HTTP Status-Code 200: OK.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    public static final int HTTP_OK = 200;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * HTTP Status-Code 201: Created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    public static final int HTTP_CREATED = 201;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * HTTP Status-Code 202: Accepted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
    public static final int HTTP_ACCEPTED = 202;
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 203: Non-Authoritative Information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    public static final int HTTP_NOT_AUTHORITATIVE = 203;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * HTTP Status-Code 204: No Content.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    public static final int HTTP_NO_CONTENT = 204;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * HTTP Status-Code 205: Reset Content.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    public static final int HTTP_RESET = 205;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     * HTTP Status-Code 206: Partial Content.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    public static final int HTTP_PARTIAL = 206;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    /* 3XX: relocation/redirect */
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 300: Multiple Choices.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    public static final int HTTP_MULT_CHOICE = 300;
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 301: Moved Permanently.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    public static final int HTTP_MOVED_PERM = 301;
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 302: Temporary Redirect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    public static final int HTTP_MOVED_TEMP = 302;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     * HTTP Status-Code 303: See Other.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    public static final int HTTP_SEE_OTHER = 303;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * HTTP Status-Code 304: Not Modified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    public static final int HTTP_NOT_MODIFIED = 304;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * HTTP Status-Code 305: Use Proxy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
    public static final int HTTP_USE_PROXY = 305;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
    /* 4XX: client error */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     * HTTP Status-Code 400: Bad Request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    public static final int HTTP_BAD_REQUEST = 400;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
     * HTTP Status-Code 401: Unauthorized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    public static final int HTTP_UNAUTHORIZED = 401;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
     * HTTP Status-Code 402: Payment Required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
    public static final int HTTP_PAYMENT_REQUIRED = 402;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     * HTTP Status-Code 403: Forbidden.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    public static final int HTTP_FORBIDDEN = 403;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     * HTTP Status-Code 404: Not Found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
    public static final int HTTP_NOT_FOUND = 404;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     * HTTP Status-Code 405: Method Not Allowed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
    public static final int HTTP_BAD_METHOD = 405;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * HTTP Status-Code 406: Not Acceptable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
    public static final int HTTP_NOT_ACCEPTABLE = 406;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     * HTTP Status-Code 407: Proxy Authentication Required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    public static final int HTTP_PROXY_AUTH = 407;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     * HTTP Status-Code 408: Request Time-Out.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
    public static final int HTTP_CLIENT_TIMEOUT = 408;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     * HTTP Status-Code 409: Conflict.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
    public static final int HTTP_CONFLICT = 409;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     * HTTP Status-Code 410: Gone.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
    public static final int HTTP_GONE = 410;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     * HTTP Status-Code 411: Length Required.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    public static final int HTTP_LENGTH_REQUIRED = 411;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
     * HTTP Status-Code 412: Precondition Failed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
    public static final int HTTP_PRECON_FAILED = 412;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     * HTTP Status-Code 413: Request Entity Too Large.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    public static final int HTTP_ENTITY_TOO_LARGE = 413;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     * HTTP Status-Code 414: Request-URI Too Large.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    public static final int HTTP_REQ_TOO_LONG = 414;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
     * HTTP Status-Code 415: Unsupported Media Type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    public static final int HTTP_UNSUPPORTED_TYPE = 415;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    /* 5XX: server error */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * HTTP Status-Code 500: Internal Server Error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     * @deprecated   it is misplaced and shouldn't have existed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    public static final int HTTP_SERVER_ERROR = 500;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
     * HTTP Status-Code 500: Internal Server Error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
    public static final int HTTP_INTERNAL_ERROR = 500;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     * HTTP Status-Code 501: Not Implemented.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
    public static final int HTTP_NOT_IMPLEMENTED = 501;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
     * HTTP Status-Code 502: Bad Gateway.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    public static final int HTTP_BAD_GATEWAY = 502;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
     * HTTP Status-Code 503: Service Unavailable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    public static final int HTTP_UNAVAILABLE = 503;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
     * HTTP Status-Code 504: Gateway Timeout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
    public static final int HTTP_GATEWAY_TIMEOUT = 504;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     * HTTP Status-Code 505: HTTP Version Not Supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    public static final int HTTP_VERSION = 505;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
}