From 54b179d0ea3cd9881fb9c82d75263e1f371143fe Mon Sep 17 00:00:00 2001 From: gue5t Date: Sun, 19 Apr 2015 09:39:09 -0500 Subject: avoid deprecated SoupServer API with libsoup 2.48 --- tests/download.vala | 14 +++++++++++++- tests/tab.vala | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/download.vala b/tests/download.vala index a3dc561a..4e2d641c 100644 --- a/tests/download.vala +++ b/tests/download.vala @@ -69,11 +69,23 @@ static void download_unique () { } void download_properties () { +#if HAVE_LIBSOUP_2_48_0 + var test_server = new Soup.Server ("server-header", null, null); + try { + test_server.listen_local (0, Soup.ServerListenOptions.IPV4_ONLY); + } + catch (Error error) { + GLib.error (error.message); + } + var port = test_server.get_uris ().data.port; +#else var test_address = new Soup.Address ("127.0.0.1", Soup.ADDRESS_ANY_PORT); test_address.resolve_sync (null); var test_server = new Soup.Server ("interface", test_address, null); - string test_url = "http://127.0.0.1:%u".printf (test_server.get_port ()); test_server.run_async (); + var port = test_server.get_port (); +#endif + string test_url = "http://127.0.0.1:%u".printf (port); test_server.add_handler ("/", (server, msg, path, query, client)=>{ Thread.usleep (1000000); /* 1 seconds in µs */ if ("/not_found/" in path) diff --git a/tests/tab.vala b/tests/tab.vala index 3d1eb899..fbad9940 100644 --- a/tests/tab.vala +++ b/tests/tab.vala @@ -178,11 +178,23 @@ void tab_http () { browser.add_tab (tab); var loop = MainContext.default (); +#if HAVE_LIBSOUP_2_48_0 + var test_server = new Soup.Server ("server-header", null, null); + try { + test_server.listen_local (0, Soup.ServerListenOptions.IPV4_ONLY); + } + catch (Error error) { + GLib.error (error.message); + } + var port = test_server.get_uris ().data.port; +#else var test_address = new Soup.Address ("127.0.0.1", Soup.ADDRESS_ANY_PORT); test_address.resolve_sync (null); var test_server = new Soup.Server ("interface", test_address, null); - string test_url = "http://127.0.0.1:%u".printf (test_server.get_port ()); test_server.run_async (); + var port = test_server.get_port (); +#endif + string test_url = "http://127.0.0.1:%u".printf (port); test_server.add_handler ("/", (server, msg, path, query, client)=>{ msg.set_status_full (200, "OK"); msg.response_body.append_take ("".data); -- cgit v1.2.1