40 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
41 "<html xmlns=\"http://www.w3.org/1999/xhtml\">"
43 "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"/>"
44 "<title>404 - File or directory not found.</title>"
45 "<style type=\"text/css\">"
47 "body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}"
48 "fieldset{padding:0 15px 10px 15px;} "
49 "h1{font-size:2.4em;margin:0;color:#FFF;}"
50 "h2{font-size:1.7em;margin:0;color:#CC0000;} "
51 "h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} "
52 "#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:\"trebuchet MS\", Verdana, sans-serif;color:#FFF;"
53 "background-color:#555555;}"
54 "#content{margin:0 0 0 2%;position:relative;}"
55 ".content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}"
60 "<div id=\"header\"><h1>Server Error</h1></div>"
61 "<div id=\"content\">"
62 " <div class=\"content-container\"><fieldset>"
63 " <h2>404 - File or directory not found.</h2>"
64 " <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>"
92 std::string get_chk_str;
93 std::string post_chk_str;
105 std::getline(stream, request,
'\r');
108 get_chk_str = request.substr(0,3);
109 post_chk_str = request.substr(0,4);
111 if (get_chk_str.compare(
"GET") == 0)
113 sLog.Debug(
"APIServerConnection::ProcessHeaders()",
"RECEIVED new HTTP GET request..." );
120 request = request.substr(4);
123 int del = request.find_first_of(
' ');
124 if (del == std::string::npos)
129 request = request.substr(0,del);
136 request = request.substr(1);
138 pos = request.find_first_of(
'/');
141 request = request.substr(pos+1);
142 pos = request.find_first_of(
'?');
145 request = request.substr(pos+1);
149 while( (pos = request.find_first_of(
'=')) >= 0 )
151 param = request.substr(0,pos);
152 std::transform(param.begin(), param.end(), param.begin(), tolower);
153 request = request.substr(pos+1);
154 pos = request.find_first_of(
'&');
159 value = request.substr(0,pos);
160 request = request.substr(pos);
161 if( request.substr(0,5) ==
"&" )
162 request = request.substr(5);
164 request = request.substr(1);
166 m_apiCommandCall.insert( std::pair<std::string, std::string>( param, value ) );
172 sLog.Error(
"APIServerConnection::ProcessHeaders()",
"Unknown or malformed EVEmu API HTTP CMD Received:\r\n%s\r\n", query.c_str());
179 APICommandCall::const_iterator cur, end;
182 for (
int i=1; cur != end; cur++, i++)
183 sLog.Debug(
" ",
"%d: param = %s, value = %s", i, cur->first.c_str(), cur->second.c_str() );
189 else if (post_chk_str.compare(
"POST") == 0)
191 sLog.Debug(
"APIServerConnection::ProcessHeaders()",
"RECEIVED new HTTP POST request..." );
205 request = request.substr(5);
208 int del = request.find_first_of(
' ');
209 if (del == std::string::npos)
214 request = request.substr(0,del);
221 request = request.substr(1);
223 pos = request.find_first_of(
'/');
226 request = request.substr(pos+1);
231 while( (request.substr( 0,15 ).compare(
"Content-Length:" )) != 0 )
233 std::getline(stream, request,
'\r');
234 request = request.substr(1);
237 pos = request.find_first_of(
' ');
238 request = request.substr( pos+1 );
239 uint32 postDataBytes = atoi( request.c_str() );
240 std::getline(stream, request,
'\n');
242 sLog.Debug(
"APIServerConnection::ProcessHeaders()",
" POST Content-Length = %u bytes", postDataBytes );
245 while( request.compare(
"\r" ) != 0 )
247 std::getline(stream, request,
'\n');
250 std::getline(stream, request,
'\n');
251 pos = request.find_first_of(
'\r');
252 request = request.substr( 0,pos );
254 if( request.compare(
"" ) != 0 )
259 sLog.Debug(
"APIServerConnection::ProcessHeaders()",
"POST data found in ProcessHeaders() ! Parsing..." );
261 while( (pos = request.find_first_of(
'=')) >= 0 )
264 param = request.substr(0,pos);
265 std::transform(param.begin(), param.end(), param.begin(), tolower);
266 request = request.substr(pos+1);
267 pos = request.find_first_of(
'&');
272 value = request.substr(0,pos);
273 request = request.substr(pos);
274 if( request.substr(0,5) ==
"&" )
275 request = request.substr(5);
277 request = request.substr(1);
279 m_apiCommandCall.insert( std::pair<std::string, std::string>( param, value ) );
283 if( parameterCount == 0 )
294 sLog.Error(
"APIServerConnection::ProcessHeaders()",
"Unknown or malformed EVEmu API HTTP CMD Received:\r\n%s\r\n", query.c_str());
301 APICommandCall::const_iterator cur, end;
304 for (
int i=1; cur != end; cur++, i++)
305 sLog.Debug(
" ",
"%d: param = %s, value = %s", i, cur->first.c_str(), cur->second.c_str() );
335 std::getline(stream, request,
'\r');
338 if( request.compare(
"" ) == 0 )
340 sLog.Error(
"APIServerConnection::ProcessPostData()",
"POST data block is COMPLETELY EMPTY!!" );
349 while( (pos = request.find_first_of(
'=')) >= 0 )
351 param = request.substr(0,pos);
352 std::transform(param.begin(), param.end(), param.begin(), tolower);
353 request = request.substr(pos+1);
354 pos = request.find_first_of(
'&');
359 value = request.substr(0,pos);
360 request = request.substr(pos);
361 if( request.substr(0,5) ==
"&" )
362 request = request.substr(5);
364 request = request.substr(1);
366 m_apiCommandCall.insert( std::pair<std::string, std::string>( param, value ) );
372 sLog.Error(
"APIServerConnection::ProcessPostData()",
"Unknown or malformed EVEmu API HTTP CMD Received:\r\n%s\r\n", query.c_str());
379 APICommandCall::const_iterator cur, end;
382 for (
int i=1; cur != end; cur++, i++)
383 sLog.Debug(
" ",
"%d: param = %s, value = %s", i, cur->first.c_str(), cur->second.c_str() );
407 std::stringstream url;
425 return haystack.substr(0, strlen(needle)).compare(needle) == 0;
static const char *const FallbackURL
boost::asio::streambuf _postBuffer
std::string _service_handler
static std::tr1::shared_ptr< APIServerConnection > create(boost::asio::io_context &io)
static boost::asio::const_buffers_1 _responseRedirectBegin
static boost::asio::const_buffers_1 _responseRedirectEnd
boost::asio::ip::tcp::socket & socket()
static boost::asio::const_buffers_1 _responseOK
static boost::asio::const_buffers_1 _responseNotFound
APICommandCall m_apiCommandCall
std::tr1::shared_ptr< std::vector< char > > _xmlData
#define sLog
Evaluates to a NewLog instance.
std::string _http_cmd_str
static boost::asio::const_buffers_1 _responseNoContent
APIServerConnection(boost::asio::io_context &io)
boost::asio::streambuf _buffer
static bool starts_with(std::string &haystack, const char *const needle)
boost::asio::ip::tcp::socket _socket