Fixing sockets and response.
This commit is contained in:
@@ -35,6 +35,15 @@ socket_t xe_socket_create_tcp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void xe_socket_close(socket_t socket) {
|
void xe_socket_close(socket_t socket) {
|
||||||
|
struct linger so_linger;
|
||||||
|
so_linger.l_onoff = TRUE;
|
||||||
|
so_linger.l_linger = 30;
|
||||||
|
setsockopt(
|
||||||
|
socket,
|
||||||
|
SOL_SOCKET,
|
||||||
|
SO_LINGER,
|
||||||
|
(const char*)&so_linger,
|
||||||
|
sizeof so_linger);
|
||||||
shutdown(socket, SD_SEND);
|
shutdown(socket, SD_SEND);
|
||||||
closesocket(socket);
|
closesocket(socket);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,34 +223,28 @@ int WSClient::PerformHandshake() {
|
|||||||
xesnprintfa(title_id, XECOUNT(title_id), "%.8X",
|
xesnprintfa(title_id, XECOUNT(title_id), "%.8X",
|
||||||
header->execution_info.title_id);
|
header->execution_info.title_id);
|
||||||
|
|
||||||
ostringstream response;
|
ostringstream response_body;
|
||||||
if (module) {
|
if (module) {
|
||||||
response <<
|
response_body << "[{";
|
||||||
"HTTP/1.0 200 OK\r\n"
|
response_body <<
|
||||||
"Content-Type: application/json\r\n"
|
|
||||||
"Connection: close\r\n"
|
|
||||||
"\r\n";
|
|
||||||
response << "[{";
|
|
||||||
response <<
|
|
||||||
"\"name\": \"" << module->name() << "\",";
|
"\"name\": \"" << module->name() << "\",";
|
||||||
response <<
|
response_body <<
|
||||||
"\"path\": \"" << module->path() << "\",";
|
|
||||||
response <<
|
|
||||||
"\"titleId\": \"" << title_id << "\"";
|
"\"titleId\": \"" << title_id << "\"";
|
||||||
response << "}]";
|
response_body << "}]";
|
||||||
response <<
|
|
||||||
"\r\n"
|
|
||||||
"\r\n";
|
|
||||||
} else {
|
} else {
|
||||||
response <<
|
response_body <<
|
||||||
|
"[]";
|
||||||
|
}
|
||||||
|
size_t content_length = response_body.str().length();
|
||||||
|
ostringstream response;
|
||||||
|
response <<
|
||||||
"HTTP/1.0 200 OK\r\n"
|
"HTTP/1.0 200 OK\r\n"
|
||||||
"Content-Type: application/json\r\n"
|
"Content-Type: application/json\r\n"
|
||||||
"Connection: close\r\n"
|
"Connection: close\r\n"
|
||||||
"\r\n"
|
"Access-Control-Allow-Origin: *\r\n"
|
||||||
"[]"
|
"Content-Length: " << content_length << "\r\n"
|
||||||
"\r\n"
|
|
||||||
"\r\n";
|
"\r\n";
|
||||||
}
|
response << response_body.str();
|
||||||
error_code = WriteResponse(response.str());
|
error_code = WriteResponse(response.str());
|
||||||
if (error_code) {
|
if (error_code) {
|
||||||
return error_code;
|
return error_code;
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ XModule::XModule(KernelState* kernel_state, const char* path) :
|
|||||||
if (slash) {
|
if (slash) {
|
||||||
XEIGNORE(xestrcpya(name_, XECOUNT(name_), slash + 1));
|
XEIGNORE(xestrcpya(name_, XECOUNT(name_), slash + 1));
|
||||||
}
|
}
|
||||||
|
char* dot = xestrrchra(name_, '.');
|
||||||
|
if (dot) {
|
||||||
|
*dot = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
XModule::~XModule() {
|
XModule::~XModule() {
|
||||||
|
|||||||
Reference in New Issue
Block a user