com.planet_ink.coffee_mud.core.http
Class ProcessHTTPrequest

java.lang.Object
  extended by com.planet_ink.coffee_mud.core.http.ProcessHTTPrequest
All Implemented Interfaces:
CMObject, CMRunnable, CMLibrary, ExternalHTTPRequests, java.lang.Cloneable, java.lang.Comparable<CMObject>, java.lang.Runnable

public class ProcessHTTPrequest
extends java.lang.Object
implements CMRunnable, ExternalHTTPRequests


Nested Class Summary
protected static class ProcessHTTPrequest.JScriptablePage
           
 
Constructor Summary
ProcessHTTPrequest()
           
ProcessHTTPrequest(java.net.Socket a_sock, HTTPserver a_webServer, CMProps a_page, boolean a_isAdminServer)
           
 
Method Summary
 boolean activate()
           
 long activeTimeMillis()
          Returns the number of milliseconds this runnable has been running.
 void addRequestParameters(java.lang.String key, java.lang.String value)
           
 boolean byteCompare(byte[] buf, int start, byte[] to)
           
 int compareTo(CMObject o)
           
 CMObject copyOf()
          Similar to Cloneable.clone(), but does its best to make sure that any internal objects to this class are also copyOfed.
 byte[] doVirtualPage(byte[] data)
           
 java.lang.String doVirtualPage(java.lang.String data)
           
 java.lang.StringBuffer doVirtualPage(java.lang.StringBuffer s)
           
 java.util.List<java.lang.String> getAllRequestParameterKeys(java.lang.String keyMask)
           
 java.lang.String getBoundary(java.util.Vector data)
           
 int getContentLength(java.util.Vector data)
           
 java.lang.String getContentType(java.util.Vector data)
           
protected  java.util.Vector getData(java.io.InputStream sin)
           
 java.lang.String getHTTPclientIP()
           
 java.lang.String getHTTPRequest(java.io.InputStream sin)
           
 java.lang.String getHTTPstatus()
           
 java.lang.String getHTTPstatusInfo()
           
 java.lang.String getMimeType(java.lang.String a_extension)
           
 MudHost getMUD()
           
 java.lang.String getName()
           
 java.lang.String getPageContent(java.lang.String filename)
           
 java.lang.String getRequestEncodedParameters()
           
 java.util.Map<java.lang.String,java.lang.Object> getRequestObjects()
           
 java.lang.String getRequestParameter(java.lang.String key)
           
 java.net.InetAddress getServerAddress()
           
 java.lang.String getServerVersionString()
           
 ThreadEngine.SupportThread getSupportThread()
           
 java.util.Map<java.lang.String,java.lang.String> getVirtualDirectories()
           
 HTTPserver getWebServer()
           
 java.lang.String getWebServerPartialName()
           
 int getWebServerPort()
           
 java.lang.String getWebServerPortStr()
           
 CMFile grabFile(java.lang.String fn)
           
 java.lang.String ID()
          The CoffeeMud Java Class ID shared by all instances of this object.
 void initializeClass()
          Called ONCE after all objects are loaded, but before the map is read in during initialization.
 boolean isCompleted()
           
 boolean isRequestParameter(java.lang.String key)
           
 java.lang.String makeRedirectPage(java.lang.String url)
           
protected  int myBack(java.lang.StringBuffer s, int i)
           
protected  int myElse(java.lang.StringBuffer s, int i, int end)
           
protected  int myEndif(java.lang.StringBuffer s, int i)
           
 CMObject newInstance()
          Returns a new instance of this class.
protected  java.lang.String parseFoundMacro(java.lang.StringBuffer s, int i, boolean lookOnly)
           
protected  java.lang.String preFilter(java.lang.StringBuffer input)
           
protected  boolean process(java.lang.String inLine)
           
 void propertiesLoaded()
           
 boolean readyToRun()
           
 void removeRequestParameter(java.lang.String key)
           
 void resetRequestEncodedParameters()
           
 void run()
           
protected  java.lang.String runMacro(java.lang.String foundMacro)
           
 boolean shutdown()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProcessHTTPrequest

public ProcessHTTPrequest()

ProcessHTTPrequest

public ProcessHTTPrequest(java.net.Socket a_sock,
                          HTTPserver a_webServer,
                          CMProps a_page,
                          boolean a_isAdminServer)
Method Detail

ID

public java.lang.String ID()
Description copied from interface: CMObject
The CoffeeMud Java Class ID shared by all instances of this object. Unlike the Java Class name, this method does not include package information. However, it must return a String value unique to its class category in the ClassLoader. Class categories include Libraries, Common, Areas, Abilities, Behaviors, CharClasses, Commands, Exits Locales, MOBS, Races, WebMacros, Basic Items, Armor, Weapons, ClanItems, MiscTech. The name is typically identical to the class name.

Specified by:
ID in interface CMObject
Returns:
the name of this class

newInstance

public CMObject newInstance()
Description copied from interface: CMObject
Returns a new instance of this class.

Specified by:
newInstance in interface CMObject
Returns:
a new instance of this class

initializeClass

public void initializeClass()
Description copied from interface: CMObject
Called ONCE after all objects are loaded, but before the map is read in during initialization.

Specified by:
initializeClass in interface CMObject

copyOf

public CMObject copyOf()
Description copied from interface: CMObject
Similar to Cloneable.clone(), but does its best to make sure that any internal objects to this class are also copyOfed.

Specified by:
copyOf in interface CMObject
Returns:
a clone of this object

compareTo

public int compareTo(CMObject o)
Specified by:
compareTo in interface java.lang.Comparable<CMObject>

propertiesLoaded

public void propertiesLoaded()
Specified by:
propertiesLoaded in interface CMLibrary

readyToRun

public boolean readyToRun()

