jdk/src/share/classes/sun/net/www/URLConnection.java
author michaelm
Mon, 30 May 2011 23:36:10 +0100
changeset 9775 1b128726e887
parent 9550 c3a275ce56d3
child 10596 39b3a979e600
permissions -rw-r--r--
7042550: Reintegrate 6569621 Reviewed-by: chegar, alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1995, 2006, 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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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 sun.net.www;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.net.URL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.net.ContentHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.InputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.OutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.BufferedInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.net.UnknownServiceException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * A class to represent an active connection to an object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * represented by a URL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @author  James Gosling
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
abstract public class URLConnection extends java.net.URLConnection {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    /** The URL that it is connected to */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    private String contentType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    private int contentLength = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    protected MessageHeader properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    /** Create a URLConnection object.  These should not be created directly:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        instead they should be created by protocol handers in response to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        URL.openConnection.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        @param  u       The URL that this connects to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    public URLConnection (URL u) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        super(u);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        properties = new MessageHeader();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /** Call this routine to get the property list for this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * Properties (like content-type) that have explicit getXX() methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * associated with them should be accessed using those methods.  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public MessageHeader getProperties() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        return properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /** Call this routine to set the property list for this object. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    public void setProperties(MessageHeader properties) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        this.properties = properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public void setRequestProperty(String key, String value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        if(connected)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            throw new IllegalAccessError("Already connected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        if (key == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            throw new NullPointerException ("key cannot be null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        properties.set(key, value);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * The following three methods addRequestProperty, getRequestProperty,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * and getRequestProperties were copied from the superclass implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * before it was changed by CR:6230836, to maintain backward compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public void addRequestProperty(String key, String value) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        if (connected)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            throw new IllegalStateException("Already connected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        if (key == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
            throw new NullPointerException ("key is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public String getRequestProperty(String key) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        if (connected)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            throw new IllegalStateException("Already connected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    public Map<String,List<String>> getRequestProperties() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        if (connected)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            throw new IllegalStateException("Already connected");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        return Collections.EMPTY_MAP;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    public String getHeaderField(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            getInputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        return properties == null ? null : properties.findValue(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * Return the key for the nth header field. Returns null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * there are fewer than n fields.  This can be used to iterate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * through all the headers in the message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    public String getHeaderFieldKey(int n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            getInputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        MessageHeader props = properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        return props == null ? null : props.getKey(n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * Return the value for the nth header field. Returns null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * there are fewer than n fields.  This can be used in conjunction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * with getHeaderFieldKey to iterate through all the headers in the message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    public String getHeaderField(int n) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            getInputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        MessageHeader props = properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        return props == null ? null : props.getValue(n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /** Call this routine to get the content-type associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    public String getContentType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        if (contentType == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            contentType = getHeaderField("content-type");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        if (contentType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            String ct = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                ct = guessContentTypeFromStream(getInputStream());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            } catch(java.io.IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            String ce = properties.findValue("content-encoding");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            if (ct == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                ct = properties.findValue("content-type");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                if (ct == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                    if (url.getFile().endsWith("/"))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                        ct = "text/html";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                        ct = guessContentTypeFromName(url.getFile());
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
             * If the Mime header had a Content-encoding field and its value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
             * was not one of the values that essentially indicate no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
             * encoding, we force the content type to be unknown. This will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
             * cause a save dialog to be presented to the user.  It is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
             * ideal but is better than what we were previously doing, namely
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
             * bringing up an image tool for compressed tar files.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            if (ct == null || ce != null &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                    !(ce.equalsIgnoreCase("7bit")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                      || ce.equalsIgnoreCase("8bit")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                      || ce.equalsIgnoreCase("binary")))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                ct = "content/unknown";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            setContentType(ct);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        return contentType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Set the content type of this URL to a specific value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @param   type    The content type to use.  One of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *                  content_* static variables in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *                  class should be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *                  eg. setType(URL.content_html);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    public void setContentType(String type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        contentType = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        properties.set("content-type", type);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    /** Call this routine to get the content-length associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    public int getContentLength() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            getInputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
            return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        int l = contentLength;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        if (l < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                l = Integer.parseInt(properties.findValue("content-length"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                setContentLength(l);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            } catch(Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        return l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    /** Call this routine to set the content-length associated with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    protected void setContentLength(int length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        contentLength = length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        properties.set("content-length", String.valueOf(length));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * Returns true if the data associated with this URL can be cached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    public boolean canCache() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        return url.getFile().indexOf('?') < 0   /* && url.postData == null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                REMIND */ ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * Call this to close the connection and flush any remaining data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * Overriders must remember to call super.close()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    public void close() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        url = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
9775
1b128726e887 7042550: Reintegrate 6569621
michaelm
parents: 9550
diff changeset
   241
1b128726e887 7042550: Reintegrate 6569621
michaelm
parents: 9550
diff changeset
   242
    private static HashMap<String,Void> proxiedHosts = new HashMap<>();
1b128726e887 7042550: Reintegrate 6569621
michaelm
parents: 9550
diff changeset
   243
1b128726e887 7042550: Reintegrate 6569621
michaelm
parents: 9550
diff changeset
   244
    public synchronized static void setProxiedHost(String host) {
1b128726e887 7042550: Reintegrate 6569621
michaelm
parents: 9550
diff changeset
   245
        proxiedHosts.put(host.toLowerCase(), null);
1b128726e887 7042550: Reintegrate 6569621
michaelm
parents: 9550
diff changeset
   246
    }
1b128726e887 7042550: Reintegrate 6569621
michaelm
parents: 9550
diff changeset
   247
1b128726e887 7042550: Reintegrate 6569621
michaelm
parents: 9550
diff changeset
   248
    public synchronized static boolean isProxiedHost(String host) {
1b128726e887 7042550: Reintegrate 6569621
michaelm
parents: 9550
diff changeset
   249
        return proxiedHosts.containsKey(host.toLowerCase());
1b128726e887 7042550: Reintegrate 6569621
michaelm
parents: 9550
diff changeset
   250
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
}