I search for solutions in this order: Past Code, Unreal Source, Wiki, BUF, groups.yahoo, google, screaming at monitor. – RegularX

Legacy:LibHTTP/HttpCache

From Unreal Wiki, The Unreal Engine Documentation Site
< Legacy:LibHTTP
Revision as of 09:14, 19 November 2007 by Sweavo (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Disk\Memory cache for LibHTTP, it will handle caching of data. To use it simply create a HttpCache object and use it's get() request to get updated documents. Don't use a HttpSock instance for this.

When using this class it will perform a specially constructed get request when it's needed, it will try to satisfy the caching headers returned by the server. Ihis class is only usefull if you know the remote server returns correct cachable data. By default most dynamic pages (ASP, PHP, Perl, CGI) will return non-cachable pages.

Properties

array<CacheInfoRecord> CacheList 
cache list, each entry is an URL
array<HttpCacheObject> CacheObjectList 
the spawned cache objects
class<HttpCacheObject> HttpCacheObjectClass 
class<HttpSock> HttpSockClass 
array<CacheRequest> Requests 
running requests

Options

int iCacheLimit 
maximum cache size (entries?)

Enums

ECacheFailError

Reasons for a failure

CF_None 
CF_BadRequest 
CF_AuthRequired 
CF_Timeout 
CF_ResolveFailed 
CF_Busy 
CF_Unknown 

EDataOrigin

Hints where the data came from

DO_Unknown 
DO_Cache 
DO_Initial 
DO_Refresh 

Structures

CacheInfoRecord

records of the cached entries

int colidx 
index in the CacheObjectList, volatile
int DataSize 
last datazie
int Hash 
hash used for record info
int LastUpdate 
last update
HttpUtil.xURL URL 
the request URL

CacheRequest

int idx 
HttpSock Socket 

Delegates

OnComplete(HttpCache Sender, HttpCacheObject Data, EDataOrigin origin )
Will be called when the operation was completed successfully.
int OnCreateSock(HttpCache Sender, HttpSock Socket )
Will be called after the HttpSock instance has been created. Use it to set certain variables and delegates for the HttpSock.
Note: You shouldn't set any delegates in the sccket, most will be overwritten anyway.
OnError(HttpCache Sender, string ErrorMessage, optional string Param1, optional string Param2 )
Will be called in case of an internal error.
OnFail(HttpCache Sender, int idx, ECacheFailError reason )
failed to complete the request, will be called when everything fails

Functions

CacheCleanup( )
Clean up the cache
int createHash(string URL )
return the hash of the URL
DownloadComplete(HttpSock Sender )
DownloadError(HttpSock Sender, string ErrorMessage, optional string Param1, optional string Param2 )
DownloadTimeout(HttpSock Sender )
int findCacheRecord(int hash )
find an idx using a hash
int get(string location )
Performs a get request. Returns the ID of the request. This Id can be used in to retrieve the URL in the future
HttpCacheObject getCacheObject(int idx )
get\create a CacheObject
bool getURLbyId(int id, out string URL )
Returns the URL for a certain ID. Result will be false when the ID is no longer valid.
bool isCached(string location )
Returns true when the location is cached
ResolveFailed(HttpSock Sender, string hostname )

Events

PreBeginPlay( )