01: /*
02: * Copyright 2006 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.dev.shell.ie;
17:
18: import com.google.gwt.dev.shell.LowLevel;
19:
20: /**
21: * Various low-level helper methods for dealing with COM and such.
22: */
23: class LowLevelIE6 {
24:
25: /**
26: * Does an HTTP GET that works with Windows proxy settings. Set the system
27: * property <code>gwt.debugLowLevelHttpGet</code> to print failure status
28: * codes to stderr.
29: *
30: * @param userAgent the user-agent to specify for the GET
31: * @param url the absolute URL to GET
32: * @return the bytes of the full response (including headers), or
33: * <code>null</code> if there's a problem
34: */
35: public static byte[] httpGet(String userAgent, String url) {
36: init();
37: byte[][] out = new byte[1][];
38: int status = _httpGet(userAgent, url, out);
39: if (status == 0) {
40: return out[0];
41: } else {
42: if (System.getProperty("gwt.debugLowLevelHttpGet") != null) {
43: System.err.println("GET failed with status " + status
44: + " for " + url);
45: }
46: return null;
47: }
48: }
49:
50: public static synchronized void init() {
51: // Force LowLevel initialization to load gwt-ll
52: LowLevel.init();
53: }
54:
55: // CHECKSTYLE_OFF
56: // out must be an array of size 1 to receive the array answer
57: private static native int _httpGet(String userAgent, String url,
58: byte[][] out);
59:
60: // CHECKSTYLE_ON
61:
62: /**
63: * Not instantiable.
64: */
65: private LowLevelIE6() {
66: }
67: }
|