| |
@@ -0,0 +1,103 @@
|
| |
+ From 0136e726e5be7bcbd34b39c841bd9529bf87cf66 Mon Sep 17 00:00:00 2001
|
| |
+ From: Marian Koncek <mkoncek@redhat.com>
|
| |
+ Date: Fri, 19 May 2023 14:23:41 +0200
|
| |
+ Subject: [PATCH 1/3] Remove support for HTTP and mongoose dependency
|
| |
+
|
| |
+ Upstream PR: https://github.com/svenstaro/glsl-language-server/pull/44
|
| |
+
|
| |
+ ---
|
| |
+ src/main.cpp | 64 +---------------------------------------------------
|
| |
+ 1 file changed, 1 insertion(+), 63 deletions(-)
|
| |
+
|
| |
+ diff --git a/src/main.cpp b/src/main.cpp
|
| |
+ index 05fe10c..ac10189 100644
|
| |
+ --- a/src/main.cpp
|
| |
+ +++ b/src/main.cpp
|
| |
+ @@ -5,8 +5,6 @@
|
| |
+
|
| |
+ #include "nlohmann/json.hpp"
|
| |
+
|
| |
+ -#include "mongoose.h"
|
| |
+ -
|
| |
+ #include "ResourceLimits.h"
|
| |
+ #include "ShaderLang.h"
|
| |
+ #include "Initialize.h"
|
| |
+ @@ -510,47 +508,6 @@ std::optional<std::string> handle_message(const MessageBuffer& message_buffer, A
|
| |
+ return make_response(result_body);
|
| |
+ }
|
| |
+
|
| |
+ -void ev_handler(struct mg_connection* c, int ev, void* p) {
|
| |
+ - AppState& appstate = *static_cast<AppState*>(c->mgr->user_data);
|
| |
+ -
|
| |
+ - if (ev == MG_EV_HTTP_REQUEST) {
|
| |
+ - struct http_message* hm = (struct http_message*)p;
|
| |
+ -
|
| |
+ - std::string content = hm->message.p;
|
| |
+ -
|
| |
+ - MessageBuffer message_buffer;
|
| |
+ - message_buffer.handle_string(content);
|
| |
+ -
|
| |
+ - if (message_buffer.message_completed()) {
|
| |
+ - json body = message_buffer.body();
|
| |
+ - if (appstate.use_logfile) {
|
| |
+ - fmt::print(appstate.logfile_stream, ">>> Received message of type '{}'\n", body["method"].get<std::string>());
|
| |
+ - if (appstate.verbose) {
|
| |
+ - fmt::print(appstate.logfile_stream, "Headers:\n");
|
| |
+ - for (auto elem : message_buffer.headers()) {
|
| |
+ - auto pretty_header = fmt::format("{}: {}\n", elem.first, elem.second);
|
| |
+ - appstate.logfile_stream << pretty_header;
|
| |
+ - }
|
| |
+ - fmt::print(appstate.logfile_stream, "Body: \n{}\n\n", body.dump(4));
|
| |
+ - fmt::print(appstate.logfile_stream, "Raw: \n{}\n\n", message_buffer.raw());
|
| |
+ - }
|
| |
+ - }
|
| |
+ -
|
| |
+ - auto message = handle_message(message_buffer, appstate);
|
| |
+ - if (message.has_value()) {
|
| |
+ - std::string response = message.value();
|
| |
+ - mg_send_head(c, 200, response.length(), "Content-Type: text/plain");
|
| |
+ - mg_printf(c, "%.*s", static_cast<int>(response.length()), response.c_str());
|
| |
+ - if (appstate.use_logfile && appstate.verbose) {
|
| |
+ - fmt::print(appstate.logfile_stream, "<<< Sending message: \n{}\n\n", message.value());
|
| |
+ - }
|
| |
+ - }
|
| |
+ - appstate.logfile_stream.flush();
|
| |
+ - message_buffer.clear();
|
| |
+ - }
|
| |
+ - }
|
| |
+ -}
|
| |
+ -
|
| |
+ int main(int argc, char* argv[])
|
| |
+ {
|
| |
+ CLI::App app{ "GLSL Language Server" };
|
| |
+ @@ -667,26 +624,7 @@ int main(int argc, char* argv[])
|
| |
+ auto diagnostics = get_diagnostics(uri, contents, appstate);
|
| |
+ fmt::print("diagnostics: {}\n", diagnostics.dump(4));
|
| |
+ } else if (!use_stdin) {
|
| |
+ - struct mg_mgr mgr;
|
| |
+ - struct mg_connection* nc;
|
| |
+ - struct mg_bind_opts bind_opts;
|
| |
+ - std::memset(&bind_opts, 0, sizeof(bind_opts));
|
| |
+ - bind_opts.user_data = &appstate;
|
| |
+ -
|
| |
+ - mg_mgr_init(&mgr, NULL);
|
| |
+ - fmt::print("Starting web server on port {}\n", port);
|
| |
+ - nc = mg_bind_opt(&mgr, std::to_string(port).c_str(), ev_handler, bind_opts);
|
| |
+ - if (nc == NULL) {
|
| |
+ - return 1;
|
| |
+ - }
|
| |
+ -
|
| |
+ - // Set up HTTP server parameters
|
| |
+ - mg_set_protocol_http_websocket(nc);
|
| |
+ -
|
| |
+ - while (true) {
|
| |
+ - mg_mgr_poll(&mgr, 1000);
|
| |
+ - }
|
| |
+ - mg_mgr_free(&mgr);
|
| |
+ + throw std::invalid_argument("This package was built without support for HTTP communication");
|
| |
+ } else {
|
| |
+ char c;
|
| |
+ MessageBuffer message_buffer;
|
| |
+ --
|
| |
+ 2.40.1
|
| |
+
|
| |