KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > dev > shell > ie > LowLevelIE6


1 /*
2  * Copyright 2006 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc userAgent, String JavaDoc 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 + " for " + url);
44       }
45       return null;
46     }
47   }
48
49   public static synchronized void init() {
50     // Force LowLevel initialization to load gwt-ll
51
LowLevel.init();
52   }
53
54   // CHECKSTYLE_OFF
55
// out must be an array of size 1 to receive the array answer
56
private static native int _httpGet(String JavaDoc userAgent, String JavaDoc url, byte[][] out);
57
58   // CHECKSTYLE_ON
59

60   /**
61    * Not instantiable.
62    */

63   private LowLevelIE6() {
64   }
65 }
66
Popular Tags