home *** CD-ROM | disk | FTP | other *** search
- package sun.net.www;
-
- import java.io.IOException;
- import java.net.URL;
-
- public abstract class URLConnection extends java.net.URLConnection {
- private String contentType;
- private int contentLength = -1;
- protected MessageHeader properties = new MessageHeader();
-
- public URLConnection(URL var1) {
- super(var1);
- }
-
- public MessageHeader getProperties() {
- return this.properties;
- }
-
- public void setProperties(MessageHeader var1) {
- this.properties = var1;
- }
-
- public void setRequestProperty(String var1, String var2) {
- if (super.connected) {
- throw new IllegalAccessError("Already connected");
- } else {
- this.properties.add(var1, var2);
- }
- }
-
- public String getHeaderField(String var1) {
- try {
- ((java.net.URLConnection)this).getInputStream();
- } catch (Exception var2) {
- return null;
- }
-
- return this.properties == null ? null : this.properties.findValue(var1);
- }
-
- public String getHeaderFieldKey(int var1) {
- try {
- ((java.net.URLConnection)this).getInputStream();
- } catch (Exception var3) {
- return null;
- }
-
- MessageHeader var2 = this.properties;
- return var2 == null ? null : var2.getKey(var1);
- }
-
- public String getHeaderField(int var1) {
- try {
- ((java.net.URLConnection)this).getInputStream();
- } catch (Exception var3) {
- return null;
- }
-
- MessageHeader var2 = this.properties;
- return var2 == null ? null : var2.getValue(var1);
- }
-
- public String getContentType() {
- if (this.contentType == null) {
- this.contentType = this.getHeaderField("content-type");
- }
-
- if (this.contentType == null) {
- String var1 = null;
-
- try {
- var1 = java.net.URLConnection.guessContentTypeFromStream(((java.net.URLConnection)this).getInputStream());
- } catch (IOException var3) {
- }
-
- String var2 = this.properties.findValue("content-encoding");
- if (var1 == null) {
- var1 = this.properties.findValue("content-type");
- if (var1 == null) {
- if (super.url.getFile().endsWith("/")) {
- var1 = "text/html";
- } else {
- var1 = java.net.URLConnection.guessContentTypeFromName(super.url.getFile());
- }
- }
- }
-
- if (var1 == null || var2 != null && !var2.equalsIgnoreCase("7bit") && !var2.equalsIgnoreCase("8bit") && !var2.equalsIgnoreCase("binary")) {
- var1 = "content/unknown";
- }
-
- this.contentType = var1;
- }
-
- return this.contentType;
- }
-
- public void setContentType(String var1) {
- this.contentType = var1;
- }
-
- public int getContentLength() {
- try {
- ((java.net.URLConnection)this).getInputStream();
- } catch (Exception var3) {
- return -1;
- }
-
- int var1 = this.contentLength;
- if (var1 < 0) {
- try {
- var1 = Integer.parseInt(this.properties.findValue("content-length"));
- this.contentLength = var1;
- } catch (Exception var2) {
- }
- }
-
- return var1;
- }
-
- protected void setContentLength(int var1) {
- this.contentLength = var1;
- }
-
- public boolean canCache() {
- return super.url.getFile().indexOf(63) < 0;
- }
-
- public void close() {
- super.url = null;
- }
- }
-