home *** CD-ROM | disk | FTP | other *** search
- package java.net;
-
- import java.io.IOException;
-
- public abstract class HttpURLConnection extends URLConnection {
- protected String method = "GET";
- protected int responseCode = -1;
- protected String responseMessage;
- private static boolean followRedirects = true;
- private static final String[] methods = new String[]{"GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"};
- public static final int HTTP_OK = 200;
- public static final int HTTP_CREATED = 201;
- public static final int HTTP_ACCEPTED = 202;
- public static final int HTTP_NOT_AUTHORITATIVE = 203;
- public static final int HTTP_NO_CONTENT = 204;
- public static final int HTTP_RESET = 205;
- public static final int HTTP_PARTIAL = 206;
- public static final int HTTP_MULT_CHOICE = 300;
- public static final int HTTP_MOVED_PERM = 301;
- public static final int HTTP_MOVED_TEMP = 302;
- public static final int HTTP_SEE_OTHER = 303;
- public static final int HTTP_NOT_MODIFIED = 304;
- public static final int HTTP_USE_PROXY = 305;
- public static final int HTTP_BAD_REQUEST = 400;
- public static final int HTTP_UNAUTHORIZED = 401;
- public static final int HTTP_PAYMENT_REQUIRED = 402;
- public static final int HTTP_FORBIDDEN = 403;
- public static final int HTTP_NOT_FOUND = 404;
- public static final int HTTP_BAD_METHOD = 405;
- public static final int HTTP_NOT_ACCEPTABLE = 406;
- public static final int HTTP_PROXY_AUTH = 407;
- public static final int HTTP_CLIENT_TIMEOUT = 408;
- public static final int HTTP_CONFLICT = 409;
- public static final int HTTP_GONE = 410;
- public static final int HTTP_LENGTH_REQUIRED = 411;
- public static final int HTTP_PRECON_FAILED = 412;
- public static final int HTTP_ENTITY_TOO_LARGE = 413;
- public static final int HTTP_REQ_TOO_LONG = 414;
- public static final int HTTP_UNSUPPORTED_TYPE = 415;
- public static final int HTTP_SERVER_ERROR = 500;
- public static final int HTTP_INTERNAL_ERROR = 501;
- public static final int HTTP_BAD_GATEWAY = 502;
- public static final int HTTP_UNAVAILABLE = 503;
- public static final int HTTP_GATEWAY_TIMEOUT = 504;
- public static final int HTTP_VERSION = 505;
-
- protected HttpURLConnection(URL var1) {
- super(var1);
- }
-
- public static void setFollowRedirects(boolean var0) {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkSetFactory();
- }
-
- followRedirects = var0;
- }
-
- public static boolean getFollowRedirects() {
- return followRedirects;
- }
-
- public void setRequestMethod(String var1) throws ProtocolException {
- if (super.connected) {
- throw new ProtocolException("Can't reset method: already connected");
- } else {
- for(int var2 = 0; var2 < methods.length; ++var2) {
- if (methods[var2].equals(var1)) {
- this.method = var1;
- return;
- }
- }
-
- throw new ProtocolException("Invalid HTTP method: " + var1);
- }
- }
-
- public String getRequestMethod() {
- return this.method;
- }
-
- public int getResponseCode() throws IOException {
- if (this.responseCode != -1) {
- return this.responseCode;
- } else {
- ((URLConnection)this).getInputStream();
- String var1 = ((URLConnection)this).getHeaderField(0);
-
- try {
- int var2;
- for(var2 = var1.indexOf(32); var1.charAt(var2) == ' '; ++var2) {
- }
-
- this.responseCode = Integer.parseInt(var1.substring(var2, var2 + 3));
- this.responseMessage = var1.substring(var2 + 4).trim();
- return this.responseCode;
- } catch (Exception var3) {
- return this.responseCode;
- }
- }
- }
-
- public String getResponseMessage() throws IOException {
- this.getResponseCode();
- return this.responseMessage;
- }
-
- public abstract void disconnect();
-
- public abstract boolean usingProxy();
- }
-