HttpIncomingRequestResponse Class

From RemObjects Software

Jump to: navigation, search

This is a Internet Pack Architecture entry
Feel free to add your notes to this topic below.



Overview

Abstract base class representing an incoming HTTP message - either a request to received by the HttpServer, or a response received by the HttpClient. You will usually deal with the separate descendants HttpServerRequest or HttpClientResponse that descend from this class.

Namespace

Declaration (C#)

public abstract class HttpIncomingRequestResponse : HttpRequestResponse;

Members

Properties

Property
Description
ContentBytes Returns the HTTP body in form of a byte array.

Note that this method is not as efficient as the ContentStream method, as the entire body will be read into a memory buffer at once.

ContentLength Contains the ContentLength header value reveived from the remote side. If the remot did not provide a length (for example in HTTP 1.0 scenarios, or if Keep-Alive is not supported), accessing the property will raise an exception.

Use the HasContentLength property to determine if a valid ContentLength has been received.

ContentStream Returns a Stream object with the HTTP body of the received request (server) or response (client).

This object is a HttpIncomingStream, which provides direct access to the underling DataConnection, but is (at leats for HTTP 1.1) limited to the number of bytes indicated by the HTTP header. As such, the same limitations as for the Connection stream class apply, you can only rad it once and forward-only, and it does not support seeking or writing.

Because ContentStream provides you with direct access to the underlying Connection Stream, it is the fastest and most efficient way to access the response (as opposed to ContentString and ContentBytes, both of which involve copying the entire data from the stream into a memory buffer).

Note also, that you can easily use ContentStream to access and process even very large HTTP bodies (such as a huge file download), without the need to comy the entire body into memory, and without having to wait for the entire download to have finished before you can start processing it.

ContentString Returns the HTTP body in form of a String object.

Note that this method is the least efficient for accessing the HTTP body, as the entire body will first be read into a memory buffer (then accessible via ContentBytes), and then converted into a string by the assigned Encoding (Encoding.ASCII by default).

HasContentLength Specifies whether the HTTP header provides a ContentLength field.


See Also


Product: RemObjects Internet Pack
Current version: Internet Pack 'Vinci' (2.0)

ListsGlossaryFeaturesHow ToComponentsToolsSamplesArticlesArchitectureIssues

Personal tools