C# Class XenAPI.HTTP

Show file Open project: xapi-project/xen-api-sdk Class Usage Examples

Public Methods

Method Description
BuildUri ( string hostname, string path ) : Uri

Build a URI from a hostname, a path, and some query arguments

CONNECT ( Uri uri, IWebProxy proxy, String session, int timeout_ms ) : Stream
ConnectStream ( Uri uri, IWebProxy proxy, bool nodelay, int timeout_ms ) : Stream

This function will connect a stream to a uri (host and port), negotiating proxies and SSL

CopyStream ( Stream inStream, Stream outStream, DataCopiedDelegate progressDelegate, FuncBool cancellingDelegate ) : long
GET ( Uri uri, IWebProxy proxy, int timeout_ms ) : Stream
Get ( DataCopiedDelegate dataCopiedDelegate, FuncBool cancellingDelegate, Uri uri, IWebProxy proxy, string path, int timeout_ms ) : void

A general HTTP GET method, with delegates for progress and cancelling. May throw various exceptions.

PUT ( Uri uri, IWebProxy proxy, long ContentLength, int timeout_ms ) : Stream
Put ( UpdateProgressDelegate progressDelegate, FuncBool cancellingDelegate, Uri uri, IWebProxy proxy, string path, int timeout_ms ) : void

A general HTTP PUT method, with delegates for progress and cancelling. May throw various exceptions.

UseSSL ( Uri uri ) : bool
getResultCode ( string line ) : int

Private Methods

Method Description
ConnectSocket ( Uri uri, bool nodelay, int timeout_ms ) : NetworkStream
DO_HTTP ( Uri uri, IWebProxy proxy, bool nodelay, int timeout_ms ) : Stream
ReadHttpHeaders ( Stream &stream, IWebProxy proxy, bool nodelay, int timeout_ms ) : bool

Read HTTP headers, doing any redirects as necessary

ReadLine ( Stream stream ) : string
ValidateServerCertificate ( object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors ) : bool
WriteLine ( Stream stream ) : void
WriteLine ( String txt, Stream stream ) : void

Method Details

BuildUri() public static method

Build a URI from a hostname, a path, and some query arguments
public static BuildUri ( string hostname, string path ) : Uri
hostname string
path string
return System.Uri

CONNECT() public static method

public static CONNECT ( Uri uri, IWebProxy proxy, String session, int timeout_ms ) : Stream
uri System.Uri
proxy IWebProxy
session String
timeout_ms int
return Stream

ConnectStream() public static method

This function will connect a stream to a uri (host and port), negotiating proxies and SSL
public static ConnectStream ( Uri uri, IWebProxy proxy, bool nodelay, int timeout_ms ) : Stream
uri System.Uri
proxy IWebProxy
nodelay bool
timeout_ms int Timeout, in ms. 0 for no timeout.
return Stream

CopyStream() public static method

public static CopyStream ( Stream inStream, Stream outStream, DataCopiedDelegate progressDelegate, FuncBool cancellingDelegate ) : long
inStream Stream
outStream Stream
progressDelegate DataCopiedDelegate
cancellingDelegate FuncBool
return long

GET() public static method

public static GET ( Uri uri, IWebProxy proxy, int timeout_ms ) : Stream
uri System.Uri
proxy IWebProxy
timeout_ms int
return Stream

Get() public static method

A general HTTP GET method, with delegates for progress and cancelling. May throw various exceptions.
public static Get ( DataCopiedDelegate dataCopiedDelegate, FuncBool cancellingDelegate, Uri uri, IWebProxy proxy, string path, int timeout_ms ) : void
dataCopiedDelegate DataCopiedDelegate
cancellingDelegate FuncBool Delegate called periodically to see if need to cancel
uri System.Uri URI to GET from
proxy IWebProxy A proxy to handle the HTTP connection
path string Path to file to receive the data
timeout_ms int Timeout for the connection in ms. 0 for no timeout.
return void

PUT() public static method

public static PUT ( Uri uri, IWebProxy proxy, long ContentLength, int timeout_ms ) : Stream
uri System.Uri
proxy IWebProxy
ContentLength long
timeout_ms int
return Stream

Put() public static method

A general HTTP PUT method, with delegates for progress and cancelling. May throw various exceptions.
public static Put ( UpdateProgressDelegate progressDelegate, FuncBool cancellingDelegate, Uri uri, IWebProxy proxy, string path, int timeout_ms ) : void
progressDelegate UpdateProgressDelegate Delegate called periodically (500ms) with percent complete
cancellingDelegate FuncBool Delegate called periodically to see if need to cancel
uri System.Uri URI to PUT to
proxy IWebProxy A proxy to handle the HTTP connection
path string Path to file to put
timeout_ms int Timeout for the connection in ms. 0 for no timeout.
return void

UseSSL() public static method

public static UseSSL ( Uri uri ) : bool
uri System.Uri
return bool

getResultCode() public static method

public static getResultCode ( string line ) : int
line string
return int