New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial

Allow the transfer of data files using the W3C's specification for HTTP multipart form data. Microsoft's version has a bug where it does not format the ending boundary correctly.

Definition

Namespace:Telerik.Web.UI.Editor.DialogControls

Assembly:Telerik.Web.UI.dll

Syntax:

C#
public class HTTPSend : IDisposable

Inheritance: objectHTTPSend

Implements: IDisposable

Inherited Members object.ToString()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()object.GetType()object.MemberwiseClone()...

Constructors

Initialize our class for use to send data files.

C#
public HTTPSend(string url)
Parameters:urlstring

The URL of the destination server.

Properties

The string that defines the begining boundary of our multipart transfer as defined in the w3c specs. This method also sets the Content and Ending boundaries as defined by the w3c specs.

C#
public string BeginBoundary { get; set; }

Allows us to determine the size of the buffer used to send a piece of the file at a time out the IO stream. Defaults to 1024 * 10.

C#
public int BufferSize { get; set; }

Allows us to specifiy the certificate to use for secure communications.

C#
public X509Certificate Certificate { get; set; }

Gets or sets a value indicating whether the file can be sent in smaller packets.

C#
public bool Chunked { get; set; }

The string that defines the content boundary of our multipart transfer as defined in the w3c specs.

C#
public string ContentBoundary { get; set; }

Allows us to specified the credentials used for the transfer.

C#
public ICredentials Credentials { get; set; }

The string that defines the ending boundary of our multipart transfer as defined in the w3c specs.

C#
public string EndingBoundary { get; set; }

Gets or sets a value indicating whether the Expect100-Continue header should be sent.

C#
public bool Expect100 { get; set; }

Used to change the content type of the file being sent. Currently defaults to: text/xml. Other options are text/plain or binary.

C#
public string FileContentType { get; set; }

Gets or sets a value indicating whether to make a persistent connection to the Internet resource.

C#
public bool KeepAlive { get; set; }

Gets or sets a value indicating whether to pipeline the request to the Internet resource.

C#
public bool Pipelined { get; set; }

The data returned to us after the transfer is completed.

C#
public StringBuilder ResponseText { get; set; }

Allows you to specify the specific version of HTTP to use for uploads. The dot NET stuff currently does not allow you to remove the continue-100 header from 1.1 and 1.0 currently has a bug in it where it adds the continue-100. MS has sent a patch to remove the continue-100 in HTTP 1.0.

C#
public Version TransferHttpVersion { get; set; }

The web address of the recipient of the transfer.

C#
public string URL { get; set; }

Methods

C#
public void Dispose()

Implements: IDisposable.Dispose()

C#
protected virtual void Dispose(bool disposing)
Parameters:disposingbool

Returns the proper content information for the file we are sending.

C#
public string GetFileHeader(string filename)
Parameters:filenamestring

The local path to the file that should be sent.

Returns:

string

All file headers, properly formatted in a string.

Creates the proper ending boundary for the multipart upload.

C#
public string GetFileTrailer()
Returns:

string

The ending boundary.

Builds the proper format of the multipart data that contains the form fields and their respective values.

C#
public string GetFormFields()
Returns:

string

All form fields, properly formatted in a string.

Make the request to the web server and retrieve it's response into a text buffer.

C#
public void GetResponse()

Determines if we have a file stream set, and returns either the HttpWebRequest stream or the file.

C#
public Stream GetStream()
Returns:

Stream

Either the HttpWebRequest stream or the local output file.

C#
public void SendFile(string filename)
Parameters:filenamestring

Transmits a file to the web server stated in the URL property. You may call this several times and it will use the values previously set for fields and URL.

C#
public void SendTextAsFile(string content, string filename)
Parameters:contentstring

the text to send

filenamestring

The local path of the file to send.

Allows you to add some additional field data to be sent along with the transfer. This is usually used for things like userid and password to validate the transfer.

C#
public void SetField(string name, string value)
Parameters:namestring

The name of the custom field.

valuestring

The value of the custom field.

Used to signal we want the output to go to a text file verses being transfered to a URL.

C#
public void SetFilename(string path)
Parameters:pathstring

The local path to the output file.

Allows you to add some additional header data to be sent along with the transfer.

C#
public void SetHeader(string name, string value)
Parameters:namestring

The name of the custom header.

valuestring

The value of the custom header.

Reads in the file a chunck at a time then sends it to the output stream.

C#
public void WriteFile(Stream output, string filename)
Parameters:outputStream

The stream to write to.

filenamestring

The local path of the file to send.

Mainly used to turn the string into a byte buffer and then write it to our IO stream.

C#
public static void WriteString(Stream output, string data)
Parameters:outputStream

The stream to write to.

datastring

The data to place into the stream.