3261N/A * Copyright (c) 1994, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * This is the base class for network clients. 0N/A * @author Jonathan Payne 2981N/A /* Default value of read timeout, if not specified (infinity) */ 2981N/A /* Default value of connect timeout, if not specified (infinity) */ 0N/A /** Socket for communicating with server. */ 0N/A /** Stream for printing to the server. */ 0N/A /** Buffered stream for reading replies from server. */ 0N/A /* Name of encoding to use for output */ 0N/A * Test the named character encoding to verify that it converts ASCII 0N/A * characters correctly. We have to use an ASCII based encoding, or else 0N/A * the NetworkClients will not work correctly in EBCDIC based systems. 0N/A * However, we cannot just use ASCII or ISO8859_1 universally, because in 0N/A * Asian locales, non-ASCII characters may be embedded in otherwise 0N/A * ASCII based protocols (eg. HTTP). The specifications (RFC2616, 2398) 0N/A * are a little ambiguous in this matter. For instance, RFC2398 [part 2.1] 0N/A * says that the HTTP request URI should be escaped using a defined 0N/A * mechanism, but there is no way to specify in the escaped string what 0N/A * the original character set is. It is not correct to assume that 0N/A * UTF-8 is always used (as in URLs in HTML 4.0). For this reason, 0N/A * until the specifications are updated to deal with this issue more 0N/A * comprehensively, and more importantly, HTTP servers are known to 0N/A * support these mechanisms, we will maintain the current behavior 0N/A * where it is possible to send non-ASCII characters in their original 0N/A "abcdefghijklmnopqrstuvwxyz-_.!~*'();/?:@&=+$,";
0N/A // Expected byte sequence for string above 0N/A byte[]
chkB = {
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
65,
66,
67,
68,
69,
70,
71,
72,
0N/A 73,
74,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87,
88,
89,
90,
97,
98,
99,
0N/A 100,
101,
102,
103,
104,
105,
106,
107,
108,
109,
110,
111,
112,
113,
114,
0N/A 115,
116,
117,
118,
119,
120,
121,
122,
45,
95,
46,
33,
126,
42,
39,
40,
41,
59,
0N/A 47,
63,
58,
64,
38,
61,
43,
36,
44};
0N/A /** Open a connection to the server. */ 0N/A * Return a socket connected to the server, with any 0N/A * appropriate options pre-established 2241N/A // Still connecting through a proxy 2241N/A // server & port will be the proxy address and port 0N/A // Instance specific timeouts do have priority, that means 0N/A // connectTimeout & readTimeout (-1 means not set) 0N/A // Then global default timeouts 2241N/A * The following method, createSocket, is provided to allow the 2241N/A * https client to override it so that it may use its socket factory 0N/A /** Close an open connection to the server. */ 0N/A /** Return server connection status */ 0N/A /** Create connection with host <i>host</i> on port <i>port</i> */ 2981N/A * Note: Public URLConnection (and protocol specific implementations) 2981N/A * protect against negative timeout values being set. This implemenation, 2981N/A * and protocol specific implementations, use -1 to represent the default 2981N/A * This method may be invoked with the default timeout value when the 2981N/A * protocol handler is trying to reset the timeout after doing a 2981N/A * potentially blocking internal operation, e.g. cleaning up unread 2981N/A * response data, buffering error stream response data, etc