Urho3D
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Urho3D::HttpRequest Class Reference

An HTTP connection with response data stream. More...

#include </home/runner/work/rurho3d.github.io/rurho3d.github.io/urho3d_repo/Source/Urho3D/Network/HttpRequest.h>

Inheritance diagram for Urho3D::HttpRequest:
Urho3D::RefCounted Urho3D::Deserializer Urho3D::Thread

Public Member Functions

 HttpRequest (const String &url, const String &verb, const Vector< String > &headers, const String &postData)
 Construct with parameters.
 
 ~HttpRequest () override
 Destruct. Release the connection object.
 
void ThreadFunction () override
 Process the connection in the worker thread until closed. More...
 
i32 Read (void *dest, i32 size) override
 Read response data from the HTTP connection and return number of bytes actually read. While the connection is open, will block while trying to read the specified size. To avoid blocking, only read up to as many bytes as GetAvailableSize() returns. More...
 
i64 Seek (i64 position) override
 Set position from the beginning of the stream. Not supported. More...
 
bool IsEof () const override
 Return whether all response data has been read. More...
 
const StringGetURL () const
 Return URL used in the request.
 
const StringGetVerb () const
 Return verb used in the request. Default GET if empty verb specified on construction.
 
String GetError () const
 Return error. Only non-empty in the error state.
 
HttpRequestState GetState () const
 Return connection state.
 
i32 GetAvailableSize () const
 Return amount of bytes in the read buffer.
 
bool IsOpen () const
 Return whether connection is in the open state.
 
- Public Member Functions inherited from Urho3D::RefCounted
 RefCounted ()
 Construct. Allocate the reference count structure and set an initial self weak reference.
 
virtual ~RefCounted ()
 Destruct. Mark as expired and also delete the reference count structure if no outside weak references exist.
 
 RefCounted (const RefCounted &rhs)=delete
 Prevent copy construction.
 
RefCountedoperator= (const RefCounted &rhs)=delete
 Prevent assignment.
 
void AddRef ()
 Increment reference count. Can also be called outside of a SharedPtr for traditional reference counting.
 
void ReleaseRef ()
 Decrement reference count and delete self if no more references. Can also be called outside of a SharedPtr for traditional reference counting.
 
int Refs () const
 Return reference count.
 
int WeakRefs () const
 Return weak reference count.
 
RefCountRefCountPtr ()
 Return pointer to the reference count structure.
 
- Public Member Functions inherited from Urho3D::Deserializer
 Deserializer ()
 Construct with zero size.
 
 Deserializer (i64 size)
 Construct with defined size.
 
virtual ~Deserializer ()
 Destruct.
 
virtual i32 Read (void *dest, i32 size)=0
 Read bytes from the stream. Return number of bytes actually read. More...
 
virtual i64 Seek (i64 position)=0
 Set position from the beginning of the stream. Return actual new position. More...
 
virtual const StringGetName () const
 Return name of the stream. More...
 
virtual hash32 GetChecksum ()
 Return a checksum if applicable. More...
 
virtual bool IsEof () const
 Return whether the end of stream has been reached. More...
 
i64 SeekRelative (i64 delta)
 Set position relative to current position. Return actual new position.
 
i64 GetPosition () const
 Return current position.
 
i64 Tell () const
 Return current position.
 
i64 GetSize () const
 Return size.
 
long long ReadInt64 ()
 Read a 64-bit integer.
 
int ReadInt ()
 Read a 32-bit integer.
 
short ReadShort ()
 Read a 16-bit integer.
 
signed char ReadByte ()
 Read an 8-bit integer.
 
unsigned long long ReadUInt64 ()
 Read a 64-bit unsigned integer.
 
unsigned ReadUInt ()
 Read a 32-bit unsigned integer.
 
unsigned short ReadUShort ()
 Read a 16-bit unsigned integer.
 
u8 ReadUByte ()
 Read an 8-bit unsigned integer.
 
bool ReadBool ()
 Read a bool.
 
float ReadFloat ()
 Read a float.
 
double ReadDouble ()
 Read a double.
 
IntRect ReadIntRect ()
 Read an IntRect.
 
IntVector2 ReadIntVector2 ()
 Read an IntVector2.
 
IntVector3 ReadIntVector3 ()
 Read an IntVector3.
 
Rect ReadRect ()
 Read a Rect.
 
Vector2 ReadVector2 ()
 Read a Vector2.
 
Vector3 ReadVector3 ()
 Read a Vector3.
 
Vector3 ReadPackedVector3 (float maxAbsCoord)
 Read a Vector3 packed into 3 x 16 bits with the specified maximum absolute range.
 
Vector4 ReadVector4 ()
 Read a Vector4.
 
