Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[mms-lib] Fixed compilation against libsoup 2.48 and newer. MER#1616
  • Loading branch information
monich committed Jul 6, 2016
1 parent d0faebc commit 6841d27
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
5 changes: 5 additions & 0 deletions mms-lib/src/mms_task_http.c
Expand Up @@ -32,6 +32,11 @@
# define SOUP_SESSION_LOCAL_ADDRESS "local-address"
#endif

#if SOUP_CHECK_VERSION(2,42,0)
# define soup_session_async_new_with_options soup_session_new_with_options
# define soup_session_async_new soup_session_new
#endif

/* Logging */
#define MMS_LOG_MODULE_NAME MMS_TASK_HTTP_LOG
#include "mms_lib_log.h"
Expand Down
29 changes: 26 additions & 3 deletions mms-lib/test/common/test_http.c
Expand Up @@ -27,6 +27,7 @@ typedef struct test_http_response {

struct test_http {
gint ref_count;
guint port;
SoupServer* server;
GPtrArray* responses;
GPtrArray* post_data;
Expand Down Expand Up @@ -97,7 +98,7 @@ guint
test_http_get_port(
TestHttp* http)
{
return soup_server_get_port(http->server);
return http->port;
}

guint
Expand Down Expand Up @@ -170,6 +171,16 @@ test_http_add_response(
g_ptr_array_add(http->responses, resp);
}

#if SOUP_CHECK_VERSION(2,48,0)
static
void
test_http_uri_free(
gpointer uri)
{
soup_uri_free(uri);
}
#endif

TestHttp*
test_http_new(
GMappedFile* get_file,
Expand All @@ -181,9 +192,21 @@ test_http_new(
http->responses = g_ptr_array_new_full(0, test_http_response_free);
http->post_data = g_ptr_array_new_full(0, test_http_post_data_bytes_free);
http->server = g_object_new(SOUP_TYPE_SERVER, NULL);
MMS_DEBUG("Listening on port %hu", soup_server_get_port(http->server));
soup_server_add_handler(http->server, NULL, test_http_callback, http, NULL);
#if SOUP_CHECK_VERSION(2,48,0)
if (soup_server_listen_local(http->server, 0, 0, NULL)) {
GSList* uris = soup_server_get_uris(http->server);
if (uris) {
SoupURI* uri = uris->data;
http->port = soup_uri_get_port(uri);
g_slist_free_full(uris, test_http_uri_free);
}
}
#else
http->port = soup_server_get_port(http->server);
soup_server_run_async(http->server);
#endif
MMS_DEBUG("Listening on port %hu", http->port);
soup_server_add_handler(http->server, NULL, test_http_callback, http, NULL);
if (get_file || resp_content_type || resp_status) {
test_http_add_response(http, get_file, resp_content_type, resp_status);
}
Expand Down

0 comments on commit 6841d27

Please sign in to comment.