getName

public java.lang.String getName()

getVirtualDirectories

public java.util.Map<java.lang.String,java.lang.String> getVirtualDirectories()
Specified by:
getVirtualDirectories in interface ExternalHTTPRequests

getWebServer

public HTTPserver getWebServer()

getHTTPstatus

public java.lang.String getHTTPstatus()
Specified by:
getHTTPstatus in interface ExternalHTTPRequests

getHTTPstatusInfo

public java.lang.String getHTTPstatusInfo()
Specified by:
getHTTPstatusInfo in interface ExternalHTTPRequests

activate

public boolean activate()
Specified by:
activate in interface CMLibrary

shutdown

public boolean shutdown()
Specified by:
shutdown in interface CMLibrary

getSupportThread

public ThreadEngine.SupportThread getSupportThread()
Specified by:
getSupportThread in interface CMLibrary

isCompleted

public boolean isCompleted()

grabFile

public CMFile grabFile(java.lang.String fn)
Specified by:
grabFile in interface ExternalHTTPRequests

getMimeType

public java.lang.String getMimeType(java.lang.String a_extension)
Specified by:
getMimeType in interface ExternalHTTPRequests

process

protected boolean process(java.lang.String inLine)
                   throws java.lang.Exception
Throws:
java.lang.Exception

getRequestObjects

public java.util.Map<java.lang.String,java.lang.Object> getRequestObjects()
Specified by:
getRequestObjects in interface ExternalHTTPRequests

resetRequestEncodedParameters

public void resetRequestEncodedParameters()

addRequestParameters

public void addRequestParameters(java.lang.String key,
                                 java.lang.String value)
Specified by:
addRequestParameters in interface ExternalHTTPRequests

isRequestParameter

public boolean isRequestParameter(java.lang.String key)
Specified by:
isRequestParameter in interface ExternalHTTPRequests

removeRequestParameter

public void removeRequestParameter(java.lang.String key)
Specified by:
removeRequestParameter in interface ExternalHTTPRequests

getRequestParameter

public java.lang.String getRequestParameter(java.lang.String key)
Specified by:
getRequestParameter in interface ExternalHTTPRequests

getAllRequestParameterKeys

public java.util.List<java.lang.String> getAllRequestParameterKeys(java.lang.String keyMask)
Specified by:
getAllRequestParameterKeys in interface ExternalHTTPRequests

getRequestEncodedParameters

public java.lang.String getRequestEncodedParameters()
Specified by:
getRequestEncodedParameters in interface ExternalHTTPRequests

parseFoundMacro

protected java.lang.String parseFoundMacro(java.lang.StringBuffer s,
                                           int i,
                                           boolean lookOnly)

myBack

protected int myBack(java.lang.StringBuffer s,
                     int i)

preFilter

protected java.lang.String preFilter(java.lang.StringBuffer input)

myEndif

protected int myEndif(java.lang.StringBuffer s,
                      int i)

runMacro

protected java.lang.String runMacro(java.lang.String foundMacro)
                             throws HTTPRedirectException,
                                    HTTPServerException
Throws:
HTTPRedirectException
HTTPServerException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

myElse

protected int myElse(java.lang.StringBuffer s,
                     int i,
                     int end)

doVirtualPage

public byte[] doVirtualPage(byte[] data)
                     throws HTTPRedirectException
Specified by:
doVirtualPage in interface ExternalHTTPRequests
Throws:
HTTPRedirectException

doVirtualPage

public java.lang.String doVirtualPage(java.lang.String data)
                               throws HTTPRedirectException
Specified by:
doVirtualPage in interface ExternalHTTPRequests
Throws:
HTTPRedirectException

doVirtualPage

public java.lang.StringBuffer doVirtualPage(java.lang.StringBuffer s)
                                     throws HTTPRedirectException
Specified by:
doVirtualPage in interface ExternalHTTPRequests
Throws:
HTTPRedirectException

makeRedirectPage

public java.lang.String makeRedirectPage(java.lang.String url)

run

public void run()
Specified by:
run in interface java.lang.Runnable

getHTTPclientIP

public java.lang.String getHTTPclientIP()
Specified by:
getHTTPclientIP in interface ExternalHTTPRequests

getServerAddress

public java.net.InetAddress getServerAddress()
Specified by:
getServerAddress in interface ExternalHTTPRequests

getPageContent

public java.lang.String getPageContent(java.lang.String filename)
Specified by:
getPageContent in interface ExternalHTTPRequests

getData

protected java.util.Vector getData(java.io.InputStream sin)

getContentType

public java.lang.String getContentType(java.util.Vector data)

getContentLength

public int getContentLength(java.util.Vector data)

getBoundary

public java.lang.String getBoundary(java.util.Vector data)

byteCompare

public boolean byteCompare(byte[] buf,
                           int start,
                           byte[] to)

getHTTPRequest

public java.lang.String getHTTPRequest(java.io.InputStream sin)

getServerVersionString

public java.lang.String getServerVersionString()
Specified by:
getServerVersionString in interface ExternalHTTPRequests

getWebServerPort

public int getWebServerPort()
Specified by:
getWebServerPort in interface ExternalHTTPRequests

getWebServerPortStr

public java.lang.String getWebServerPortStr()
Specified by:
getWebServerPortStr in interface ExternalHTTPRequests

getWebServerPartialName

public java.lang.String getWebServerPartialName()
Specified by:
getWebServerPartialName in interface ExternalHTTPRequests

getMUD

public MudHost getMUD()
Specified by:
getMUD in interface ExternalHTTPRequests

activeTimeMillis

public long activeTimeMillis()
Description copied from interface: CMRunnable
Returns the number of milliseconds this runnable has been running.

Specified by:
activeTimeMillis in interface CMRunnable
Returns:
the time in millis