Game Development Community

Quck fix to make POST / SOAP work properly

by Dan Keller · in Torque 3D Professional · 08/24/2011 (8:39 pm) · 1 replies

The way T3D's HTTPObject is set up
1. POST doesnt work at all
2. SOAP 1.1 doesnt work because there isn't a SOAPAction header
3. Some servers (axis1?) don't work because there isn't a Content-Length header


The fix is very simple. Change around line 220 of httpobject.cpp to
if(pt)
      *pt = 0;
   if (mPost)
      dSprintf(buffer, sizeof(buffer), "POST %s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\nSOAPAction: \"%s%s\"\r\n\r\n%s\r\n\r\n", expPath, mHostName, dStrlen(mPost), mHostName, expPath, mPost);
   else
      dSprintf(buffer, sizeof(buffer), "GET %s HTTP/1.1\r\nHost: %s\r\n\r\n", expPath, mHostName);
   if(pt)
      *pt = ':';

If the server doesn't need the extra headers, it will ignore them, no harm done.

#1
08/25/2011 (1:25 am)
Some servers also don't like there not being any User-Agent specified.

And not having a
"Connection: close\r\n"
header means that Apache if you're using that, keeps the connection alive around based on its KeepAlive setting (which defaults to like 10 or 15 seconds!! ) ...although I noticed you mentioned axis...Adding that header can therefore help speed things up a bit depending on your circumstance (and if it applies in your case) particularly with the disconnects and onDisconnect callbacks (they become useful) and getting data to the onLine calls.

I also found Robert's TCP resource very helpful

Thanks for the info on the SOAPAction