Top Description Fields Constructors Methods
org.hsqldb.server

pack-priv Class WebServerConnection

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.io.BufferedOutputStream, .DataInputStream, .File, .FileInputStream, .IOException, .InputStream, .OutputStream, java.net.HttpURLConnection, .Socket, java.nio.ByteBuffer, java.nio.charset.Charset, .CharsetDecoder, org.hsqldb.DatabaseManager, .HsqlException, .Session, org.hsqldb.error.Error, .ErrorCode, org.hsqldb.lib.ArrayUtil, .DataOutputStream, .HsqlByteArrayOutputStream, .InOutUtil, org.hsqldb.lib.java.JavaSystem, org.hsqldb.persist.HsqlDatabaseProperties, org.hsqldb.resources.ResourceBundleHandler, org.hsqldb.result.Result, .ResultConstants, org.hsqldb.rowio.RowInputBinary, .RowOutputBinary

A web server connection is a transient object that lasts for the duration of the SQL call and its result. This class uses the notification mechanism in WebServer to allow cleanup after a SHUTDOWN.

The POST method is used for login and subsequent remote calls. In 1.7.2 The initial login establishes a persistent Session and returns its handle to the client. Subsequent calls are executed in the context of this session.

(fredt@users)

Author
Fred Toussi (fredt@users dot sourceforge.net)
Since
1.6.2
Version
2.7.0

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static byte[]
pack-priv static byte[]
pack-priv static byte[]
pack-priv static byte[]
pack-priv static final byte[]
private static final Charset
private static final String
private static final String
private static final String
private static final String
private static final int
private CharsetDecoder
pack-priv final byte[]
private static final int
private static final int
private static final int
private static final int
private RowInputBinary
private RowOutputBinary
private WebServer
private Socket

Constructor Summary

AccessConstructor and Description
pack-priv
WebServerConnection(Socket
the network socket on which WebServer communication takes place
socket
,
WebServer
the WebServer instance to which the object represents a connection
server
)

Creates a new WebServerConnection to the specified WebServer on the specified socket.

Method Summary

Modifier and TypeMethod and Description
pack-priv String

Returns:

the thread name to be used when this object is the Runnable object of a Thread.
getConnectionThreadName
()

Retrieves the thread name to be used when this object is the Runnable object of a Thread.

pack-priv String

Returns:

an HTTP protocol header
getHead
(String
the HTTP response code
responseCodeString
,
boolean
true if additional header info is to be added
addInfo
,
String
the Content-Type field value
mimeType
,
int
the Content-Length field value
length
)

Retrieves an HTTP protocol header given the supplied arguments.

private String

Returns:

a best-guess mime-type string using the file extension of the name argument.
getMimeTypeString
(String name)

Retrieves a best-guess mime-type string using the file extension of the name argument.

private void
processError(int
the error condition code
code
)

Processes an HTTP error condition, sending an error response to the client.

private void
processGet(String
the name of the content to get
name
,
boolean
whether to send the content as well, or just the header
send
)

Processes an HTTP GET request

private void
processPost(InputStream inStream, String name)

POST is used only for database access.

pack-priv void
processQuery(InputStream
the incoming byte stream representing the HSQL protocol database query
inStream
)

Processes a database query in HSQL protocol that has been tunneled over HTTP protocol.

public void
run()

Implements java.lang.Runnable.run.

Causes this WebServerConnection to process its HTTP request in a blocking fashion until the request is fully processed or an exception occurs internally.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BUFFER_SIZEback to summary
pack-priv static final int BUFFER_SIZE
BYTES_CONTENTback to summary
pack-priv static byte[] BYTES_CONTENT
BYTES_GETback to summary
pack-priv static byte[] BYTES_GET
BYTES_HEADback to summary
pack-priv static byte[] BYTES_HEAD
BYTES_POSTback to summary
pack-priv static byte[] BYTES_POST
BYTES_WHITESPACEback to summary
pack-priv static final byte[] BYTES_WHITESPACE
ENCODINGback to summary
private static final Charset ENCODING
HEADER_BAD_REQUESTback to summary
private static final String HEADER_BAD_REQUEST
HEADER_FORBIDDENback to summary
private static final String HEADER_FORBIDDEN
HEADER_NOT_FOUNDback to summary
private static final String HEADER_NOT_FOUND
HEADER_OKback to summary
private static final String HEADER_OK
hnd_content_typesback to summary
private static final int hnd_content_types
iso_8859_1_decoderback to summary
private CharsetDecoder iso_8859_1_decoder
mainBufferback to summary
pack-priv final byte[] mainBuffer
REQUEST_TYPE_BADback to summary
private static final int REQUEST_TYPE_BAD
REQUEST_TYPE_GETback to summary
private static final int REQUEST_TYPE_GET
REQUEST_TYPE_HEADback to summary
private static final int REQUEST_TYPE_HEAD
REQUEST_TYPE_POSTback to summary
private static final int REQUEST_TYPE_POST
rowInback to summary
private RowInputBinary rowIn
rowOutback to summary
private RowOutputBinary rowOut
serverback to summary
private WebServer server
socketback to summary
private Socket socket

Constructor Detail

WebServerConnectionback to summary
pack-priv WebServerConnection(Socket socket, WebServer server)

Creates a new WebServerConnection to the specified WebServer on the specified socket.

Parameters
socket:Socket

the network socket on which WebServer communication takes place

server:WebServer

the WebServer instance to which the object represents a connection

Method Detail

getConnectionThreadNameback to summary
pack-priv String getConnectionThreadName()

Retrieves the thread name to be used when this object is the Runnable object of a Thread.

Returns:String

the thread name to be used when this object is the Runnable object of a Thread.

getHeadback to summary
pack-priv String getHead(String responseCodeString, boolean addInfo, String mimeType, int length)

Retrieves an HTTP protocol header given the supplied arguments.

Parameters
responseCodeString:String

the HTTP response code

addInfo:boolean

true if additional header info is to be added

mimeType:String

the Content-Type field value

length:int

the Content-Length field value

Returns:String

an HTTP protocol header

getMimeTypeStringback to summary
private String getMimeTypeString(String name)

Retrieves a best-guess mime-type string using the file extension of the name argument.

Returns:String

a best-guess mime-type string using the file extension of the name argument.

processErrorback to summary
private void processError(int code)

Processes an HTTP error condition, sending an error response to the client.

Parameters
code:int

the error condition code

processGetback to summary
private void processGet(String name, boolean send)

Processes an HTTP GET request

Parameters
name:String

the name of the content to get

send:boolean

whether to send the content as well, or just the header

processPostback to summary
private void processPost(InputStream inStream, String name)

POST is used only for database access. So we can assume the strings are those generated by ClientConnectionHTTP

processQueryback to summary
pack-priv void processQuery(InputStream inStream)

Processes a database query in HSQL protocol that has been tunneled over HTTP protocol.

Parameters
inStream:InputStream

the incoming byte stream representing the HSQL protocol database query

runback to summary
public void run()

Implements java.lang.Runnable.run.

Causes this WebServerConnection to process its HTTP request in a blocking fashion until the request is fully processed or an exception occurs internally. This method reads the Request line then delegates action to subroutines.