Quaternion ReadQuaternion ()
 Read a quaternion.
 
Quaternion ReadPackedQuaternion ()
 Read a quaternion with each component packed in 16 bits.
 
Matrix3 ReadMatrix3 ()
 Read a Matrix3.
 
Matrix3x4 ReadMatrix3x4 ()
 Read a Matrix3x4.
 
Matrix4 ReadMatrix4 ()
 Read a Matrix4.
 
Color ReadColor ()
 Read a color.
 
BoundingBox ReadBoundingBox ()
 Read a bounding box.
 
String ReadString ()
 Read a null-terminated string.
 
String ReadFileID ()
 Read a four-letter file ID.
 
StringHash ReadStringHash ()
 Read a 32-bit StringHash.
 
Vector< u8 > ReadBuffer ()
 Read a buffer with size encoded as VLE.
 
ResourceRef ReadResourceRef ()
 Read a resource reference.
 
ResourceRefList ReadResourceRefList ()
 Read a resource reference list.
 
Variant ReadVariant ()
 Read a variant.
 
Variant ReadVariant (VariantType type)
 Read a variant whose type is already known.
 
VariantVector ReadVariantVector ()
 Read a variant vector.
 
StringVector ReadStringVector ()
 Read a string vector.
 
VariantMap ReadVariantMap ()
 Read a variant map.
 
unsigned ReadVLE ()
 Read a variable-length encoded unsigned integer, which can use 29 bits maximum.
 
unsigned ReadNetID ()
 Read a 24-bit network object ID.
 
String ReadLine ()
 Read a text line.
 
- Public Member Functions inherited from Urho3D::Thread
 Thread ()
 Construct. Does not start the thread yet.
 
virtual ~Thread ()
 Destruct. If running, stop and wait for thread to finish.
 
virtual void ThreadFunction ()=0
 The function to run in the thread. More...
 
bool Run ()
 Start running the thread. Return true if successful, or false if already running or if can not create the thread.
 
void Stop ()
 Set the running flag to false and wait for the thread to finish.
 
void SetPriority (int priority)
 Set thread priority. The thread must have been started first.
 
bool IsStarted () const
 Return whether thread exists.
 

Private Member Functions

Pair< i32, bool > CheckAvailableSizeAndEof () const
 Check for available read data in buffer and whether end has been reached. Must only be called when the mutex is held by the main thread.
 

Private Attributes

String url_
 URL.
 
String verb_
 Verb.
 
String error_
 Error string. Empty if no error.
 
Vector< Stringheaders_
 Headers.
 
String postData_
 POST data.
 
HttpRequestState state_
 Connection state.
 
Mutex mutex_
 Mutex for synchronizing the worker and the main thread.
 
SharedArrayPtr< u8 > httpReadBuffer_
 Read buffer for the worker thread.
 
SharedArrayPtr< u8 > readBuffer_
 Read buffer for the main thread.
 
i32 readPosition_
 Read buffer read cursor.
 
i32 writePosition_
 Read buffer write cursor.
 

Additional Inherited Members

- Static Public Member Functions inherited from Urho3D::Thread
static void SetMainThread ()
 Set the current thread as the main thread.
 
static ThreadID GetCurrentThreadID ()
 Return the current thread's ID.
 
static bool IsMainThread ()
 Return whether is executing in the main thread.
 
- Protected Attributes inherited from Urho3D::Deserializer
i64 position_
 Stream position.
 
i64 size_
 Stream size.
 
- Protected Attributes inherited from Urho3D::Thread
void * handle_
 Thread handle.
 
volatile bool shouldRun_
 Running flag.
 
- Static Protected Attributes inherited from Urho3D::Thread
static ThreadID mainThreadID
 Main thread's thread ID.
 

Detailed Description

An HTTP connection with response data stream.

Member Function Documentation

◆ IsEof()

bool Urho3D::HttpRequest::IsEof ( ) const
overridevirtual

Return whether all response data has been read.

Reimplemented from Urho3D::Deserializer.

◆ Read()

i32 Urho3D::HttpRequest::Read ( void *  dest,
i32  size 
)
overridevirtual

Read response data from the HTTP connection and return number of bytes actually read. While the connection is open, will block while trying to read the specified size. To avoid blocking, only read up to as many bytes as GetAvailableSize() returns.

Implements Urho3D::Deserializer.

◆ Seek()

i64 Urho3D::HttpRequest::Seek ( i64  position)
overridevirtual

Set position from the beginning of the stream. Not supported.

Implements Urho3D::Deserializer.

◆ ThreadFunction()

void Urho3D::HttpRequest::ThreadFunction ( )
overridevirtual

Process the connection in the worker thread until closed.

Implements Urho3D::Thread.


The documentation for this class was generated from the following files: