ClintHeyer.Httpd
Class HttpReply

HTTP reply

Field Summary
System.Collections.ArrayList buffer
bool buffered
long bufferSize
bool chunked
bool closed
string contentType
ClintHeyer.Httpd.Context context
ClintHeyer.Httpd.IEncoder encoder
System.Collections.ArrayList header
bool headersSent
bool keepAlive
long length
ClintHeyer.Httpd.HttpRequest request
ClintHeyer.Httpd.HttpResponse response
bool sectionStarted
long sent
ClintHeyer.Httpd.HttpSession session
long throttleRate

Constructor Summary
HttpReply(ClintHeyer.Httpd.HttpRequest request)
         Constructor, attempts to work out context manually (based on request)
HttpReply(ClintHeyer.Httpd.HttpRequest request, ClintHeyer.Httpd.Context handlingContext)
         Constructor

Property Summary
bool Buffered
         Gets or sets whether output is buffered
bool Chunked
         Gets or sets whether output is chunked
long ContentLength
         Gets the content length
string ContentType
         Gets or sets the content type of the reply
ClintHeyer.Httpd.IEncoder Encoder
         Gets or sets the encoder to use
bool HeadersSent
         Have the headers been sent already?
bool IsClosed
         Has the request been closed?
bool KeepAlive
         Gets or sets whether keep alive is used
ClintHeyer.Httpd.HttpRequest Request
         Gets the request that triggered this reply
ClintHeyer.Httpd.HttpResponse Response
         Gets or sets the Response
long Sent
         Number of bytes sent (including headers)
long ThrottleRate
         Gets current throttle rate
long TransferRate
         Bytes per second of transfer

Method Summary
void AddHeader(string name, string val)
         Adds a header
void AddRawHeader(string raw)
         Adds a raw header into the reply. Ensure it is properly formed
void BufferAdd(byte[] data, int length)
void Close()
         Finishes off sending a reply (automatically closes off an open section).
void EndSection()
         Closes a section
void FlushBuffer()
         Flushes any buffered data, including buffered data in any current chunk
void FlushBuffer(bool chunkExempt)
         Flushes any buffered data
void OnThrottleRateChanged(ClintHeyer.Httpd.Context sender, ClintHeyer.Httpd.ThrottleChangeEvent args)
void SendChunkHeader(long size)
         Sends a chunk header of known size
void SendCRLF()
         Sends a new line
void SendData(string data)
         Sends a string without a CRLF on the end
void SendHeaders()
void SendImpl(byte[] data)
void SendImpl(byte[] data, int length)
void SendImpl(string data)
void SendLine(string data)
         Sends text with a CRLF at the end (used for sending individual lines of text)
void SendSection(byte[] data)
         Sends byte data
void SendSection(string data)
         Sends string data
void SendSection(byte[] data, int length)
         Sends data
void StartSection()
         Starts a section of unknown size
void StartSection(long knownSize)
         Starts a section of known size

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


Field Detail

buffer

private System.Collections.ArrayList buffer


buffered

private bool buffered


bufferSize

private long bufferSize


chunked

private bool chunked


closed

private bool closed


contentType

private string contentType


context

private ClintHeyer.Httpd.Context context


encoder

private ClintHeyer.Httpd.IEncoder encoder


header

private System.Collections.ArrayList header


headersSent

private bool headersSent


keepAlive

private bool keepAlive


length

private long length


request

private ClintHeyer.Httpd.HttpRequest request


response

private ClintHeyer.Httpd.HttpResponse response


sectionStarted

private bool sectionStarted


sent

private long sent


session

private ClintHeyer.Httpd.HttpSession session


throttleRate

private long throttleRate

Constructor Detail

HttpReply

public HttpReply(ClintHeyer.Httpd.HttpRequest request)

Constructor, attempts to work out context manually (based on request)

Parameters:
request - Original request

HttpReply

public HttpReply(ClintHeyer.Httpd.HttpRequest request,
                 ClintHeyer.Httpd.Context handlingContext)

