C# Class TrotiNet.HttpSocket

Communication state between two hosts
Inheritance: IDisposable
Mostrar archivo Open project: Gizeta/Nekoxy-fiddler Class Usage Examples

Public Properties

Property Type Description
id int

Protected Properties

Property Type Description
LowLevelSocket Socket

Public Methods

Method Description
CloseSocket ( ) : void

Close the internal socket

Dispose ( ) : void

Close the wrapped socket

HttpSocket ( Socket socket ) : System

Wrap a Socket instance into a HttpSocket instance

IsSocketDead ( ) : bool

Returns true if the socket has been closed, or has become unresponsive

ReadAsciiLine ( ) : string

Reads a LF-delimited (or CRLF-delimited) line from the socket, and returns it (without the trailing newline character)

ReadBinary ( ) : uint

Read buffered binary data

A read operation (for instance, ReadAsciiLine) may have loaded the buffer with some data which ended up not being used. If that's the case, then ReadBinary uses it (ReadRaw does not).

Send302 ( ) : void

Send a HTTP 302 redirection over the socket

Send400 ( ) : void

Send a HTTP 400 error over the socket

Send403 ( ) : void

Send a HTTP 403 error over the socket

Send404 ( ) : void

Send a HTTP 404 error over the socket

Send501 ( ) : void

Send a HTTP 501 error over the socket

TunnelChunkedDataTo ( HttpSocket dest ) : void

Tunnel a HTTP-chunked blob of data

The tunneling stops when the last chunk, identified by a size of 0, arrives. The optional trailing entities are also transmitted (but otherwise ignored).

TunnelChunkedDataTo ( MessagePacketHandler mph ) : void

Tunnel a HTTP-chunked blob of data to the specified packet handler

The tunneling stops when the last chunk, identified by a size of 0, arrives. The optional trailing entities are also transmitted (but otherwise ignored).

TunnelDataTo ( HttpSocket dest ) : uint

Transfer data from this socket to the destination socket until this socket closes

TunnelDataTo ( HttpSocket dest, uint nb_bytes ) : uint

Read nb_bytes bytes from the socket, and send it to the destination socket

TunnelDataTo ( MessagePacketHandler mph ) : uint

Transfer data from the socket to the specified packet handler until the socket closes

TunnelDataTo ( MessagePacketHandler mph, byte buffer ) : uint

Sends a buffer to the specified packet handler

TunnelDataTo ( MessagePacketHandler mph, uint nb_bytes ) : uint

Read nb_bytes bytes from the socket, and send it to the specified packet handler

TunnelDataTo ( byte &buffer ) : uint

Fills the buffer with an unknown amount of data from the socket

TunnelDataTo ( byte buffer, uint byte_count ) : uint

Write data from a buffer to the socket

WriteAsciiLine ( string s ) : uint

Write an ASCII string, a CR character, and a LF character to the socket

WriteBinary ( byte b ) : uint

Write an array of bytes to the socket

WriteBinary ( byte b, uint nb_bytes ) : uint

Write the first nb_bytes of b to the socket

WriteBinary ( byte b, uint offset, uint nb_bytes ) : uint

Write nb_bytes of b, starting at offset offset to the socket

Protected Methods

Method Description
ReadRaw ( ) : uint

Read a block of data from the socket; unread data that was in the buffer is dropped

BufferPosition is reset. If there were unread data in the buffer, it's lost.

Private Methods

Method Description
SendHttpError ( string ErrorCodeAndReason ) : void
Trace ( string msg ) : void
TunnelChunkedDataTo ( HttpSocket dest, MessagePacketHandler mph ) : void

Method Details

CloseSocket() public method

Close the internal socket
public CloseSocket ( ) : void
return void

Dispose() public method

Close the wrapped socket
public Dispose ( ) : void
return void

HttpSocket() public method

Wrap a Socket instance into a HttpSocket instance
public HttpSocket ( Socket socket ) : System
socket Socket
return System

IsSocketDead() public method

Returns true if the socket has been closed, or has become unresponsive
public IsSocketDead ( ) : bool
return bool

ReadAsciiLine() public method

