httpObject.cpp

Engine/source/app/net/httpObject.cpp

More...

Public Functions

ConsoleDocClass(HTTPObject , "@brief Allows communications between the game and <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> server using <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">HTTP.\n\n</a>" "<a href="/coding/class/classhttpobject/">HTTPObject</a> is derrived from <a href="/coding/class/classtcpobject/">TCPObject</a> and makes use of the same callbacks <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> dealing with " "connections and received data. However, the way in which you use <a href="/coding/class/classhttpobject/">HTTPObject</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> connect " "with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> server is different than TCPObject. Rather than opening <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> connection, sending data, " "waiting <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> receive data, and then closing the connection, you issue <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> get() or post() and " "handle the response. The connection is automatically created and destroyed <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">you.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//In this example we 'll retrieve the weather in Las Vegas <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">using\n</a>" "//Google 's API. The response is in XML which could be <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">processed\n</a>" "//and used by the game using SimXMLDocument, but we 'll just <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">output\n</a>" "//the results <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the console in this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">example.\n\n</a>" "//Define callbacks <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> our specific <a href="/coding/class/classhttpobject/">HTTPObject</a> using our instance '<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">s\n</a>" "//name(WeatherFeed) as the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">namespace.\n\n</a>" "//Handle an issue with resolving the server 's <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">name\n</a>" "function WeatherFeed::onDNSFailed(%this)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//Store this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">state\n</a>" " %this.lastState=\"DNSFailed\";\n\n" "   // Handle DNS <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">failure\n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "function WeatherFeed::onConnectFailed(%this)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   // Store this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">state\n</a>" "   %this.lastState = \"ConnectFailed\";\n\n" "   // Handle connection <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">failure\n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "function WeatherFeed::onDNSResolved(%this)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   // Store this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">state\n</a>" "   %this.lastState = \"DNSResolved\";\n\n" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "function WeatherFeed::onConnected(%this)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   // Store this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">state\n</a>" "   %this.lastState = \"Connected\";\n\n" "   // Clear our <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">buffer\n</a>" "   %this.buffer = \"\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "function WeatherFeed::onDisconnect(%this)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   // Store this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">state\n</a>" "   %this.lastState = \"Disconnected\";\n\n" "   // Output the buffer <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">console\n</a>" "   <a href="/coding/file/ggendoflinefix_8txt/#ggendoflinefix_8txt_1a7f8fee038817022b75b8865e5da4eba3">echo</a>(\"Google Weather Results:\");\n" "   <a href="/coding/file/ggendoflinefix_8txt/#ggendoflinefix_8txt_1a7f8fee038817022b75b8865e5da4eba3">echo</a>(%this.buffer);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "// Handle <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> line from the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">server\n</a>" "function WeatherFeed::onLine(%this, %line)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   // Store this line in out <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">buffer\n</a>" "   %this.buffer = %this.buffer @ %line;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "// Create the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">HTTPObject\n</a>" "% feed)
DefineEngineMethod(HTTPObject , get , void , (const char *Address, const char *requirstURI, const char *query) , ("") , "@brief Send <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> GET command <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> server <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> send or retrieve <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">data.\n\n</a>" "@param Address HTTP web address <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> send this get call to. Be sure <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> include the port at the end (IE: \"www.garagegames.com:80\").\n" "@param requirstURI Specific location on the server <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> access (IE: \"index.php\".)\n" "@param query Optional. Actual data <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> transmit <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the server. Can be anything <a href="/coding/file/tsshapeconstruct_8cpp/#tsshapeconstruct_8cpp_1a21625ca11566389388a748ad1acc0990">required</a> providing it sticks with limitations of the HTTP protocol. " "If you were building the URL manually, this is the text that follows the question mark. For example:http://www.google.com/ig/api?< <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> > weather, US</<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//Create an HTTP object <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">communications\n</a>" "% httpObj)
DefineEngineMethod(HTTPObject , post , void , (const char *Address, const char *requirstURI, const char *query, const char *post) , "@brief Send POST command <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> server <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> send or retrieve <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">data.\n\n</a>" "@param Address HTTP web address <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> send this get call to. Be sure <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> include the port at the end (IE: \"www.garagegames.com:80\").\n" "@param requirstURI Specific location on the server <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> access (IE: \"index.php\".)\n" "@param query Actual data <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> transmit <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the server. Can be anything <a href="/coding/file/tsshapeconstruct_8cpp/#tsshapeconstruct_8cpp_1a21625ca11566389388a748ad1acc0990">required</a> providing it sticks with limitations of the HTTP protocol. \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@param post Submission data <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> be <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">processed.\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "// Create an HTTP object <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">communications\n</a>" "% httpObj)
char
getHex(char c)
getHexVal(char c)

Detailed Description

Public Functions

ConsoleDocClass(HTTPObject , "@brief Allows communications between the game and <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> server using <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">HTTP.\n\n</a>" "<a href="/coding/class/classhttpobject/">HTTPObject</a> is derrived from <a href="/coding/class/classtcpobject/">TCPObject</a> and makes use of the same callbacks <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> dealing with " "connections and received data. However, the way in which you use <a href="/coding/class/classhttpobject/">HTTPObject</a> <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> connect " "with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> server is different than TCPObject. Rather than opening <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> connection, sending data, " "waiting <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> receive data, and then closing the connection, you issue <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> get() or post() and " "handle the response. The connection is automatically created and destroyed <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">you.\n\n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//In this example we 'll retrieve the weather in Las Vegas <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">using\n</a>" "//Google 's API. The response is in XML which could be <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">processed\n</a>" "//and used by the game using SimXMLDocument, but we 'll just <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">output\n</a>" "//the results <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the console in this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">example.\n\n</a>" "//Define callbacks <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> our specific <a href="/coding/class/classhttpobject/">HTTPObject</a> using our instance '<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">s\n</a>" "//name(WeatherFeed) as the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">namespace.\n\n</a>" "//Handle an issue with resolving the server 's <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">name\n</a>" "function WeatherFeed::onDNSFailed(%this)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "//Store this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">state\n</a>" " %this.lastState=\"DNSFailed\";\n\n" "   // Handle DNS <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">failure\n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "function WeatherFeed::onConnectFailed(%this)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   // Store this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">state\n</a>" "   %this.lastState = \"ConnectFailed\";\n\n" "   // Handle connection <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">failure\n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "function WeatherFeed::onDNSResolved(%this)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   // Store this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">state\n</a>" "   %this.lastState = \"DNSResolved\";\n\n" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "function WeatherFeed::onConnected(%this)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   // Store this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">state\n</a>" "   %this.lastState = \"Connected\";\n\n" "   // Clear our <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">buffer\n</a>" "   %this.buffer = \"\";\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "function WeatherFeed::onDisconnect(%this)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   // Store this <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">state\n</a>" "   %this.lastState = \"Disconnected\";\n\n" "   // Output the buffer <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">console\n</a>" "   <a href="/coding/file/ggendoflinefix_8txt/#ggendoflinefix_8txt_1a7f8fee038817022b75b8865e5da4eba3">echo</a>(\"Google Weather Results:\");\n" "   <a href="/coding/file/ggendoflinefix_8txt/#ggendoflinefix_8txt_1a7f8fee038817022b75b8865e5da4eba3">echo</a>(%this.buffer);\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "// Handle <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> line from the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">server\n</a>" "function WeatherFeed::onLine(%this, %line)\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "{\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "   // Store this line in out <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">buffer\n</a>" "   %this.buffer = %this.buffer @ %line;\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "}\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "// Create the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">HTTPObject\n</a>" "% feed)

DefineEngineMethod(HTTPObject , get , void , (const char *Address, const char *requirstURI, const char *query) , ("") , "@brief Send <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> GET command <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> server <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> send or retrieve <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">data.\n\n</a>" "@param Address HTTP web address <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> send this get call to. Be sure <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> include the port at the end (IE: \"www.garagegames.com:80\").\n" "@param requirstURI Specific location on the server <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> access (IE: \"index.php\".)\n" "@param query Optional. Actual data <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> transmit <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the server. Can be anything <a href="/coding/file/tsshapeconstruct_8cpp/#tsshapeconstruct_8cpp_1a21625ca11566389388a748ad1acc0990">required</a> providing it sticks with limitations of the HTTP protocol. " "If you were building the URL manually, this is the text that follows the question mark. For example:http://www.google.com/ig/api?< <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> > weather, US</<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a91b64995742fd30063314f12340b4b5a">b</a> >\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" " @<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "//Create an HTTP object <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">communications\n</a>" "% httpObj)

DefineEngineMethod(HTTPObject , post , void , (const char *Address, const char *requirstURI, const char *query, const char *post) , "@brief Send POST command <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> server <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> send or retrieve <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">data.\n\n</a>" "@param Address HTTP web address <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> send this get call to. Be sure <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> include the port at the end (IE: \"www.garagegames.com:80\").\n" "@param requirstURI Specific location on the server <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> access (IE: \"index.php\".)\n" "@param query Actual data <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> transmit <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the server. Can be anything <a href="/coding/file/tsshapeconstruct_8cpp/#tsshapeconstruct_8cpp_1a21625ca11566389388a748ad1acc0990">required</a> providing it sticks with limitations of the HTTP protocol. \<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n</a>" "@param post Submission data <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> be <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">processed.\n</a>" "@<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">tsexample\n</a>" "// Create an HTTP object <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">communications\n</a>" "% httpObj)

getHex(char c)

getHexVal(char c)

IMPLEMENT_CONOBJECT(HTTPObject )

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#include "app/net/httpObject.h"
 25
 26#include "platform/platform.h"
 27#include "core/stream/fileStream.h"
 28#include "console/simBase.h"
 29#include "console/consoleInternal.h"
 30#include "console/engineAPI.h"
 31
 32IMPLEMENT_CONOBJECT(HTTPObject);
 33
 34ConsoleDocClass( HTTPObject,
 35   "@brief Allows communications between the game and a server using HTTP.\n\n"
 36   
 37   "HTTPObject is derrived from TCPObject and makes use of the same callbacks for dealing with "
 38   "connections and received data.  However, the way in which you use HTTPObject to connect "
 39   "with a server is different than TCPObject.  Rather than opening a connection, sending data, "
 40   "waiting to receive data, and then closing the connection, you issue a get() or post() and "
 41   "handle the response.  The connection is automatically created and destroyed for you.\n\n"
 42   
 43   "@tsexample\n"
 44      "// In this example we'll retrieve the weather in Las Vegas using\n"
 45      "// Google's API.  The response is in XML which could be processed\n"
 46      "// and used by the game using SimXMLDocument, but we'll just output\n"
 47      "// the results to the console in this example.\n\n"
 48
 49      "// Define callbacks for our specific HTTPObject using our instance's\n"
 50      "// name (WeatherFeed) as the namespace.\n\n"
 51
 52      "// Handle an issue with resolving the server's name\n"
 53      "function WeatherFeed::onDNSFailed(%this)\n"
 54      "{\n"
 55      "   // Store this state\n"
 56      "   %this.lastState = \"DNSFailed\";\n\n"
 57
 58      "   // Handle DNS failure\n"
 59      "}\n\n"
 60
 61      "function WeatherFeed::onConnectFailed(%this)\n"
 62      "{\n"
 63      "   // Store this state\n"
 64      "   %this.lastState = \"ConnectFailed\";\n\n"
 65      "   // Handle connection failure\n"
 66      "}\n\n"
 67
 68      "function WeatherFeed::onDNSResolved(%this)\n"
 69      "{\n"
 70      "   // Store this state\n"
 71      "   %this.lastState = \"DNSResolved\";\n\n"
 72      "}\n\n"
 73
 74      "function WeatherFeed::onConnected(%this)\n"
 75      "{\n"
 76      "   // Store this state\n"
 77      "   %this.lastState = \"Connected\";\n\n"
 78
 79      "   // Clear our buffer\n"
 80      "   %this.buffer = \"\";\n"
 81      "}\n\n"
 82
 83      "function WeatherFeed::onDisconnect(%this)\n"
 84      "{\n"
 85      "   // Store this state\n"
 86      "   %this.lastState = \"Disconnected\";\n\n"
 87
 88      "   // Output the buffer to the console\n"
 89      "   echo(\"Google Weather Results:\");\n"
 90      "   echo(%this.buffer);\n"
 91      "}\n\n"
 92
 93      "// Handle a line from the server\n"
 94      "function WeatherFeed::onLine(%this, %line)\n"
 95      "{\n"
 96      "   // Store this line in out buffer\n"
 97      "   %this.buffer = %this.buffer @ %line;\n"
 98      "}\n\n"
 99
100      "// Create the HTTPObject\n"
101      "%feed = new HTTPObject(WeatherFeed);\n\n"
102
103      "// Define a dynamic field to store the last connection state\n"
104      "%feed.lastState = \"None\";\n\n"
105
106      "// Send the GET command\n"
107      "%feed.get(\"www.google.com:80\", \"/ig/api\", \"weather=Las-Vegas,US\");\n"
108   "@endtsexample\n\n" 
109   
110   "@see TCPObject\n"
111
112   "@ingroup Networking\n"
113);
114
115//--------------------------------------
116
117HTTPObject::HTTPObject()
118   : mParseState(ParsingStatusLine),
119   mTotalBytes(0),
120   mBytesRemaining(0),
121   mStatus(0),
122   mVersion(0.0f),
123   mContentLength(0),
124   mChunkedEncoding(false),
125   mChunkSize(0),
126   mContentType(""),
127   mHostName(NULL),
128   mPath(NULL),
129   mQuery(NULL),
130   mPost(NULL),
131   mBufferSave(NULL),
132   mBufferSaveSize(0)
133{
134}
135
136HTTPObject::~HTTPObject()
137{
138   dFree(mHostName);
139   dFree(mPath);
140   dFree(mQuery);
141   dFree(mPost);
142
143   mHostName = 0;
144   mPath = 0;
145   mQuery = 0;
146   mPost = 0;
147   dFree(mBufferSave);
148}
149
150//--------------------------------------
151//--------------------------------------
152void HTTPObject::get(const char *host, const char *path, const char *query)
153{
154   if(mHostName)
155      dFree(mHostName);
156   if(mPath)
157      dFree(mPath);
158   if(mQuery)
159      dFree(mQuery);
160   if(mPost)
161      dFree(mPost);
162   if(mBufferSave)
163      dFree(mBufferSave);
164
165   mBufferSave = 0;
166   mHostName = dStrdup(host);
167   mPath = dStrdup(path);
168   if(query)
169      mQuery = dStrdup(query);
170   else
171      mQuery = NULL;
172   mPost = NULL;
173
174   connect(host);
175}
176
177void HTTPObject::post(const char *host, const char *path, const char *query, const char *post)
178{
179   if(mHostName)
180      dFree(mHostName);
181   if(mPath)
182      dFree(mPath);
183   if(mQuery)
184      dFree(mQuery);
185   if(mPost)
186      dFree(mPost);
187   if(mBufferSave)
188      dFree(mBufferSave);
189
190   mBufferSave = 0;
191   mHostName = dStrdup(host);
192   mPath = dStrdup(path);
193   if(query && query[0])
194      mQuery = dStrdup(query);
195   else
196      mQuery = NULL;
197   mPost = dStrdup(post);
198   connect(host);
199}
200
201static char getHex(char c)
202{
203   if(c <= 9)
204      return c + '0';
205   return c - 10 + 'A';
206}
207
208static S32 getHexVal(char c)
209{
210   if(c >= '0' && c <= '9')
211      return c - '0';
212   else if(c >= 'A' && c <= 'Z')
213      return c - 'A' + 10;
214   else if(c >= 'a' && c <= 'z')
215      return c - 'a' + 10;
216   return -1;
217}
218
219void HTTPObject::expandPath(char *dest, const char *path, U32 destSize)
220{
221   static bool asciiEscapeTableBuilt = false;
222   static bool asciiEscapeTable[256];
223   if(!asciiEscapeTableBuilt)
224   {
225      asciiEscapeTableBuilt = true;
226      U32 i;
227      for(i = 0; i <= ' '; i++)
228         asciiEscapeTable[i] = true;
229      for(;i <= 0x7F; i++)
230         asciiEscapeTable[i] = false;
231      for(;i <= 0xFF; i++)
232         asciiEscapeTable[i] = true;
233      asciiEscapeTable[static_cast<U32>('\"')] = true;
234      asciiEscapeTable[static_cast<U32>('_')] = true;
235      asciiEscapeTable[static_cast<U32>('\'')] = true;
236      asciiEscapeTable[static_cast<U32>('#')] = true;
237      asciiEscapeTable[static_cast<U32>('$')] = true;
238      asciiEscapeTable[static_cast<U32>('%')] = true;
239      asciiEscapeTable[static_cast<U32>('&')] = false;
240      asciiEscapeTable[static_cast<U32>('+')] = true;
241      asciiEscapeTable[static_cast<U32>('-')] = true;
242      asciiEscapeTable[static_cast<U32>('~')] = true;
243   }
244
245   U32 destIndex = 0;
246   U32 srcIndex = 0;
247   while(path[srcIndex] && destIndex < destSize - 3)
248   {
249      char c = path[srcIndex++];
250      if(asciiEscapeTable[static_cast<U32>(c)])
251      {
252         dest[destIndex++] = '%';
253         dest[destIndex++] = getHex((c >> 4) & 0xF);
254         dest[destIndex++] = getHex(c & 0xF);
255      }
256      else
257         dest[destIndex++] = c;
258   }
259   dest[destIndex] = 0;
260}
261
262//--------------------------------------
263void HTTPObject::onConnected()
264{
265   Parent::onConnected();
266   char expPath[8192];
267   char buffer[8192];
268
269   if(mQuery)
270   {
271      dSprintf(buffer, sizeof(buffer), "%s?%s", mPath, mQuery);
272      expandPath(expPath, buffer, sizeof(expPath));
273   }
274   else
275      expandPath(expPath, mPath, sizeof(expPath));
276
277   char *pt = dStrchr(mHostName, ':');
278   if(pt)
279      *pt = 0;
280
281   //If we want to do a get request
282   if(mPost == NULL)
283   {
284      dSprintf(buffer, sizeof(buffer), "GET %s HTTP/1.1\r\nHost: %s\r\n\r\n", expPath, mHostName);
285   }
286   //Else we want to do a post request
287   else
288   {
289      dSprintf(buffer, sizeof(buffer), "POST %s HTTP/1.1\r\nHost: %s\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: %i\r\n\r\n%s\r\n\r\n",
290         expPath, mHostName, dStrlen(mPost), mPost);
291   }
292
293   if(pt)
294      *pt = ':';
295
296   send((U8*)buffer, dStrlen(buffer));
297   mParseState = ParsingStatusLine;
298   mChunkedEncoding = false;
299}
300
301void HTTPObject::onConnectFailed()
302{
303   dFree(mHostName);
304   dFree(mPath);
305   dFree(mQuery);
306   mHostName = 0;
307   mPath = 0;
308   mQuery = 0;
309   Parent::onConnectFailed();
310}
311
312
313void HTTPObject::onDisconnect()
314{
315   dFree(mHostName);
316   dFree(mPath);
317   dFree(mQuery);
318   mHostName = 0;
319   mPath = 0;
320   mQuery = 0;
321   Parent::onDisconnect();
322}
323
324bool HTTPObject::processLine(UTF8 *line)
325{
326   if(mParseState == ParsingStatusLine)
327   {
328      mParseState = ParsingHeader;
329   }
330   else if(mParseState == ParsingHeader)
331   {
332      if(!dStricmp((char *) line, "transfer-encoding: chunked"))
333         mChunkedEncoding = true;
334      if(line[0] == 0)
335      {
336         if(mChunkedEncoding)
337            mParseState = ParsingChunkHeader;
338         else
339            mParseState = ProcessingBody;
340         return true;
341      }
342   }
343   else if(mParseState == ParsingChunkHeader)
344   {
345      if(line[0]) // strip off the crlf if necessary
346      {
347         mChunkSize = 0;
348         S32 hexVal;
349         while((hexVal = getHexVal(*line++)) != -1)
350         {
351            mChunkSize *= 16;
352            mChunkSize += hexVal;
353         }
354         if(mBufferSave)
355         {
356            mBuffer = mBufferSave;
357            mBufferSize = mBufferSaveSize;
358            mBufferSave = 0;
359         }
360         if(mChunkSize)
361            mParseState = ProcessingBody;
362         else
363         {
364            mParseState = ProcessingDone;
365            finishLastLine();
366         }
367      }
368   }
369   else
370   {
371      return Parent::processLine((UTF8*)line);
372   }
373   return true;
374}
375
376U32 HTTPObject::onDataReceive(U8 *buffer, U32 bufferLen)
377{
378   U32 start = 0;
379   parseLine(buffer, &start, bufferLen);
380   return start;
381}
382
383//--------------------------------------
384U32 HTTPObject::onReceive(U8 *buffer, U32 bufferLen)
385{
386   if(mParseState == ProcessingBody)
387   {
388      if(mChunkedEncoding && bufferLen >= mChunkSize)
389      {
390         U32 ret = onDataReceive(buffer, mChunkSize);
391         mChunkSize -= ret;
392         if(mChunkSize == 0)
393         {
394            if(mBuffer)
395            {
396               mBufferSaveSize = mBufferSize;
397               mBufferSave = mBuffer;
398               mBuffer = 0;
399               mBufferSize = 0;
400            }
401            mParseState = ParsingChunkHeader;
402         }
403         return ret;
404      }
405      else
406      {
407         U32 ret = onDataReceive(buffer, bufferLen);
408         mChunkSize -= ret;
409         return ret;
410      }
411   }
412   else if(mParseState != ProcessingDone)
413   {
414      U32 start = 0;
415      parseLine(buffer, &start, bufferLen);
416      return start;
417   }
418   return bufferLen;
419}
420
421//--------------------------------------
422DefineEngineMethod( HTTPObject, get, void, ( const char* Address, const char* requirstURI, const char* query ), ( "" ),
423   "@brief Send a GET command to a server to send or retrieve data.\n\n"
424
425   "@param Address HTTP web address to send this get call to. Be sure to include the port at the end (IE: \"www.garagegames.com:80\").\n"
426   "@param requirstURI Specific location on the server to access (IE: \"index.php\".)\n"
427   "@param query Optional. Actual data to transmit to the server. Can be anything required providing it sticks with limitations of the HTTP protocol. "
428   "If you were building the URL manually, this is the text that follows the question mark.  For example: http://www.google.com/ig/api?<b>weather=Las-Vegas,US</b>\n"
429   
430   "@tsexample\n"
431      "// Create an HTTP object for communications\n"
432      "%httpObj = new HTTPObject();\n\n"
433      "// Specify a URL to transmit to\n"
434      "%url = \"www.garagegames.com:80\";\n\n"
435      "// Specify a URI to communicate with\n"
436      "%URI = \"/index.php\";\n\n"
437      "// Specify a query to send.\n"
438      "%query = \"\";\n\n"
439      "// Send the GET command to the server\n"
440      "%httpObj.get(%url,%URI,%query);\n"
441   "@endtsexample\n\n"
442   )
443{
444   if( !query || !query[ 0 ] )
445      object->get(Address, requirstURI, NULL);
446   else
447      object->get(Address, requirstURI, query);
448}
449
450DefineEngineMethod( HTTPObject, post, void, ( const char* Address, const char* requirstURI, const char* query, const char* post ),,
451   "@brief Send POST command to a server to send or retrieve data.\n\n"
452
453   "@param Address HTTP web address to send this get call to. Be sure to include the port at the end (IE: \"www.garagegames.com:80\").\n"
454   "@param requirstURI Specific location on the server to access (IE: \"index.php\".)\n"
455   "@param query Actual data to transmit to the server. Can be anything required providing it sticks with limitations of the HTTP protocol. \n"
456   "@param post Submission data to be processed.\n"
457
458   "@tsexample\n"
459      "// Create an HTTP object for communications\n"
460      "%httpObj = new HTTPObject();\n\n"
461      "// Specify a URL to transmit to\n"
462      "%url = \"www.garagegames.com:80\";\n\n"
463      "// Specify a URI to communicate with\n"
464      "%URI = \"/index.php\";\n\n"
465      "// Specify a query to send.\n"
466      "%query = \"\";\n\n"
467      "// Specify the submission data.\n"
468      "%post = \"\";\n\n"
469      "// Send the POST command to the server\n"
470      "%httpObj.POST(%url,%URI,%query,%post);\n"
471   "@endtsexample\n\n"
472   )
473{
474   object->post(Address, requirstURI, query, post);
475}
476