Naanou.ResourceExchange
Class NaanouDirectContext

Allows users to download a resource just by its content hash

Field Summary
string HDR_DOWNLOAD_URL
string HDR_FILENAME
string HDR_HASH
string HDR_LENGTH
string HDR_PART
string HDR_PART_LAS
string HDR_PARTS
string HDR_RANGE_END
string HDR_RANGE_START
string HDR_SERVER_CONTACTS
string HDR_SERVER_NAME
string HDR_SERVER_SIMUL
string HDR_SERVER_THROTTLE
string HDR_THROTTLE
         Throttle for this reply
string HDR_URL
string HDR_USER
string HDR_USER_AGENT
string HDR_VERSION

Fields inherited from class Naanou.ResourceExchange.NaanouContext
description

Fields inherited from class ClintHeyer.Httpd.FSContext
docRoot, mount, readBufferLenSet

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

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

Properties inherited from class Naanou.ResourceExchange.NaanouContext
Description, Lister

Properties inherited from class ClintHeyer.Httpd.FSContext
DocumentRoot, MountedPoint, Url

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

Method Summary
int GetReadBufferLen(long throttle)
void Handle(ClintHeyer.Httpd.HttpRequest request, string extraPath)
         Handle a request
void HandleGet(ClintHeyer.Httpd.HttpRequest request, string hash)
void HandleHead(ClintHeyer.Httpd.HttpRequest request, string hash)
int LocateTemporaryBlocks(ClintHeyer.Httpd.HttpReply reply, string hash, int blockCount)
         Locates a resource in the temporary block storage area
bool SendRange(ClintHeyer.Httpd.HttpRequest request, ClintHeyer.Httpd.HttpReply reply, System.IO.Stream stream, long start, long end, int readBufferLen)
         Sends a byte range

Methods inherited from class Naanou.ResourceExchange.NaanouContext
IsValidRequest

Methods inherited from class ClintHeyer.Httpd.FSContext
CanHandleRequest, OnThrottleChange, SendFile, SendStream, ToString

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

HDR_DOWNLOAD_URL

public string HDR_DOWNLOAD_URL


HDR_FILENAME

public string HDR_FILENAME


HDR_HASH

public string HDR_HASH


HDR_LENGTH

public string HDR_LENGTH


HDR_PART

public string HDR_PART


HDR_PART_LAS

public string HDR_PART_LAS


HDR_PARTS

public string HDR_PARTS


HDR_RANGE_END

public string HDR_RANGE_END


HDR_RANGE_START

public string HDR_RANGE_START


HDR_SERVER_CONTACTS

public string HDR_SERVER_CONTACTS


HDR_SERVER_NAME

public string HDR_SERVER_NAME


HDR_SERVER_SIMUL

public string HDR_SERVER_SIMUL


HDR_SERVER_THROTTLE

public string HDR_SERVER_THROTTLE


HDR_THROTTLE

public string HDR_THROTTLE

Throttle for this reply


HDR_URL

public string HDR_URL


HDR_USER

public string HDR_USER


HDR_USER_AGENT

public string HDR_USER_AGENT


HDR_VERSION

public string HDR_VERSION

Constructor Detail

NaanouDirectContext

public NaanouDirectContext(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)
Method Detail

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

HandleGet

private void HandleGet(ClintHeyer.Httpd.HttpRequest request,
                       string hash)


HandleHead

private void HandleHead(ClintHeyer.Httpd.HttpRequest request,
                        string hash)


LocateTemporaryBlocks

private int LocateTemporaryBlocks(ClintHeyer.Httpd.HttpReply reply,
                                  string hash,
                                  int blockCount)

Locates a resource in the temporary block storage area

Parameters:
reply - Reply to add part details too
hash - Resource hash
blockCount - Start index from
Returns:
Number of parts found

SendRange

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

Sends a byte range

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