Skip to content

Commit

Permalink
Fix: Send "Connection: close"-Header for proxy connections
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Dec 15, 2024
1 parent 7aec221 commit 748c821
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This is a small bug fix release.

### Changelog

- Fix: Import of scripts
- Fix: Lua wrapper for `mympd.api`
- Fix: Emmit correct trigger event for INTERNAL_API_TRIGGER_EVENT_EMIT

Expand Down
12 changes: 9 additions & 3 deletions src/web_server/proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ void send_backend_request(struct mg_connection *nc) {
"User-Agent: myMPD/"MYMPD_VERSION" (https://github.com/jcorporation/myMPD)\r\n"
"Accept: */*\r\n"
"Accept-Encoding: none\r\n"
"Connection: close\r\n"
"\r\n",
mg_url_uri(backend_nc_data->uri),
(int)host.len, host.buf
Expand All @@ -126,7 +127,12 @@ struct mg_connection *create_backend_connection(struct mg_connection *nc, struct
sds uri, mg_event_handler_t fn, bool stream)
{
if (backend_nc == NULL) {
MYMPD_LOG_INFO(NULL, "Creating new http backend connection to \"%s\"", uri);
if (stream == false) {
MYMPD_LOG_INFO(NULL, "Creating new http backend connection to \"%s\"", uri);
}
else {
MYMPD_LOG_INFO(NULL, "Creating new stream backend connection to \"%s\"", uri);
}
struct t_backend_nc_data *backend_nc_data = malloc(sizeof(struct t_backend_nc_data));
backend_nc_data->uri = sdsdup(uri);
backend_nc_data->frontend_nc = nc;
Expand All @@ -135,8 +141,8 @@ struct mg_connection *create_backend_connection(struct mg_connection *nc, struct
: mg_connect(nc->mgr, uri, fn, backend_nc_data); // tcp connection with MG_EV_READ event
if (backend_nc == NULL) {
//no backend connection, close frontend connection
MYMPD_LOG_WARN(NULL, "Can not create http backend connection");
webserver_send_error(nc, 502, "Could not create backend connection");
MYMPD_LOG_WARN(NULL, "Failure creating backend connection");
webserver_send_error(nc, 502, "Failure creating backend connection");
nc->is_draining = 1;
//free backend_nc_data
free_backend_nc_data(backend_nc_data);
Expand Down

0 comments on commit 748c821

Please sign in to comment.