Legacy:LibHTTP/HttpUtil - Unreal Wiki

# Legacy:LibHTTP/HttpUtil

### From Unreal Wiki, The Unreal Engine Documentation Site

< Legacy:LibHTTP
UT2004 :: Object >> HttpUtil

Miscelaneous static functions. Part of LibHTTP.

Contains various algorithms, under which Base64 encoding and MD5 hash generation. MD5 code by Petr Jelinek.

## Constants

TOKEN_HASH = "#"
  URL delimiter

TOKEN_PATH = "/"
  URL delimiter

TOKEN_PORT = ":"
  URL delimiter

TOKEN_PROTOCOL = "://"
  URL delimiter; to seperate protocol from the rest

TOKEN_QUERY = "?"
  URL delimiter

TOKEN_USER = "@"
  URL delimiter

TOKEN_USERPASS = ":"
  URL delimiter; to seperate the user and pass from the url

URL_ESCAPE = "%"
  URL escape token

## Properties

string DayNamesLong[7]
  names of the days, 0 = sunday

string DayNamesShort[7]
  names of the days, 0 = sunday

int LOGDATA
int LOGERR
int LOGINFO
int LOGWARN
string MonthNames[13]
  month names to use for date string generation

int MonthOffsetLeap[13]
  days offsets for each month

int MonthOffset[13]
  days offsets for each month

## Structures

### DateTime

int day
int hour
int minute
int month
int second
int weekday
int year

### MD5_CTX

MD5 context

array<byte> buffer
  input buffer

array<int> count
  number of bits, modulo 2^64 (lsb first)

array<int> state
  state (ABCD)

### xURL

a better URL structure that contains all elements

string hash
  the part after the #, without the leading #

string hostname
  the hostname

string location
  the location field, all from the hostname up to the query or hash string, includes leading /

string password
  possible password that was in the url

int port
  the port number specified in the URL

string protocol
  protocol used, like http://, https://, ftp://. But without the '://' part. (ignore the space between the two slashes, it's required because of a bug in UE2)

string query
  the part after the ?, without the leading ?

string username
  username that was provided in the URL

## Functions

int AdvSplit(string input, string delim, out array<string> elm, optional string quoteChar )
  Split a string with quotes, quotes may appear anywhere in the string, escape the quote char with a \ to use a literal.
  Qoutes are removed from the result, and escaped quotes are used as normal quotes.

array<string> Base64Decode(array<string> indata )
  Decode a base64 encoded string

array<string> Base64Encode(array<string> indata, out array<string> B64Lookup )
  base64 encode an input array

Base64EncodeLookupTable(out array<string> LookupTable )
  Generate the base 64 encode lookup table

string basename(string filename )
  get the base filename

int daysInYear(int year )
  returns the number of days in a year

string DecToHex(int dec, int size )
  convert a decimal to hexadecimal notation

string dirname(string filename )
  get the dirname of a filename, with traling slash

int getPortByProtocol(string protocol )
  return the default port based on the protocol

int HexToDec(string hexcode )
  convert a hexadecimal number to the integer counterpart

string HTTPResponseCode(int code )
  return the description of a HTTP response code

bool isLeapYear(int year )
  returns if year is a leap year

int leapsThruEndOf(int y )

Logf(name Comp, coerce string message, optional int level, optional coerce string Param1, optional coerce string Param2 )
  Write a log entry

MD5Decode(out array<int> output, array<byte> input, int len )
MD5Encode(out array<byte> output, array<int> input, int len )
MD5Final(out array<byte> digest, out MD5_CTX context )
  finalize the MD5 context

MD5Init(out MD5_CTX context )
  initialize the MD5 context

MD5Move(string src, int srcindex, out array<byte> buffer, int bufindex, int len )
string MD5String(string str )
  return the MD5 of the input string

string MD5StringArray(array<string> stra, optional string Concat )
  Return the MD5 of the input string array. Concat is added after each line.

MD5Transform(out array<int> Buf, array<byte> block )
MD5Update(out MD5_CTX Context, string Data, int inputLen )
  update MD5 context

bool parseUrl(string inURL, out xURL outURL )
  parses the inURL to an xURL structure, return true when succesful

string RawUrlDecode(string instring, optional bool bIgnorePlus )
  This will decode URL encoded elements. If bIgnorePlus is set to true '+' will not be changed to a space

string RawUrlEncode(string instring )
  Encode special characters, you should not use this function, it's slow and not secure, so try to avoid it.
  This is replace the following characters: ";", "/", "?", ":", "@", "&", "=", "+", ",", "$" and " "

ReplaceChar(out string instring, string from, string to )
  replace part of a string

int ROTATE_LEFT(int x, int n )
int stringToTimestamp(string datestring, optional int TZoffset )
  Parse a string to a timestamp

The date string is formatted as: Wdy, DD-Mon-YYYY HH:MM:SS GMT
TZoffset is the local offset to GMT

int timestamp(int year, int mon, int day, int hour, int min, int sec )
  Create a UNIX timestamp.
  Warning: Assumes info is passed in GMT. So make sure you correct the timezone if you are going to send a timestamp generated with this function to an other server.

DateTime timestampToDatetime(int timestamp )
  converts a timestamp to a DateTime record

string timestampToString(int timestamp, optional string Timezone, optional string format )
  convert a timestamp into a string.
  Format can be one of the following strings:
  "822", "1123" : RFC 822, updated by RFC 1123 (default), timezone is the TZ CODE
  "850", "1036" : RFC 850, obsoleted by RFC 1036, timezone is the TZ CODE
  "2822" : RFC 2822, timezone is a +0000 like string
  "asctime": ANSI C's asctime() format, timezone is an integer that will increment the hour

string Trim(coerce string S )
  Trim leading and trailing spaces

float TZtoOffset(string TZ )
  Converts a timezone code to an offset.

string xURLtoLocation(xURL inURL, optional bool bIncludePassword )
  convert a xURL to a location string, just the location+query+hash

string xURLtoString(xURL inURL, optional bool bIncludePassword )
  converts a xURL to a string. bIncludePassword defaults to false

Category: Legacy Custom Class (UT2004)

##### Views

- Legacy
- Discussion
- Current revision

##### Search