hypercast
Class HTTP_ServerUtility

java.lang.Object
  |
  +--hypercast.HTTP_ServerUtility

public class HTTP_ServerUtility
extends java.lang.Object

This class contains a set of static functions used by UDP_HTTP_ServerAdapter and HTTP_Server for server transactions. These functions translate a message from bytes into a string of hexadecimal characters ('0'-'9' or 'A'-'F'), insert that string into a CGI query, read the response, translate the response back into a byte[] and return it.


Field Summary
static int MAX_SERVER_RESPONSE_SIZE
          Maximum size of a response coming from the server.
 
Constructor Summary
HTTP_ServerUtility()
           
 
Method Summary
static java.lang.String decodeURLString(java.lang.String s)
          This method takes a string from a URL (e.g.
static java.lang.String encodeURLString(java.lang.String s)
          This function encodes a string in a URL format.
static java.lang.String query(java.lang.String urlString)
          Builds a simple query without a message and return the response as a string.
static byte[] query(java.lang.String server_query_prefix, java.lang.String overlayID, byte[] input_message)
          Builds a query with a message and return the response as another message.
static byte[] toByteArray(java.lang.String s)
          This is the inverse function of toHexString().
static java.lang.String toHexString(byte[] a)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_SERVER_RESPONSE_SIZE

public static final int MAX_SERVER_RESPONSE_SIZE
Maximum size of a response coming from the server.

See Also:
Constant Field Values
Constructor Detail

HTTP_ServerUtility

public HTTP_ServerUtility()
Method Detail

query

public static java.lang.String query(java.lang.String urlString)
                              throws java.net.MalformedURLException,
                                     java.io.IOException
Builds a simple query without a message and return the response as a string.

java.net.MalformedURLException
java.io.IOException

query

public static byte[] query(java.lang.String server_query_prefix,
                           java.lang.String overlayID,
                           byte[] input_message)
                    throws java.net.MalformedURLException,
                           java.io.IOException
Builds a query with a message and return the response as another message.

java.net.MalformedURLException
java.io.IOException

toHexString

public static java.lang.String toHexString(byte[] a)

toByteArray

public static byte[] toByteArray(java.lang.String s)
This is the inverse function of toHexString(). It takes a string of hexidecimal digits and returns a byte[]. The string can end with nothing, a newline character, or a carriage return. Any extraneous characters causes an error message to be printed and null returned.


decodeURLString

public static java.lang.String decodeURLString(java.lang.String s)
This method takes a string from a URL (e.g. CGI forms request) and converts it into a normal string. This means that '+' gets converted into ' ', and for any '%', the next two characters are treated as the hex encoding of an ASCII character. WARNING: THIS IS POORLY CODED AND MAY NOT WORK ON NON-ASCII SYSTEMS!


encodeURLString

public static java.lang.String encodeURLString(java.lang.String s)
This function encodes a string in a URL format. This means that all ' ' become '+' and any of the characters "&=?+" are encoded using '%' and the character encoded as the hexidecimal of their ASCII value.