Reads a LF-delimited (or CRLF-delimited) line from the socket, and returns it (without the trailing newline character)
public ReadAsciiLine ( ) : string
return string

ReadBinary() public method

Read buffered binary data
A read operation (for instance, ReadAsciiLine) may have loaded the buffer with some data which ended up not being used. If that's the case, then ReadBinary uses it (ReadRaw does not).
public ReadBinary ( ) : uint
return uint

ReadRaw() protected method

Read a block of data from the socket; unread data that was in the buffer is dropped
BufferPosition is reset. If there were unread data in the buffer, it's lost.
protected ReadRaw ( ) : uint
return uint

Send302() public method

Send a HTTP 302 redirection over the socket
public Send302 ( ) : void
return void

Send400() public method

Send a HTTP 400 error over the socket
public Send400 ( ) : void
return void

Send403() public method

Send a HTTP 403 error over the socket
public Send403 ( ) : void
return void

Send404() public method

Send a HTTP 404 error over the socket
public Send404 ( ) : void
return void

Send501() public method

Send a HTTP 501 error over the socket
public Send501 ( ) : void
return void

TunnelChunkedDataTo() public method

Tunnel a HTTP-chunked blob of data
The tunneling stops when the last chunk, identified by a size of 0, arrives. The optional trailing entities are also transmitted (but otherwise ignored).
public TunnelChunkedDataTo ( HttpSocket dest ) : void
dest HttpSocket The destination socket
return void

TunnelChunkedDataTo() public method

Tunnel a HTTP-chunked blob of data to the specified packet handler
The tunneling stops when the last chunk, identified by a size of 0, arrives. The optional trailing entities are also transmitted (but otherwise ignored).
public TunnelChunkedDataTo ( MessagePacketHandler mph ) : void
mph MessagePacketHandler
return void

TunnelDataTo() public method

Transfer data from this socket to the destination socket until this socket closes
public TunnelDataTo ( HttpSocket dest ) : uint
dest HttpSocket
return uint

TunnelDataTo() public method

Read nb_bytes bytes from the socket, and send it to the destination socket
public TunnelDataTo ( HttpSocket dest, uint nb_bytes ) : uint
dest HttpSocket
nb_bytes uint
return uint

TunnelDataTo() public method

Transfer data from the socket to the specified packet handler until the socket closes
public TunnelDataTo ( MessagePacketHandler mph ) : uint
mph MessagePacketHandler
return uint

TunnelDataTo() public method

Sends a buffer to the specified packet handler
public TunnelDataTo ( MessagePacketHandler mph, byte buffer ) : uint
mph MessagePacketHandler
buffer byte
return uint

TunnelDataTo() public method

Read nb_bytes bytes from the socket, and send it to the specified packet handler
public TunnelDataTo ( MessagePacketHandler mph, uint nb_bytes ) : uint
mph MessagePacketHandler
nb_bytes uint
return uint

TunnelDataTo() public method

Fills the buffer with an unknown amount of data from the socket
public TunnelDataTo ( byte &buffer ) : uint
buffer byte data from the socket
return uint

TunnelDataTo() public method

Write data from a buffer to the socket
public TunnelDataTo ( byte buffer, uint byte_count ) : uint
buffer byte
byte_count uint
return uint

WriteAsciiLine() public method

Write an ASCII string, a CR character, and a LF character to the socket
public WriteAsciiLine ( string s ) : uint
s string
return uint

WriteBinary() public method

Write an array of bytes to the socket
public WriteBinary ( byte b ) : uint
b byte
return uint

WriteBinary() public method

Write the first nb_bytes of b to the socket
public WriteBinary ( byte b, uint nb_bytes ) : uint
b byte
nb_bytes uint
return uint

WriteBinary() public method

Write nb_bytes of b, starting at offset offset to the socket
public WriteBinary ( byte b, uint offset, uint nb_bytes ) : uint
b byte
offset uint
nb_bytes uint
return uint

Property Details

LowLevelSocket protected_oe property

Returns the wrapped socket
protected Socket LowLevelSocket
return Socket

id public_oe property

Socket UID.
public int id
return int