## UWeb
Class WebRequest

source: C:\XIII\UWeb\Classes\WebRequest.uc

    Core.Object
       |
       +--UWeb.WebRequest

Direct Known Subclasses:None

class WebRequest
extends Core.Object

Variables
`int` | `ContentLength`
`string` | `ContentType`
`string` | `Password`
`ERequestType` | `RequestType`
`string` | `URI`
`string` | `Username`
`int` | `VariableMap[5]` TMultiMap!

Function Summary
`void` | `AddVariable(string VariableName, string Value)`
`string` | `DecodeBase64(string Encoded)`
`void` | `DecodeFormData(string Data)`
`int` | `GetHexDigit(string D)`
`string` | `GetVariable(string VariableName, optional string)`
`int` | `GetVariableCount(string VariableName)`
`string` | `GetVariableNumber(string VariableName, int Number, optional string)`
`void` | `ProcessHeaderString(string S)`

Source Code

    00001	class WebRequest extends Object
    00002		native
    00003		noexport;
    00004
    00005	enum ERequestType
    00006	{
    00007		Request_GET,
    00008		Request_POST
    00009	};
    00010
    00011	var string URI;
    00012	var string Username;
    00013	var string Password;
    00014	var int ContentLength;
    00015	var string ContentType;
    00016	var ERequestType RequestType;
    00017	var private native const int VariableMap[5];	// TMultiMap<FString, FString>!
    00018
    00019	native final function string DecodeBase64(string Encoded);
    00020	native final function AddVariable(string VariableName, string Value);
    00021	native final function string GetVariable(string VariableName, optional string DefaultValue);
    00022	native final function int GetVariableCount(string VariableName);
    00023	native final function string GetVariableNumber(string VariableName, int Number, optional string DefaultValue);
    00024
    00025	function ProcessHeaderString(string S)
    00026	{
    00027		local int i;
    00028
    00029		if(Left(S, 21) ~= "Authorization: Basic ")
    00030		{
    00031			S = DecodeBase64(Mid(S, 21));
    00032			i = InStr(S, ":");
    00033			if(i != -1)
    00034			{
    00035				Username = Left(S, i);
    00036				Password = Mid(S, i+1);
    00037			}
    00038		}
    00039		else
    00040		if(Left(S, 16) ~= "Content-Length: ")
    00041			ContentLength = Int(Mid(S, 16));
    00042		else
    00043		if(Left(S, 14) ~= "Content-Type: ")
    00044			ContentType = Mid(S, 14);
    00045	}
    00046
    00047	function DecodeFormData(string Data)
    00048	{
    00049		local string Token[2], ch;
    00050		local int i;
    00051		local int t;
    00052
    00053		t = 0;
    00054		for(i=0;i<Len(Data);i++)
    00055		{
    00056			ch = mid(Data, i, 1);
    00057			switch(ch)
    00058			{
    00059			case "+":
    00060				Token[t] = Token[t]$" ";
    00061				break;
    00062			case "&":
    00063			case "?":
    00064				if(Token[0] != "")
    00065					AddVariable(Token[0], Token[1]);
    00066				Token[0] = "";
    00067				Token[1] = "";
    00068				t = 0;
    00069				break;
    00070			case "=":
    00071				if(t == 0)
    00072					t = 1;
    00073				else
    00074					Token[t] = Token[t]$"=";
    00075				break;
    00076			case "%":
    00077				Token[t] = Token[t]$Chr(16 * GetHexDigit(mid(Data, ++i, 1)) + GetHexDigit(mid(Data, ++i, 1)));
    00078				break;
    00079			default:
    00080				Token[t] = Token[t]$ch;
    00081			}
    00082		}
    00083
    00084		if(Token[0] != "")
    00085			AddVariable(Token[0], Token[1]);
    00086	}
    00087
    00088	function int GetHexDigit(string D)
    00089	{
    00090		switch(caps(D))
    00091		{
    00092		case "0": return 0;
    00093		case "1": return 1;
    00094		case "2": return 2;
    00095		case "3": return 3;
    00096		case "4": return 4;
    00097		case "5": return 5;
    00098		case "6": return 6;
    00099		case "7": return 7;
    00100		case "8": return 8;
    00101		case "9": return 9;
    00102		case "A": return 10;
    00103		case "B": return 11;
    00104		case "C": return 12;
    00105		case "D": return 13;
    00106		case "E": return 14;
    00107		case "F": return 15;
    00108		}
    00109
    00110		return 0;
    00111	}
    00112	defaultproperties
    00113	{
    00114	    SendText=
    00115	}

End Source Code