Default implementation of the ISimpleHttp interface.
sealed class
|
SimpleHttp
|
extends
|
Disposable
|
||
implements
|
ISimpleHttp
|
The number of attempts to make for accessing an HTTP resource.
public
property
|
Attempts
{
get
set
}
|
||
type
|
int32
|
||
value
|
|
The number of attempts. |
Remarks:
The
default
value
is
3
.
Returns the lifecycle state of this object.
public
virtual
property
|
LifecycleState
{
get
}
|
||
type
|
LifecycleState
|
||
value
|
The lifecycle state. | ||
inherited
|
Disposable.LifecycleState
|
The request timeout.
public
property
|
Timeout
{
get
set
}
|
||
type
|
int32
|
||
value
|
|
The timeout value, in milliseconds. | |
implements
|
ISimpleHttp.Timeout
|
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
Creates a new instance of SimpleHttp.
public
constructor
|
SimpleHttp
(string userAgent = null)
|
||
params
|
userAgent
|
Specifies
the
HTTP
User-Agent
string
to
use.
If
null ,
the
following
string
will
be
used:
'Tinman3D/X.Y',
where
X
and
Y
are
the
major
resp.
minor
version
numbers
of
TinmanCoreModule
(see
Info).
Defaults
to
null .
|
Acquires a strong reference to this disposable object.
[OwnerReturn, ThreadSafe]
|
||||
public
method
|
AcquireTry
()
|
|||
type
|
IDisposable
|
|||
returns
|
this
if
a
new
strong
reference
has
been
acquired,
null
if
this
object
is
already
being
disposed.
|
|||
inherited
|
Disposable.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.
Cancels all pending HTTP requests.
public
method
|
Cancel
()
|
||
implements
|
ISimpleHttp.Cancel
|
Remarks:
A
cancelled
HTTP
request
has
a
StatusCode
of
0
and
an
Error
of
Cancelled.
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]
|
||||
public
method
|
Dispose
()
|
|||
inherited
|
Disposable.Dispose
|
Remarks:
The Dispose method silently returns if the object has already been disposed.
Performs an HTTP/1.1 GET request on the given resource byte range.
[ThreadSafe]
|
||||
public
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. | |||
implements
|
ISimpleHttp.GetBytes
|
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.
Performs an HTTP/1.1 GET request on the given image resource.
[ThreadSafe]
|
||||
public
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. | |||
implements
|
ISimpleHttp.GetImage
|
Remarks:
The
following
image
types
are
supported:
BMP
,
GIF
,
PNG
,
JPEG
and
TIFF
.
Performs an HTTP/1.1 GET request on the given resource.
[ThreadSafe]
|
||||
public
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. | |||
implements
|
ISimpleHttp.GetText
|
Performs an HTTP/1.1 HEAD request on the given resource.
[ThreadSafe]
|
||||
public
method
|
Head
(string url)
|
|||
type
|
SimpleHttpResult
|
|||
params
|
url
|
[not-empty]
|
The URL of the resource. | |
returns
|
The request result status. | |||
implements
|
ISimpleHttp.Head
|
The logger object of this class.
public
static
readonly
field
|
Logger
|
||
type
|
ILogger
|