WebSockets: allow serving SVG files using libwebsockets < 3
This commit is contained in:
parent
2ba8dab95e
commit
612c71aa25
@ -57,20 +57,22 @@ WebsocketsServer::WebsocketsServer (ArdourSurface::ArdourWebsockets& surface)
|
|||||||
#if LWS_LIBRARY_VERSION_MAJOR >= 3
|
#if LWS_LIBRARY_VERSION_MAJOR >= 3
|
||||||
proto.tx_packet_size = 0;
|
proto.tx_packet_size = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_lws_proto[0] = proto;
|
_lws_proto[0] = proto;
|
||||||
memset (&_lws_proto[1], 0, sizeof (lws_protocols));
|
memset (&_lws_proto[1], 0, sizeof (lws_protocols));
|
||||||
|
|
||||||
// '/' is served by a static index.html file in the surface data directory
|
/* '/' is served by a static index.html file in the surface data directory
|
||||||
// inside it there is a 'builtin' subdirectory that contains all built-in
|
* inside it there is a 'builtin' subdirectory that contains all built-in
|
||||||
// surfaces so there is no need to create a dedicated mount point for them
|
* surfaces so there is no need to create a dedicated mount point for them
|
||||||
// list of surfaces is available as a dynamically generated json file
|
* list of surfaces is available as a dynamically generated json file
|
||||||
|
*/
|
||||||
memset (&_lws_mnt_index, 0, sizeof (lws_http_mount));
|
memset (&_lws_mnt_index, 0, sizeof (lws_http_mount));
|
||||||
_lws_mnt_index.mountpoint = "/";
|
_lws_mnt_index.mountpoint = "/";
|
||||||
_lws_mnt_index.mountpoint_len = strlen (_lws_mnt_index.mountpoint);
|
_lws_mnt_index.mountpoint_len = strlen (_lws_mnt_index.mountpoint);
|
||||||
_lws_mnt_index.origin_protocol = LWSMPRO_FILE;
|
_lws_mnt_index.origin_protocol = LWSMPRO_FILE;
|
||||||
_lws_mnt_index.origin = _resources.index_dir ().c_str ();
|
_lws_mnt_index.origin = _resources.index_dir ().c_str ();
|
||||||
|
|
||||||
// user defined surfaces in the user config directory
|
/* user defined surfaces in the user config directory */
|
||||||
memset (&_lws_mnt_user, 0, sizeof (lws_http_mount));
|
memset (&_lws_mnt_user, 0, sizeof (lws_http_mount));
|
||||||
_lws_mnt_user.mountpoint = "/user";
|
_lws_mnt_user.mountpoint = "/user";
|
||||||
_lws_mnt_user.mountpoint_len = strlen (_lws_mnt_user.mountpoint);
|
_lws_mnt_user.mountpoint_len = strlen (_lws_mnt_user.mountpoint);
|
||||||
@ -86,6 +88,15 @@ WebsocketsServer::WebsocketsServer (ArdourSurface::ArdourWebsockets& surface)
|
|||||||
_lws_info.uid = -1;
|
_lws_info.uid = -1;
|
||||||
_lws_info.gid = -1;
|
_lws_info.gid = -1;
|
||||||
_lws_info.user = this;
|
_lws_info.user = this;
|
||||||
|
|
||||||
|
#if LWS_LIBRARY_VERSION_MAJOR < 3
|
||||||
|
/* older libwebsockets does not define mime type for svg files */
|
||||||
|
memset (&_lws_vhost_opt, 0, sizeof (lws_protocol_vhost_options));
|
||||||
|
_lws_vhost_opt.name = ".svg";
|
||||||
|
_lws_vhost_opt.value = "image/svg+xml";
|
||||||
|
_lws_mnt_index.extra_mimetypes = &_lws_vhost_opt;
|
||||||
|
_lws_mnt_user.extra_mimetypes = &_lws_vhost_opt;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -62,6 +62,9 @@ public:
|
|||||||
void update_all_clients (const NodeState&, bool);
|
void update_all_clients (const NodeState&, bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#if LWS_LIBRARY_VERSION_MAJOR < 3
|
||||||
|
struct lws_protocol_vhost_options _lws_vhost_opt;
|
||||||
|
#endif
|
||||||
struct lws_protocols _lws_proto[2];
|
struct lws_protocols _lws_proto[2];
|
||||||
struct lws_http_mount _lws_mnt_index;
|
struct lws_http_mount _lws_mnt_index;
|
||||||
struct lws_http_mount _lws_mnt_user;
|
struct lws_http_mount _lws_mnt_user;
|
||||||
|
Loading…
Reference in New Issue
Block a user