Constructor

Parameters:
request - Original request
handlingContext - Context it's served from
Property Detail

Buffered

public bool Buffered

Gets or sets whether output is buffered


Chunked

public bool Chunked

Gets or sets whether output is chunked

Throws:
System.InvalidOperationException - If turned on when HTTP version is 1.0

ContentLength

public long ContentLength

Gets the content length


ContentType

public string ContentType

Gets or sets the content type of the reply

Throws:
System.InvalidOperationException - Set after headers have been sent

Encoder

public ClintHeyer.Httpd.IEncoder Encoder

Gets or sets the encoder to use

Throws:
System.InvalidOperationException - When encoder h

HeadersSent

public bool HeadersSent

Have the headers been sent already?


IsClosed

public bool IsClosed

Has the request been closed?


KeepAlive

public bool KeepAlive

Gets or sets whether keep alive is used


Request

public ClintHeyer.Httpd.HttpRequest Request

Gets the request that triggered this reply


Response

public ClintHeyer.Httpd.HttpResponse Response

Gets or sets the Response

Throws:
System.InvalidOperationException - Response set after headers have been sent

Sent

public long Sent

Number of bytes sent (including headers)


ThrottleRate

public long ThrottleRate

Gets current throttle rate


TransferRate

public long TransferRate

Bytes per second of transfer

Method Detail

AddHeader

public void AddHeader(string name,
                      string val)

Adds a header

Parameters:
name - Name
val - Value
Throws:
System.InvalidOperationException - Headers have already been sent

AddRawHeader

public void AddRawHeader(string raw)

Adds a raw header into the reply. Ensure it is properly formed

Parameters:
raw - Raw header
Throws:
System.InvalidOperationException - Headers have already been sent

BufferAdd

private void BufferAdd(byte[] data,
                       int length)


Close

public void Close()

Finishes off sending a reply (automatically closes off an open section).


EndSection

public void EndSection()

Closes a section

Throws:
System.InvalidOperationException - A section has not been started

FlushBuffer

public void FlushBuffer()

Flushes any buffered data, including buffered data in any current chunk


FlushBuffer

public void FlushBuffer(bool chunkExempt)

Flushes any buffered data

Parameters:
chunkExempt - Should buffered data be exempt from any current chunk?

OnThrottleRateChanged

private void OnThrottleRateChanged(ClintHeyer.Httpd.Context sender,
                                   ClintHeyer.Httpd.ThrottleChangeEvent args)


SendChunkHeader

private void SendChunkHeader(long size)

Sends a chunk header of known size

Parameters:
size - Size
Throws:
System.ArgumentOutOfRangeException - Size is less than zero

SendCRLF

public void SendCRLF()

Sends a new line


SendData

public void SendData(string data)

Sends a string without a CRLF on the end

Parameters:
data -

SendHeaders

private void SendHeaders()


SendImpl

private void SendImpl(byte[] data)


SendImpl

private void SendImpl(byte[] data,
                      int length)


SendImpl

private void SendImpl(string data)


SendLine

public void SendLine(string data)

Sends text with a CRLF at the end (used for sending individual lines of text)

Parameters:
data -

SendSection

public void SendSection(byte[] data)

Sends byte data

Parameters:
data - Data
Throws:
System.InvalidOperationException - A section has not been started

SendSection

public void SendSection(string data)

Sends string data

Parameters:
data - Data
Throws:
System.InvalidOperationException - A section has not been started

SendSection

public void SendSection(byte[] data,
                        int length)

Sends data

Parameters:
data - Data
length - Length
Throws:
System.InvalidOperationException - A section has not been started

StartSection

public void StartSection()

Starts a section of unknown size

Throws:
ClintHeyer.Httpd.ConnectionClosedException - Connection is closed

StartSection

public void StartSection(long knownSize)

Starts a section of known size

Parameters:
knownSize - Size (bytes)
Throws:
ClintHeyer.Httpd.ConnectionClosedException - Connection is closed