ClintHeyer.Httpd
Class FSContext

File System Context. Serves static pages.

Field Summary
string docRoot
string mount
int READ_BUFFER_LEN
int readBufferLenSet

Fields inherited from class ClintHeyer.Httpd.Context
configuration, contexts, padlock, parent, requiresSession, sessionManager, throttleRate

Constructor Summary
FSContext(string mount, string docRoot, ClintHeyer.Httpd.Context parent, ClintHeyer.Httpd.Lock padlock)
         Constructor. Defines a mount point, document root, parent context and a lock
FSContext(string mount, string docRoot, ClintHeyer.Httpd.Context parent)
         Constructor. Defines a mount point, document root and parent context

Property Summary
string DocumentRoot
         Gets the document root for this context
string MountedPoint
         Gets the mount point for this context
string Url
         Gets the base Url for this context

Properties inherited from class ClintHeyer.Httpd.Context
Lock, Parent, RequiresSession, ServerManager, SessionManager, ThrottleRate, TicketIssuer

Method Summary
bool CanHandleRequest(string request)
         Can we handle a given request?
int GetReadBufferLen(long throttle)
void Handle(ClintHeyer.Httpd.HttpRequest request, string extraPath)
         Handle a request
void HandleRangedRequest(ClintHeyer.Httpd.HttpRequest request, ClintHeyer.Httpd.URI requestUri, ClintHeyer.Httpd.HttpReply reply, System.IO.Stream fs, System.Int64[,] ranges, int readBufferLen)
long NormaliseRange(long start, long end, long length)
         Normalises relatives ranges to a file-based range.
void OnThrottleChange(ClintHeyer.Httpd.ThrottleChangeEvent args)
void SendFile(ClintHeyer.Httpd.URI requestURI, string path, ClintHeyer.Httpd.HttpReply reply, ClintHeyer.Httpd.HttpRequest request)
         Sends a file to requester
void SendRange(ClintHeyer.Httpd.HttpRequest request, ClintHeyer.Httpd.HttpReply reply, System.IO.Stream stream, long start, long end, string contentType, int readBufferLen)
         Sends a byte range
void SendStream(ClintHeyer.Httpd.HttpRequest request, ClintHeyer.Httpd.HttpReply reply, System.IO.Stream stream, System.IO.BinaryReader reader, int readBufferLen)
         Sends data stream
string ToString()
         Gets a string representation of context. In the form of
mountPoint > docRoot

Methods inherited from class ClintHeyer.Httpd.Context
AddContext, AddResponseHandler, GetContexts, GetMimeType, GetResponseHandler, IConfigurable.Get, IConfigurable.GetBool, IConfigurable.GetFloat, IConfigurable.GetInt, IConfigurable.GetString, LoadConfig, OnReplyCompleted, OnReplyCompletedEvent, OnReplyStarted, OnReplyStartedEvent, OnThrottleChangeEvent, RemoveContext, SaveConfig

Methods inherited from class System.Object
Equals, Finalize, GetHashCode, GetType, MemberwiseClone

Events inherited from class ClintHeyer.Httpd.Context
ReplyCompleted, ReplyStarted, ThrottleChange


Field Detail

docRoot

protected string docRoot


mount

protected string mount


READ_BUFFER_LEN

public int READ_BUFFER_LEN


readBufferLenSet

protected int readBufferLenSet

Constructor Detail

FSContext

public FSContext(string mount,
                 string docRoot,
                 ClintHeyer.Httpd.Context parent,
                 ClintHeyer.Httpd.Lock padlock)

Constructor. Defines a mount point, document root, parent context and a lock

Parameters:
mount - Mount point
docRoot - Document root
parent - Parent context
padlock - Lock (or null)

FSContext

public FSContext(string mount,
                 string docRoot,
                 ClintHeyer.Httpd.Context parent)

Constructor. Defines a mount point, document root and parent context

Parameters:
mount - Mount point
docRoot - Document root
parent - Parent context
Property Detail

DocumentRoot

public string DocumentRoot

Gets the document root for this context


MountedPoint

public string MountedPoint

Gets the mount point for this context


Url

public string Url

Gets the base Url for this context

Method Detail

CanHandleRequest

public bool CanHandleRequest(string request)

Can we handle a given request?

Parameters:
request - Request
Returns:

GetReadBufferLen

private int GetReadBufferLen(long throttle)


Handle

public void Handle(ClintHeyer.Httpd.HttpRequest request,
                   string extraPath)

Handle a request

Parameters:
request - Request
extraPath - Extra path
Throws:
ClintHeyer.Httpd.ResourceLockedException - Locked

HandleRangedRequest

private void HandleRangedRequest(ClintHeyer.Httpd.HttpRequest request,
                                 ClintHeyer.Httpd.URI requestUri,
                                 ClintHeyer.Httpd.HttpReply reply,
                                 System.IO.Stream fs,
                                 System.Int64[,] ranges,
                                 int readBufferLen)


NormaliseRange

private long NormaliseRange(long start,
                            long end,
                            long length)

Normalises relatives ranges to a file-based range.

Parameters:
start - Start
end - End
length - Length of file
Returns:
Length of range

OnThrottleChange

protected void OnThrottleChange(ClintHeyer.Httpd.ThrottleChangeEvent args)


SendFile

protected void SendFile(ClintHeyer.Httpd.URI requestURI,
                        string path,
                        ClintHeyer.Httpd.HttpReply reply,
                        ClintHeyer.Httpd.HttpRequest request)

Sends a file to requester

Parameters:
requestURI - Request URI
path - Path
reply - Reply
request - Request

SendRange

private void SendRange(ClintHeyer.Httpd.HttpRequest request,
                       ClintHeyer.Httpd.HttpReply reply,
                       System.IO.Stream stream,
                       long start,
                       long end,
                       string contentType,
                       int readBufferLen)

Sends a byte range

Parameters:
request - Request
reply - Reply
stream - Stream to read from
start - Start position (normalised)
end - End
contentType - Content type
readBufferLen - Read buffer length

SendStream

protected void SendStream(ClintHeyer.Httpd.HttpRequest request,
                          ClintHeyer.Httpd.HttpReply reply,
                          System.IO.Stream stream,
                          System.IO.BinaryReader reader,
                          int readBufferLen)

Sends data stream

Parameters:
reply - Reply
stream - Stream to read from. Can be pre-seeked
reader - Reader
readBufferLen - Read buffer size
request - Request

ToString

public string ToString()

Gets a string representation of context. In the form of

mountPoint > docRoot

Returns: