Core.Object | +--UWeb.WebResponse
WebConnection
Connection
string
IncludePath
int
ReplacementMap[5]
bool
bSentResponse
bSentText
void
ClearSubst()
FailAuthentication(string Realm)
HTTPError(int ErrorNum, optional string)
HTTPHeader(string Header)
HTTPResponse(string Header)
IncludeBinaryFile(string Filename)
IncludeUHTM(string Filename)
Redirect(string URL)
SendStandardHeaders(optional string)
Subst(string Variable, string Value, optional bool)
// uhtm including
00001 class WebResponse expands Object 00002 native 00003 noexport; 00004 00005 var private native const int ReplacementMap[5]; // TMap<FString, FString>! 00006 var const config string IncludePath; 00007 var WebConnection Connection; 00008 var bool bSentText; // used to warn headers already sent 00009 var bool bSentResponse; 00010 00011 // uhtm including 00012 native final function Subst(string Variable, string Value, optional bool bClear); 00013 native final function ClearSubst(); 00014 native final function IncludeUHTM(string Filename); 00015 native final function IncludeBinaryFile(string Filename); 00016 00017 event SendText(string Text, optional bool bNoCRLF) 00018 { 00019 if(!bSentText) 00020 { 00021 SendStandardHeaders(); 00022 bSentText = True; 00023 } 00024 00025 if(bNoCRLF) 00026 Connection.SendText(Text); 00027 else 00028 Connection.SendText(Text$Chr(13)$Chr(10)); 00029 } 00030 00031 event SendBinary(int Count, byte B[255]) 00032 { 00033 Connection.SendBinary(Count, B); 00034 } 00035 00036 function FailAuthentication(string Realm) 00037 { 00038 HTTPError(401, Realm); 00039 } 00040 00041 function HTTPResponse(string Header) 00042 { 00043 HTTPHeader(Header); 00044 bSentResponse = True; 00045 } 00046 00047 function HTTPHeader(string Header) 00048 { 00049 if(bSentText) 00050 Log("Can't send headers - already called SendText()"); 00051 00052 Connection.SendText(Header$Chr(13)$Chr(10)); 00053 } 00054 00055 function HTTPError(int ErrorNum, optional string Data) 00056 { 00057 switch(ErrorNum) 00058 { 00059 case 400: 00060 HTTPResponse("HTTP/1.1 400 Bad Request"); 00061 SendText("<TITLE>400 Bad Request</TITLE><H1>400 Bad Request</H1>If you got this error from a standard web browser, please mail jack@epicgames.com and submit a bug report."); 00062 break; 00063 case 401: 00064 HTTPResponse("HTTP/1.1 401 Unauthorized"); 00065 HTTPHeader("WWW-authenticate: basic realm=\""$Data$"\""); 00066 SendText("<TITLE>401 Unauthorized</TITLE><H1>401 Unauthorized</H1>"); 00067 break; 00068 case 404: 00069 HTTPResponse("HTTP/1.1 404 Object Not Found"); 00070 SendText("<TITLE>404 File Not Found</TITLE><H1>404 File Not Found</H1>The URL you requested was not found."); 00071 break; 00072 default: 00073 break; 00074 } 00075 } 00076 00077 function SendStandardHeaders( optional string ContentType ) 00078 { 00079 if(ContentType == "") 00080 ContentType = "text/html"; 00081 if(!bSentResponse) 00082 HTTPResponse("HTTP/1.1 200 OK"); 00083 HTTPHeader("Server: UnrealEngine UWeb Web Server Build "$Connection.Level.EngineVersion); 00084 HTTPHeader("Content-Type: "$ContentType); 00085 HTTPHeader(""); 00086 } 00087 00088 function Redirect(string URL) 00089 { 00090 HTTPResponse("HTTP/1.1 302 Document Moved"); 00091 HTTPHeader("Location: "$URL); 00092 SendText("<head><title>Document Moved</title></head>"); 00093 SendText("<body><h1>Object Moved</h1>This document may be found <a HREF=\""$URL$"\">here</a>."); 00094 } 00095 00096 defaultproperties 00097 { 00098 IncludePath="../Web" 00099 }