mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-22 06:04:01 -06:00
Fix 3rd party login issue on macOS (#4739)
* Fix use-after-free error * Ignore http OPTIONS method * Make sure response has sent before closing the http server
This commit is contained in:
parent
f36c22385b
commit
9f3bafb04e
3 changed files with 21 additions and 12 deletions
|
@ -77,13 +77,20 @@ void session::read_next_line()
|
|||
|
||||
if (line.length() == 0) {
|
||||
if (headers.content_length() == 0) {
|
||||
std::cout << "Request received: " << headers.method << " " << headers.get_url();
|
||||
if (headers.method == "OPTIONS") {
|
||||
// Ignore http OPTIONS
|
||||
server.stop(self);
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string url_str = Http::url_decode(headers.get_url());
|
||||
const auto resp = server.server.m_request_handler(url_str);
|
||||
std::stringstream ssOut;
|
||||
resp->write_response(ssOut);
|
||||
std::shared_ptr<std::string> str = std::make_shared<std::string>(ssOut.str());
|
||||
async_write(socket, boost::asio::buffer(str->c_str(), str->length()),
|
||||
[this, self](const boost::beast::error_code& e, std::size_t s) {
|
||||
[this, self, str](const boost::beast::error_code& e, std::size_t s) {
|
||||
std::cout << "done" << std::endl;
|
||||
server.stop(self);
|
||||
});
|
||||
|
@ -159,6 +166,7 @@ void HttpServer::stop()
|
|||
if (server_) {
|
||||
server_->acceptor.close();
|
||||
server_->stop_all();
|
||||
server_->io_service.stop();
|
||||
}
|
||||
if (m_http_server_thread.joinable())
|
||||
m_http_server_thread.join();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue