Fixing sockets and response.

This commit is contained in:
Ben Vanik
2013-12-21 11:52:48 -08:00
parent d98d5c855a
commit da340891c4
3 changed files with 27 additions and 20 deletions

View File

@@ -223,34 +223,28 @@ int WSClient::PerformHandshake() {
xesnprintfa(title_id, XECOUNT(title_id), "%.8X",
header->execution_info.title_id);
ostringstream response;
ostringstream response_body;
if (module) {
response <<
"HTTP/1.0 200 OK\r\n"
"Content-Type: application/json\r\n"
"Connection: close\r\n"
"\r\n";
response << "[{";
response <<
response_body << "[{";
response_body <<
"\"name\": \"" << module->name() << "\",";
response <<
"\"path\": \"" << module->path() << "\",";
response <<
response_body <<
"\"titleId\": \"" << title_id << "\"";
response << "}]";
response <<
"\r\n"
"\r\n";
response_body << "}]";
} else {
response <<
response_body <<
"[]";
}
size_t content_length = response_body.str().length();
ostringstream response;
response <<
"HTTP/1.0 200 OK\r\n"
"Content-Type: application/json\r\n"
"Connection: close\r\n"
"\r\n"
"[]"
"\r\n"
"Access-Control-Allow-Origin: *\r\n"
"Content-Length: " << content_length << "\r\n"
"\r\n";
}
response << response_body.str();
error_code = WriteResponse(response.str());
if (error_code) {
return error_code;