TINMAN 3D / REALTIME TERRAIN
Software Development Kit - User Manual

interface ISimpleHttp in Tinman.Core.IO

The ISimpleHttp interface provides methods for performing synchronous HTTP/HTTPS requests for small binary resources, images and plain text.

interface ISimpleHttp extends IDisposable
  base of SimpleHttp

Remarks

When an ISimpleHttp object is disposed, all pending requests will be cancelled.

Attributes

LifecycleState

Returns the lifecycle state of this object.

property LifecycleState { get }
type LifecycleState
value The lifecycle state.
inherited ILifecycleState.LifecycleState

Timeout

The request timeout.

property Timeout { get set }
type int32
value [>0] The timeout value, in milliseconds.

Remarks:

The default timeout value is 15000 (i.e. 15 seconds).

An HTTP request that has timed out has a StatusCode of 0 and an Error of TimeOut

Methods

AcquireTry

Acquires a strong reference to this disposable object.

[OwnerReturn, ThreadSafe]
method AcquireTry ()
type IDisposable
returns this if a new strong reference has been acquired, null if this object is already being disposed.
inherited IDisposable.AcquireTry

Remarks:

The object will not be actually disposed by calls to Dispose when there is at least one strong reference left. Code that calls the AcquireTry method is responsible for calling the Dispose method accordingly.

This method is not intended to be used in performance-critical code. It should only be used to high-level resource management.

Cancel

Cancels all pending HTTP requests.

method Cancel ()

Remarks:

A cancelled HTTP request has a StatusCode of 0 and an Error of Cancelled.

Dispose

Releases all resources held by this object if there are no more strong references to it, decrements the reference counter by one otherwise.

[Dispose, OwnerThis, ThreadSafe]
method Dispose ()
inherited IDisposable.Dispose

Remarks:

The Dispose method silently returns if the object has already been disposed.

GetBytes

Performs an HTTP/1.1 GET request on the given resource byte range.

[ThreadSafe]
method GetBytes (string url, ByteBuffer buffer, int32 bufferOffset = -1, int64 from = 0, int64 to = 0)
type SimpleHttpResult
params url [not-empty] The URL of the resource.
  buffer [not-null] The output buffer. The ByteBuffer object will not be modified by this method. The current buffer position (see Position) will be queried iff bufferOffset is -1.
  bufferOffset [>=-1] Offset into output buffer. If set to -1, the current buffer position (see Position) will be used.
  from [>=0] Start of byte range (inclusive). Defaults to 0.
  to [>=0] End of byte range (exclusive). Defaults to 0.
returns The request result status.

Remarks:

On success, exactly Length bytes have been written to buffer. If the given byte range is empty (i.e. to is less than or equal to from), the entire content is to be returned.

Less data may be returned if the given byte range exceeds the file size, or if all remaining bytes in buffer have already been written to.

If the byte range is not empty and lies outside of the file range, the HTTP server is supposed to return the status code 416:Requested Range Not Satisfiable'. This must be taken into account when GET-ing consecutive byte chunks up to the end-of-file, since the from parameter could become equal to the file size.

GetImage

Performs an HTTP/1.1 GET request on the given image resource.

[ThreadSafe]
method GetImage (string url, int32 width, int32 height, [] int64[] pixels, int32 offset, int32 stride)
type SimpleHttpResult
params url [not-empty] The URL of the image resource.
  width [>=0] The expected width of the image, in pixels.
  height [>=0] The expected height of the image, in pixels.
  pixels [not-null] Output array for image image pixels (see Colors).
  offset [>=0] Offset into pixels to top-left output pixel.
  stride [>=0] Distance between adjacent pixels rows in pixels.
returns The request result status.

Remarks:

The following image types are supported: BMP, GIF, PNG, JPEG and TIFF.

GetText

Performs an HTTP/1.1 GET request on the given resource.

[ThreadSafe]
method GetText (string url, StringBuilder buffer)
type SimpleHttpResult
params url [not-empty] The URL of the resource.
  buffer [not-null] The output buffer.
returns The request result status.

Head

Performs an HTTP/1.1 HEAD request on the given resource.

[ThreadSafe]
method Head (string url)
type SimpleHttpResult
params url [not-empty] The URL of the resource.
returns The request result status.