Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

UWeb.WebRequest


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
class WebRequest extends Object
	native
	noexport;

enum ERequestType
{
	Request_GET,
	Request_POST
};

var string URI;
var string Username;
var string Password;
var int ContentLength;
var string ContentType;
var ERequestType RequestType;
var private native const int VariableMap[5];	// TMultiMap<FString, FString>!

native final function string DecodeBase64(string Encoded);
native final function AddVariable(string VariableName, string Value);
native final function string GetVariable(string VariableName, optional string DefaultValue);
native final function int GetVariableCount(string VariableName);
native final function string GetVariableNumber(string VariableName, int Number, optional string DefaultValue);

function ProcessHeaderString(string S)
{
	local int i;

	if(Left(S, 21) ~= "Authorization: Basic ")
	{
		S = DecodeBase64(Mid(S, 21));
		i = InStr(S, ":");
		if(i != -1)
		{
			Username = Left(S, i);
			Password = Mid(S, i+1);
		}
	}
	else
	if(Left(S, 16) ~= "Content-Length: ")
		ContentLength = Int(Mid(S, 16));
	else
	if(Left(S, 14) ~= "Content-Type: ")
		ContentType = Mid(S, 14);
}

function DecodeFormData(string Data)
{
	local string Token[2], ch;
	local int i;
	local int t;

	t = 0;
	for(i=0;i<Len(Data);i++)
	{
		ch = mid(Data, i, 1);
		switch(ch)
		{
		case "+":
			Token[t] = Token[t]$" ";
			break;
		case "&":
		case "?":
			if(Token[0] != "")
				AddVariable(Token[0], Token[1]);			
			Token[0] = "";
			Token[1] = "";
			t = 0;
			break;
		case "=":
			if(t == 0)
				t = 1;
			else
				Token[t] = Token[t]$"=";
			break;
		case "%":
			Token[t] = Token[t]$Chr(16 * GetHexDigit(mid(Data, ++i, 1)) + GetHexDigit(mid(Data, ++i, 1)));
			break;
		default:
			Token[t] = Token[t]$ch;
		}
	}

	if(Token[0] != "")
		AddVariable(Token[0], Token[1]);
}

function int GetHexDigit(string D)
{
	switch(caps(D))
	{
	case "0": return 0;
	case "1": return 1;
	case "2": return 2;
	case "3": return 3;
	case "4": return 4;
	case "5": return 5; 
	case "6": return 6; 
	case "7": return 7; 
	case "8": return 8; 
	case "9": return 9; 
	case "A": return 10; 
	case "B": return 11; 
	case "C": return 12; 
	case "D": return 13; 
	case "E": return 14; 
	case "F": return 15; 
	}

	return 0;
}

defaultproperties
{
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: sk 3-1-2016 10:38:40.000 - Creation time: sk 3-1-2016 10:48:44.059 - Created with UnCodeX