NETLIB II

URL

This class contains more than just the ascii string that the W3C calls a URL, as it contains all the data associated with a URL operation: the address, the host's IP addresses, the method, the content-type, etc. Basically, it's the old URL_Struct, cleaned up and rewritten.

Definition

This class is defined in java, and is compiled with JMC. The C syntax is included in each method description, and is summarised below.
package netscape.url;
import netscape.jmc.*;
import netscape.types.*;

public abstract class URL {
    public URL(String address) throws Exception {};

    public abstract String GetAddress();
    public abstract void SetAddress(String add) throws Exception;

    public abstract String GetDestinationAddress();
    public abstract void SetDestinationAddress(String dest) throws Exception;

    public abstract String GetIPAddressString();
    public abstract void SetIPAddressString(String string) throws Exception;

    // HTTPMethod is an enumeration that contains the following:
    // Get, Post, Head, Put, Delete, Mkdir, Move, Index, and Other.
    // "Other" is for random HTTP methods, set with SetMethodName.
    // Caling SetMethodName automatically sets the method enum to Other;
    // Don't set the enumeration to Other directly.

    public abstract HTTPMethod GetMethod();
    public abstract void SetMethod(HTTPMethod method) throws Exception;

    public abstract String GetMethodName();
    public abstract void SetMethodName(String string) throws Exception;

    // ServerID: this is the introductory string sent by the server.
    // For HTTP it's the "Server:" header (or NULL if there wasn't one).
    // For things like FTP, NNTP, SMPT, etc. it's the introductory header
    // sent by the server upon connection.  GetIsNetsite returns true
    // if the server id indicates a Netscape (or "Netsite") server.

    public abstract String GetServerID();
    public abstract void SetServerID(String string) throws Exception;
    public abstract boolean GetIsNetsite();

    // This "server status" code is always an HTTP status code, even for
    // other protocols: so if an FTP server says "file not found," this will
    // still be HTTP's "404" code.

    public abstract int GetServerStatus();
    public abstract void SetServerStatus(int status);

    // Some booleans about the resource

    public abstract boolean GetIsDirectory();
    public abstract void SetIsDirectory(boolean isdir);

    public abstract boolean GetIsBinaryStream();
    public abstract void SetIsBinaryStream(boolean is_binary);

    // Headers: HeaderDirection is an enumeration with two values:
    // Incoming and Outgoing.  The sets of headers are distinct.

    // SetHeader with two arguments adds the entire string as a line.
    public abstract void SetHeader(HeaderDirection which, String line) throws Exception;

    // SetHeader with three arguments adds a line in the form "name: value"
    public abstract void SetHeader(HeaderDirection which, String name, String value) throws Exception;

    // GetHeader with a string argument gets that name's value, or NULL if it doesn't exist.
    public abstract String GetHeader(HeaderDirection which, String name);

    // GetHeader with a numeric argument gets the n'th header, in the order returned.
    // If n is out of range, this returns NULL.
    public abstract String GetHeader(HeaderDirection which, int n);

    // The header count.
    public abstract int GetHeaderCount(HeaderDirection which);

    // Some headers are complex (or hard to parse), and some values are rather common,
    // so they get special-case routines.

    public abstract String GetIncomingContentType();
    public abstract String GetIncomingContentEncoding();
    public abstract String GetIncomingContentName();
    public abstract String GetIncomingCharset();
    public abstract Time GetIncomingExpiration() throws Exception;
    public abstract Time GetIncomingLastModified() throws Exception;
    public abstract Time GetIncomingServerDate() throws Exception;

    public abstract int GetIncomingContentLength();
    public abstract void SetOutgoingContentLength(int length) throws Exception;

    // Deferred until later: attaching outgoing data directly (instead of streaming
    // it out), this includes multiple file posting; caching, which includes forced
    // reload, can-do-byteranges, and other stuff; direct authentication header
    // support (but you can use the general header routiens); security; history.
}

Interface Methods

Inherited Methods

This class inherits the usual JMC base methods.

C interface

#include "URL.h"

URL *URLFactory_Create(JMCException **e, const char *address);
const char *URL_GetAddress(URL *self, JMCException **e);
void URL_SetAddress(URL *self, const char *address, JMCException **e);
const char *URL_GetDestinationAddress(URL *self, JMCException **e);
void URL_SetDestinationAddress(URL *self, const char *destination, JMCException **e);
const char *URL_GetIPAddressString(URL *self, JMCException **e);
void URL_SetIPAddressString(URL *self, const char *addresses, JMCException **e);
URL_HTTPMethod URL_GetMethod(URL *self, JMCException **e);
void URL_SetMethod(URL *self, URL_HTTPMethod method, JMCException **e);
const char *URL_GetMethodName(URL *self, JMCException **e);
void URL_SetMethodName(URL *self, const char *name, JMCException **e);
const char *URL_GetServerID(URL *self, JMCException **e);
void URL_SetServerID(URL *self, const char *id, JMCException **e);
jbool URL_GetIsNetsite(URL *self, JMCException **e);
jint URL_GetServerStatus(URL *self, JMCException **e);
void URL_SetServerStatus(URL *self, jint status, JMCException **e);
jbool URL_GetIsDirectory(URL *self, JMCException **e);
void URL_SetIsDirectory(URL *self, jbool isdir, JMCException **e);
jbool URL_GetIsBinaryStream(URL *self, JMCException **e);
void URL_SetIsBinaryStream(URL *self, jbool isbinary, JMCException **e);
void URL_SetHeader(URL *self, URL_HeaderDirection which, const char *header, JMCException **e);
void URL_SetHeader_1(URL *self, URL_HeaderDirection which, const char *keyword, const char *value, JMCException **e);
const char *URL_GetHeader(URL *self, URL_HeaderDirection which, const char *keyword, JMCException **e);
const char *URL_GetHeader_1(URL *self, URL_HeaderDirection which, jint n, JMCException **e);
jint URL_GetHeaderCount(URL *self, URL_HeaderDirection which, JMCException **e);
const char *URL_GetIncomingContentType(URL *self, JMCException **e);
const char *URL_GetIncomingContentEncoding(URL *self, JMCException **e);
const char *URL_GetIncomingContentName(URL *self, JMCException **e);
const char *URL_GetIncomingCharset(URL *self, JMCException **e);
PRTime URL_GetIncomingExpiration(URL *self, JMCException **e);
PRTime URL_GetIncomingLastModified(URL *self, JMCException **e);
PRTime URL_GetIncomingServerDate(URL *self, JMCException **e);
jint URL_GetIncomingContentLength(URL *self, JMCException **e);
void URL_SetOutgoingContentLength(URL *self, jint length, JMCException **e);

/* methods inherited from base JMC object interface */
void *URL_getInterface(URL *self, JMCInterfaceID id, JMCException **e);
void URL_addRef(URL *self, JMCException **e);
void URL_release(URL *self, JMCException **e);
jint URL_hashCode(URL *self, JMCException **e);
void *URL_clone(URL *self, JMCException **e);
const char *URL_toString(URL *self, JMCException **e);
void URL_finalize(URL *self, JMCException **e);


This document was written by Frederick at 17:33 17.03.1997.