ISimpleHttp

Description

interface Tinman.Core.IO.ISimpleHttp

Derived from

IDisposableGeneric<ISimpleHttp>

Extended by

SimpleHttp sealed

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

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

Public / Methods

Cancel


public method Cancel → ()

Cancels all pending HTTP requests.

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

Get​Bytes


[ThreadSafe]
public method GetBytes → (5)

url in : string

[not-empty]
The URL of the resource.

buffer in : ByteBuffer

[not-null]
The output buffer. The ByteBuffer object will not be modified by this method. The current buffer position (see ByteBuffer.Position) will be queried iff bufferOffset opt is -1.

bufferOffset opt : int32 = -1

[>=-1]
Offset into output buffer in. If set to -1, the current buffer position (see ByteBuffer.Position) will be used.

from opt : int64 = 0

[>=0]
Start of byte range (inclusive).

to opt : int64 = 0

[>=0]
End of byte range (exclusive).

returns → SimpleHttpResult

The request result status.

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

On success, exactly SimpleHttpResult.Length bytes have been written to buffer in. If the given byte range is empty (i.e. to opt is less than or equal to from opt), 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 in 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 opt parameter could become equal to the file size.

Get​Image


[ThreadSafe]
public method GetImage → (7)

url in : string

[not-empty]
The URL of the image resource.

width in : int32

[>=0]
The expected width of the image, in pixels.

height in : int32

[>=0]
The expected height of the image, in pixels.

pixels in : int64 [ ]

[not-null]
Output array for image image pixels (see Colors).

offset in : int32

[>=0]
Offset into pixels in to top-left output pixel.

stride in : int32

[>=0]
Distance between adjacent pixels rows in pixels in.

defaultSrgb opt : bool = true

If the downloaded image data does not specify a color-space, assume that it is using the sRGB color-space and perform gamma correction accordingly.

returns → SimpleHttpResult

The request result status.

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

Get​Text


[ThreadSafe]
public method GetText → (2)

url in : string

[not-empty]
The URL of the resource.

buffer in : StringBuilder

[not-null]
The output buffer.

returns → SimpleHttpResult

The request result status.

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

Head


[ThreadSafe]
public method Head → (1)

url in : string

[not-empty]
The URL of the resource.

returns → SimpleHttpResult

The request result status.

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

Public / Attributes

Can​Get​Image


public attribute CanGetImage → (get)

value : bool

true if GetImage is supported,
false if it is not and will always fail with an HTTP error code.

Does this ISimpleHttp object support GetImage?

Can​Get​Text


public attribute CanGetText → (get)

value : bool

true if GetText is supported,
false if it is not and will always fail with an HTTP error code.

Does this ISimpleHttp object support GetText?

Get​Text​Task


public attribute GetTextTask → (get)

value : ITask<string, string>

[not-null]
The task object.

Returns a new ITask object, for calling GetText asynchronously.

Head​Task


public attribute HeadTask → (get)

value : ITask<string, SimpleHttpResult>

[not-null]
The task object.

Returns a new ITask object, for calling Head asynchronously.

Timeout


public attribute Timeout → (get,set)

value : int32

[>0]
The timeout value, in milliseconds.

The request timeout.

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

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

IOException

If an I/O error has occurred.