int main (int argc, char **argv) { SoupServer *server; char *fast_uri, *slow_uri; test_init (argc, argv, NULL); debug_printf (1, "http\n"); server = soup_test_server_new (TRUE); soup_server_add_handler (server, NULL, server_handler, NULL, NULL); fast_uri = g_strdup_printf ("http://127.0.0.1:%u/", soup_server_get_port (server)); slow_uri = g_strdup_printf ("http://127.0.0.1:%u/slow", soup_server_get_port (server)); do_timeout_tests (fast_uri, slow_uri); g_free (fast_uri); g_free (slow_uri); debug_printf (1, "https\n"); server = soup_test_server_new_ssl (TRUE); soup_server_add_handler (server, NULL, server_handler, NULL, NULL); fast_uri = g_strdup_printf ("https://127.0.0.1:%u/", soup_server_get_port (server)); slow_uri = g_strdup_printf ("https://127.0.0.1:%u/slow", soup_server_get_port (server)); do_timeout_tests (fast_uri, slow_uri); g_free (fast_uri); g_free (slow_uri); test_cleanup (); return errors != 0; }
int main (int argc, char **argv) { GMainLoop *loop; SoupServer *server; SoupURI *uri; SoupAuthDomain *auth_domain; test_init (argc, argv, no_test_entry); server = soup_test_server_new (FALSE); g_signal_connect (server, "request_started", G_CALLBACK (request_started_callback), NULL); soup_server_add_handler (server, NULL, server_callback, NULL, NULL); auth_domain = soup_auth_domain_basic_new ( SOUP_AUTH_DOMAIN_REALM, "server-auth-test", SOUP_AUTH_DOMAIN_ADD_PATH, "/Basic", SOUP_AUTH_DOMAIN_ADD_PATH, "/Any", SOUP_AUTH_DOMAIN_REMOVE_PATH, "/Any/Not", SOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK, basic_auth_callback, NULL); soup_server_add_auth_domain (server, auth_domain); g_object_unref (auth_domain); auth_domain = soup_auth_domain_digest_new ( SOUP_AUTH_DOMAIN_REALM, "server-auth-test", SOUP_AUTH_DOMAIN_ADD_PATH, "/Digest", SOUP_AUTH_DOMAIN_ADD_PATH, "/Any", SOUP_AUTH_DOMAIN_REMOVE_PATH, "/Any/Not", SOUP_AUTH_DOMAIN_DIGEST_AUTH_CALLBACK, digest_auth_callback, NULL); soup_server_add_auth_domain (server, auth_domain); g_object_unref (auth_domain); loop = g_main_loop_new (NULL, TRUE); if (run_tests) { uri = soup_uri_new ("http://127.0.0.1"); soup_uri_set_port (uri, soup_server_get_port (server)); do_auth_tests (uri); soup_uri_free (uri); } else { printf ("Listening on port %d\n", soup_server_get_port (server)); g_main_loop_run (loop); } g_main_loop_unref (loop); soup_test_server_quit_unref (server); if (run_tests) test_cleanup (); return errors != 0; }
int run_server (guint * http_port, guint * https_port) { guint port = SOUP_ADDRESS_ANY_PORT; guint ssl_port = SOUP_ADDRESS_ANY_PORT; const char *ssl_cert_file = GST_TEST_FILES_PATH "/test-cert.pem"; const char *ssl_key_file = GST_TEST_FILES_PATH "/test-key.pem"; static int server_running = 0; SoupAuthDomain *domain = NULL; if (server_running) return 0; server_running = 1; *http_port = *https_port = 0; server = soup_server_new (SOUP_SERVER_PORT, port, NULL); if (!server) { GST_DEBUG ("Unable to bind to server port %u", port); return 1; } *http_port = soup_server_get_port (server); GST_INFO ("HTTP server listening on port %u", *http_port); soup_server_add_handler (server, NULL, server_callback, NULL, NULL); domain = soup_auth_domain_basic_new (SOUP_AUTH_DOMAIN_REALM, realm, SOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK, basic_auth_cb, SOUP_AUTH_DOMAIN_ADD_PATH, basic_auth_path, NULL); soup_server_add_auth_domain (server, domain); g_object_unref (domain); domain = soup_auth_domain_digest_new (SOUP_AUTH_DOMAIN_REALM, realm, SOUP_AUTH_DOMAIN_DIGEST_AUTH_CALLBACK, digest_auth_cb, SOUP_AUTH_DOMAIN_ADD_PATH, digest_auth_path, NULL); soup_server_add_auth_domain (server, domain); g_object_unref (domain); soup_server_run_async (server); if (ssl_cert_file && ssl_key_file) { ssl_server = soup_server_new (SOUP_SERVER_PORT, ssl_port, SOUP_SERVER_SSL_CERT_FILE, ssl_cert_file, SOUP_SERVER_SSL_KEY_FILE, ssl_key_file, NULL); if (!ssl_server) { GST_DEBUG ("Unable to bind to SSL server port %u", ssl_port); return 1; } *https_port = soup_server_get_port (ssl_server); GST_INFO ("HTTPS server listening on port %u", *https_port); soup_server_add_handler (ssl_server, NULL, server_callback, NULL, NULL); soup_server_run_async (ssl_server); } return 0; }
int main (int argc, char **argv) { SoupAuthDomain *auth_domain; test_init (argc, argv, NULL); server = soup_test_server_new (TRUE); soup_server_add_handler (server, NULL, server_callback, "http", NULL); base_uri = soup_uri_new ("http://127.0.0.1/"); soup_uri_set_port (base_uri, soup_server_get_port (server)); auth_domain = soup_auth_domain_basic_new ( SOUP_AUTH_DOMAIN_REALM, "misc-test", SOUP_AUTH_DOMAIN_ADD_PATH, "/auth", SOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK, auth_callback, NULL); soup_server_add_auth_domain (server, auth_domain); g_object_unref (auth_domain); ssl_server = soup_test_server_new_ssl (TRUE); soup_server_add_handler (ssl_server, NULL, server_callback, "https", NULL); ssl_base_uri = soup_uri_new ("https://127.0.0.1/"); soup_uri_set_port (ssl_base_uri, soup_server_get_port (ssl_server)); do_host_test (); do_callback_unref_test (); do_callback_unref_req_test (); do_msg_reuse_test (); do_star_test (); do_early_abort_test (); do_early_abort_req_test (); do_accept_language_test (); do_cancel_while_reading_test (); do_cancel_while_reading_req_test (); do_aliases_test (); do_dot_dot_test (); do_ipv6_test (); do_idle_on_dispose_test (); do_pause_abort_test (); soup_uri_free (base_uri); soup_uri_free (ssl_base_uri); soup_test_server_quit_unref (server); soup_test_server_quit_unref (ssl_server); test_cleanup (); return errors != 0; }
static void ipv6_server_callback (SoupServer *server, SoupMessage *msg, const char *path, GHashTable *query, SoupClientContext *context, gpointer data) { const char *host; char expected_host[128]; host = soup_message_headers_get_one (msg->request_headers, "Host"); if (!host) { debug_printf (1, " request has no Host header!\n"); errors++; soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST); return; } g_snprintf (expected_host, sizeof (expected_host), "[::1]:%d", soup_server_get_port (server)); if (strcmp (host, expected_host) == 0) soup_message_set_status (msg, SOUP_STATUS_OK); else { debug_printf (1, " request has incorrect Host header '%s'\n", host); errors++; soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST); } }
int main (int argc, char **argv) { SoupServer *server; char *uri; int ret; /* Force this test to use the dummy TLS backend */ g_setenv ("GIO_USE_TLS", "dummy", TRUE); test_init (argc, argv, NULL); /* Make a non-SSL server and pretend that it's ssl, which is fine * since we won't ever actually talk to it anyway. We don't * currently test that failing to construct an SSL server works. */ server = soup_test_server_new (TRUE); soup_server_add_handler (server, NULL, server_handler, NULL, NULL); uri = g_strdup_printf ("https://127.0.0.1:%u/", soup_server_get_port (server)); g_test_add_func ("/no-ssl/session-properties", do_session_property_tests); g_test_add_data_func ("/no-ssl/request-error", uri, do_ssl_tests); ret = g_test_run (); g_free (uri); soup_test_server_quit_unref (server); test_cleanup (); return ret; }
static void force_io_streams_init (void) { SoupServer *server; SoupSession *session; guint port; SoupURI *base_uri; SoupMessage *msg; /* Poke libsoup enough to cause SoupBodyInputStream and * SoupBodyOutputStream to get defined, so we can find them * via g_type_from_name() later. */ server = soup_test_server_new (TRUE); port = soup_server_get_port (server); base_uri = soup_uri_new ("http://127.0.0.1"); soup_uri_set_port (base_uri, port); session = soup_test_session_new (SOUP_TYPE_SESSION, NULL); msg = soup_message_new_from_uri ("POST", base_uri); soup_session_send_message (session, msg); g_object_unref (msg); soup_test_session_abort_unref (session); soup_uri_free (base_uri); soup_test_server_quit_unref (server); }
int main(int argc, char** argv) { SoupServer* server; SoupURI* soup_uri; g_thread_init(NULL); gtk_test_init(&argc, &argv, NULL); /* Hopefully make test independent of the path it's called from. */ testutils_relative_chdir("WebKit/gtk/tests/resources/test.html", argv[0]); server = soup_server_new(SOUP_SERVER_PORT, 0, NULL); soup_server_run_async(server); soup_server_add_handler(server, NULL, server_callback, NULL, NULL); soup_uri = soup_uri_new("http://127.0.0.1/"); soup_uri_set_port(soup_uri, soup_server_get_port(server)); base_uri = soup_uri_to_string(soup_uri, FALSE); soup_uri_free(soup_uri); g_test_bug_base("https://bugs.webkit.org/"); g_test_add_func("/webkit/webview/icon-uri", test_webkit_web_view_icon_uri); g_test_add_func("/webkit/webview/adjustments", test_webkit_web_view_adjustments); g_test_add_func("/webkit/webview/destroy", test_webkit_web_view_destroy); g_test_add_func("/webkit/webview/grab_focus", test_webkit_web_view_grab_focus); g_test_add_func("/webkit/webview/window-features", test_webkit_web_view_window_features); return g_test_run (); }
int main (int argc, char **argv) { GMainLoop *loop; SoupServer *server; guint port; SoupURI *base_uri; test_init (argc, argv, NULL); server = soup_test_server_new (TRUE); soup_server_add_handler (server, NULL, server_callback, NULL, NULL); port = soup_server_get_port (server); loop = g_main_loop_new (NULL, TRUE); base_uri = soup_uri_new ("http://127.0.0.1"); soup_uri_set_port (base_uri, port); do_chunk_tests (base_uri); soup_uri_free (base_uri); g_main_loop_unref (loop); soup_test_server_quit_unref (server); test_cleanup (); return errors != 0; }
int main (int argc, char **argv) { SoupSession *session; char *url; RestProxy *proxy; g_type_init (); loop = g_main_loop_new (NULL, FALSE); session = soup_session_async_new (); server = soup_server_new (NULL); soup_server_add_handler (server, NULL, server_callback, NULL, NULL); soup_server_run_async (server); url = g_strdup_printf ("http://127.0.0.1:%d/", soup_server_get_port (server)); proxy = rest_proxy_new (url, FALSE); g_free (url); stream_test (proxy); g_main_loop_run (loop); return errors != 0; }
int main (int argc, char **argv) { SoupServer *server; int ret; test_init (argc, argv, NULL); server = soup_test_server_new (TRUE); soup_server_add_handler (server, NULL, server_callback, NULL, NULL); base_uri = g_strdup_printf ("http://127.0.0.1:%u/", soup_server_get_port (server)); g_test_add_data_func ("/context/blocking/explicit", GINT_TO_POINTER (FALSE), do_test1); g_test_add_data_func ("/context/blocking/thread-default", GINT_TO_POINTER (TRUE), do_test1); g_test_add_data_func ("/context/nested/explicit", GINT_TO_POINTER (FALSE), do_test2); g_test_add_data_func ("/context/nested/thread-default", GINT_TO_POINTER (TRUE), do_test2); g_test_add_func ("/context/multiple", do_multicontext_test); ret = g_test_run (); g_free (base_uri); soup_test_server_quit_unref (server); test_cleanup (); return ret; }
int main (int argc, char **argv) { test_init (argc, argv, NULL); #ifdef HAVE_APACHE apache_init (); #endif server = soup_test_server_new (TRUE); soup_server_add_handler (server, NULL, server_callback, "http", NULL); base_uri = soup_uri_new ("http://127.0.0.1/"); soup_uri_set_port (base_uri, soup_server_get_port (server)); do_content_length_framing_test (); do_persistent_connection_timeout_test (); do_max_conns_test (); do_non_persistent_connection_test (); do_non_idempotent_connection_test (); #ifdef HAVE_APACHE do_connection_state_test (); do_connection_event_test (); #endif soup_uri_free (base_uri); soup_test_server_quit_unref (server); test_cleanup (); return errors != 0; }
int main(int argc, char** argv) { SoupServer* server; SoupURI* soup_uri; gtk_test_init(&argc, &argv, NULL); /* Hopefully make test independent of the path it's called from. */ testutils_relative_chdir("Source/WebKit/gtk/tests/resources/test.html", argv[0]); server = soup_server_new(SOUP_SERVER_PORT, 0, NULL); soup_server_run_async(server); soup_server_add_handler(server, NULL, server_callback, NULL, NULL); soup_uri = soup_uri_new("http://127.0.0.1/"); soup_uri_set_port(soup_uri, soup_server_get_port(server)); base_uri = soup_uri_to_string(soup_uri, FALSE); soup_uri_free(soup_uri); g_test_bug_base("https://bugs.webkit.org/"); g_test_add_func("/webkit/webview/icon-uri", test_webkit_web_view_icon_uri); g_test_add_func("/webkit/webview/adjustments", test_webkit_web_view_adjustments); g_test_add_func("/webkit/webview/destroy", test_webkit_web_view_destroy); g_test_add_func("/webkit/webview/grab_focus", test_webkit_web_view_grab_focus); g_test_add_func("/webkit/webview/window-features", test_webkit_web_view_window_features); g_test_add_func("/webkit/webview/webview-in-offscreen-window-does-not-crash", test_webkit_web_view_in_offscreen_window_does_not_crash); g_test_add_func("/webkit/webview/webview-does-not-steal-focus", test_webkit_web_view_does_not_steal_focus); g_test_add_data_func("/webkit/webview/fullscreen", GINT_TO_POINTER(FALSE), test_webkit_web_view_fullscreen); g_test_add_data_func("/webkit/webview/fullscreen-blocked", GINT_TO_POINTER(TRUE), test_webkit_web_view_fullscreen); g_test_add_func("/webkit/webview/file-chooser", test_webkit_web_view_file_chooser); return g_test_run (); }
int main(int argc, char **argv) { gtk_test_init(&argc, &argv, NULL); /* This hopefully makes the test independent of the path it's called from. */ testutils_relative_chdir("Source/WebKit/gtk/tests/resources/test.html", argv[0]); SoupServer *server = soup_server_new(SOUP_SERVER_PORT, 0, NULL); soup_server_run_async(server); soup_server_add_handler(server, NULL, serverCallback, NULL, NULL); SoupURI *soupURI = soup_uri_new("http://127.0.0.1/"); soup_uri_set_port(soupURI, soup_server_get_port(server)); baseURI = soup_uri_to_string(soupURI, FALSE); soup_uri_free(soupURI); g_test_bug_base("https://bugs.webkit.org/"); g_test_add_func("/webkit/favicondatabase/set-path", testWebKitFaviconDatabaseSetPath); // These two tests will trigger an ASSERTION on debug builds due // to http://webkit.org/b/67582. Remove the guards once the bug is fixed. #ifdef NDEBUG g_test_add_func("/webkit/favicondatabase/get-favicon", testWebKitFaviconDatabaseGetFavicon); g_test_add_func("/webkit/favicondatabase/get-favicon-uri", testWebKitFaviconDatabaseGetFaviconURI); #endif g_test_add_func("/webkit/favicondatabase/remove-all", testWebKitFaviconDatabaseRemoveAll); g_test_add_func("/webkit/favicondatabase/close-db", testWebKitFaviconDatabaseCloseDatabase); return g_test_run(); }
int main (int argc, char **argv) { GMainLoop *loop; SoupServer *server; GHashTable *connections; SoupURI *uri; test_init (argc, argv, NULL); server = soup_test_server_new (FALSE); connections = g_hash_table_new (NULL, NULL); soup_server_add_handler (server, NULL, server_callback, connections, NULL); loop = g_main_loop_new (NULL, TRUE); uri = soup_uri_new ("http://127.0.0.1/"); soup_uri_set_port (uri, soup_server_get_port (server)); do_ntlm_tests (uri); soup_uri_free (uri); g_main_loop_unref (loop); soup_test_server_quit_unref (server); test_cleanup (); g_hash_table_destroy (connections); return errors != 0; }
int main (int argc, char **argv) { GOptionContext *opts; GMainLoop *loop; GError *error = NULL; opts = g_option_context_new (NULL); g_option_context_add_main_entries (opts, entries, NULL); if (!g_option_context_parse (opts, &argc, &argv, &error)) { g_printerr ("Could not parse arguments: %s\n", error->message); g_printerr ("%s", g_option_context_get_help (opts, TRUE, NULL)); exit (1); } if (argc != 2) { g_printerr ("%s", g_option_context_get_help (opts, TRUE, NULL)); exit (1); } g_option_context_free (opts); signal (SIGINT, quit); server = soup_server_new (SOUP_SERVER_PORT, port, NULL); if (!server) { g_printerr ("Unable to bind to server port %d\n", port); exit (1); } soup_server_add_handler (server, NULL, server_callback, NULL, NULL); if (require_auth) { SoupAuthDomain *auth_domain; auth_domain = soup_auth_domain_basic_new ( SOUP_AUTH_DOMAIN_REALM, "simple-proxy", SOUP_AUTH_DOMAIN_PROXY, TRUE, SOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK, auth_callback, NULL); soup_server_add_auth_domain (server, auth_domain); g_object_unref (auth_domain); } g_print ("\nStarting proxy on port %d\n", soup_server_get_port (server)); soup_server_run_async (server); session = soup_session_async_new (); g_print ("\nWaiting for requests...\n"); loop = g_main_loop_new (NULL, TRUE); g_main_loop_run (loop); g_main_loop_unref (loop); return 0; }
int main (int argc, char **argv) { GMainLoop *loop; SoupServer *server; guint port; SoupURI *base_uri; test_init (argc, argv, no_test_entry); server = soup_test_server_new (TRUE); soup_server_add_handler (server, NULL, server_callback, NULL, NULL); port = soup_server_get_port (server); loop = g_main_loop_new (NULL, TRUE); if (run_tests) { base_uri = soup_uri_new ("http://127.0.0.1"); soup_uri_set_port (base_uri, port); do_redirect_tests (base_uri); soup_uri_free (base_uri); } else { printf ("Listening on port %d\n", port); g_main_loop_run (loop); } g_main_loop_unref (loop); if (run_tests) test_cleanup (); return errors != 0; }
int main (int argc, char **argv) { SoupAuthDomain *auth_domain; test_init (argc, argv, NULL); server = soup_test_server_new (TRUE); soup_server_add_handler (server, NULL, server_callback, NULL, NULL); base_uri = soup_uri_new ("http://127.0.0.1/"); soup_uri_set_port (base_uri, soup_server_get_port (server)); auth_domain = soup_auth_domain_basic_new ( SOUP_AUTH_DOMAIN_REALM, "misc-test", SOUP_AUTH_DOMAIN_ADD_PATH, "/auth", SOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK, auth_callback, NULL); soup_server_add_auth_domain (server, auth_domain); g_object_unref (auth_domain); do_host_test (); do_callback_unref_test (); do_msg_reuse_test (); do_star_test (); do_early_abort_test (); do_content_length_framing_test (); do_accept_language_test (); do_persistent_connection_timeout_test (); soup_uri_free (base_uri); soup_test_server_quit_unref (server); test_cleanup (); return errors != 0; }
int main (int argc, char **argv) { GMainLoop *loop; int opt; int port = SOUP_ADDRESS_ANY_PORT; SoupAuthDomain *auth_domain = NULL; g_type_init (); signal (SIGINT, quit); while ((opt = getopt (argc, argv, "ap:")) != -1) { switch (opt) { case 'a': auth_domain = soup_auth_domain_basic_new ( SOUP_AUTH_DOMAIN_REALM, "simple-proxy", SOUP_AUTH_DOMAIN_PROXY, TRUE, SOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK, auth_callback, NULL); break; case 'p': port = atoi (optarg); break; default: g_printerr ("Usage: %s [-p port] [-n]\n", argv[0]); exit (1); } } server = soup_server_new (SOUP_SERVER_PORT, port, NULL); if (!server) { g_printerr ("Unable to bind to server port %d\n", port); exit (1); } soup_server_add_handler (server, NULL, server_callback, NULL, NULL); if (auth_domain) { soup_server_add_auth_domain (server, auth_domain); g_object_unref (auth_domain); } g_print ("\nStarting proxy on port %d\n", soup_server_get_port (server)); soup_server_run_async (server); session = soup_session_async_new (); g_print ("\nWaiting for requests...\n"); loop = g_main_loop_new (NULL, TRUE); g_main_loop_run (loop); g_main_loop_unref (loop); return 0; }
void korva_upnp_file_server_host_file_async (KorvaUPnPFileServer *self, GFile *file, GHashTable *params, const char *iface, const char *peer, GAsyncReadyCallback callback, gpointer user_data) { KorvaUPnPHostData *data; GSimpleAsyncResult *result; guint port; HostFileResult *result_data; KorvaUPnPMetadataQuery *query; result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, (gpointer) korva_upnp_file_server_host_file_async); data = g_hash_table_lookup (self->priv->host_data, file); if (data == NULL) { QueryMetaData *query_data; query_data = g_slice_new0 (QueryMetaData); data = korva_upnp_host_data_new (file, params, peer); query_data->data = data; query_data->self = self; query_data->result = result; query_data->iface = g_strdup (iface); query = korva_upnp_metadata_query_new (file, params); korva_upnp_metadata_query_run_async (query, korva_upnp_file_server_on_metadata_query_run_done, NULL, query_data); return; } korva_upnp_host_data_add_peer (data, peer); port = soup_server_get_port (self->priv->http_server); result_data = g_new0 (HostFileResult, 1); result_data->params = korva_upnp_host_data_get_meta_data (data); result_data->uri = korva_upnp_host_data_get_uri (data, iface, port); g_simple_async_result_set_op_res_gpointer (result, result_data, g_free); g_simple_async_result_complete_in_idle (result); g_object_unref (result); }
static void do_disappearing_auth_test (void) { SoupServer *server; SoupAuthDomain *auth_domain; SoupURI *uri; SoupMessage *msg; SoupSession *session; int counter; debug_printf (1, "\nTesting auth when server does not repeat challenge on failure:\n"); server = soup_test_server_new (FALSE); soup_server_add_handler (server, NULL, server_callback, NULL, NULL); uri = soup_uri_new ("http://127.0.0.1/"); soup_uri_set_port (uri, soup_server_get_port (server)); auth_domain = soup_auth_domain_basic_new ( SOUP_AUTH_DOMAIN_REALM, "auth-test", SOUP_AUTH_DOMAIN_ADD_PATH, "/", SOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK, server_basic_auth_callback, NULL); soup_server_add_auth_domain (server, auth_domain); g_signal_connect (server, "request-read", G_CALLBACK (disappear_request_read), NULL); session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); counter = 0; g_signal_connect (session, "authenticate", G_CALLBACK (disappear_authenticate), &counter); msg = soup_message_new_from_uri ("GET", uri); soup_session_send_message (session, msg); if (counter > 2) { debug_printf (1, " FAILED: Got stuck in loop"); errors++; } else if (msg->status_code != SOUP_STATUS_UNAUTHORIZED) { debug_printf (1, " Final status wrong: expected 401, got %u\n", msg->status_code); errors++; } g_object_unref (msg); soup_test_session_abort_unref (session); g_object_unref (auth_domain); soup_uri_free (uri); soup_test_server_quit_unref (server); }
int init_server() { SoupServer *server; int port = SOUP_ADDRESS_ANY_PORT; server = soup_server_new (SOUP_SERVER_PORT, port, SOUP_SERVER_SERVER_HEADER, "AwayFramework ", NULL); if (!server) { g_log("AFR", G_LOG_LEVEL_ERROR, "Unable to bind to server port %d\n", port); return -1; } soup_server_add_handler (server, NULL, server_callback, NULL, NULL); g_log("AFR", G_LOG_LEVEL_INFO, "Starting Server on port %d", soup_server_get_port (server)); soup_server_run_async (server); return soup_server_get_port (server); }
int main (int argc, char **argv) { test_init (argc, argv, NULL); server = soup_test_server_new (TRUE); soup_server_add_handler (server, NULL, server_callback, NULL, NULL); first_party_uri = soup_uri_new (first_party); third_party_uri = soup_uri_new (third_party); soup_uri_set_port (first_party_uri, soup_server_get_port (server)); soup_uri_set_port (third_party_uri, soup_server_get_port (server)); do_cookies_accept_policy_test (); do_cookies_parsing_test (); soup_uri_free (first_party_uri); soup_uri_free (third_party_uri); soup_test_server_quit_unref (server); test_cleanup (); return errors != 0; }
static void do_ipv6_test (void) { SoupServer *ipv6_server; SoupURI *ipv6_uri; SoupAddress *ipv6_addr; SoupSession *session; SoupMessage *msg; debug_printf (1, "\nIPv6 server test\n"); ipv6_addr = soup_address_new ("::1", SOUP_ADDRESS_ANY_PORT); soup_address_resolve_sync (ipv6_addr, NULL); ipv6_server = soup_server_new (SOUP_SERVER_INTERFACE, ipv6_addr, NULL); g_object_unref (ipv6_addr); soup_server_add_handler (ipv6_server, NULL, ipv6_server_callback, NULL, NULL); soup_server_run_async (ipv6_server); ipv6_uri = soup_uri_new ("http://[::1]/"); soup_uri_set_port (ipv6_uri, soup_server_get_port (ipv6_server)); session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); debug_printf (1, " HTTP/1.1\n"); msg = soup_message_new_from_uri ("GET", ipv6_uri); soup_session_send_message (session, msg); if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { debug_printf (1, " request failed: %d %s\n", msg->status_code, msg->reason_phrase); errors++; } g_object_unref (msg); debug_printf (1, " HTTP/1.0\n"); msg = soup_message_new_from_uri ("GET", ipv6_uri); soup_message_set_http_version (msg, SOUP_HTTP_1_0); soup_session_send_message (session, msg); if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { debug_printf (1, " request failed: %d %s\n", msg->status_code, msg->reason_phrase); errors++; } g_object_unref (msg); soup_uri_free (ipv6_uri); soup_test_session_abort_unref (session); soup_test_server_quit_unref (ipv6_server); }
int main (int argc, char **argv) { SoupServer *server; GHashTable *connections; SoupURI *uri; test_init (argc, argv, NULL); server = soup_test_server_new (TRUE); connections = g_hash_table_new (NULL, NULL); soup_server_add_handler (server, NULL, server_callback, connections, NULL); uri = soup_uri_new ("http://127.0.0.1/"); soup_uri_set_port (uri, soup_server_get_port (server)); /* Built-in NTLM auth support. (We set SOUP_NTLM_AUTH_DEBUG to * an empty string to ensure that the built-in support is * being used, even if /usr/bin/ntlm_auth is available.) */ g_setenv ("SOUP_NTLM_AUTH_DEBUG", "", TRUE); debug_printf (1, "Built-in NTLM support\n"); do_ntlm_tests (uri, TRUE); /* Samba winbind /usr/bin/ntlm_auth helper support (via a * helper program that emulate's its interface). */ g_setenv ("SOUP_NTLM_AUTH_DEBUG", BUILDDIR "/ntlm-test-helper", TRUE); debug_printf (1, "\nExternal helper support\n"); do_ntlm_tests (uri, FALSE); /* Support for when ntlm_auth is installed, but the user has * no cached credentials (and thus we have to fall back to * libsoup's built-in NTLM support). */ g_setenv ("SOUP_NTLM_AUTH_DEBUG_NOCREDS", "1", TRUE); debug_printf (1, "\nExternal -> fallback support\n"); do_ntlm_tests (uri, TRUE); soup_uri_free (uri); soup_test_server_quit_unref (server); test_cleanup (); g_hash_table_destroy (connections); return errors != 0; }
static void do_auth_close_test (void) { SoupServer *server; SoupAuthDomain *basic_auth_domain; SoupURI *uri; AuthCloseData acd; debug_printf (1, "\nTesting auth when server times out connection:\n"); server = soup_test_server_new (FALSE); soup_server_add_handler (server, NULL, server_callback, NULL, NULL); uri = soup_uri_new ("http://127.0.0.1/close"); soup_uri_set_port (uri, soup_server_get_port (server)); basic_auth_domain = soup_auth_domain_basic_new ( SOUP_AUTH_DOMAIN_REALM, "auth-test", SOUP_AUTH_DOMAIN_ADD_PATH, "/", SOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK, server_basic_auth_callback, NULL); soup_server_add_auth_domain (server, basic_auth_domain); g_object_unref (basic_auth_domain); g_signal_connect (server, "request-started", G_CALLBACK (auth_close_request_started), NULL); acd.session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); g_signal_connect (acd.session, "authenticate", G_CALLBACK (auth_close_authenticate), &acd); acd.msg = soup_message_new_from_uri ("GET", uri); soup_uri_free (uri); soup_session_send_message (acd.session, acd.msg); if (acd.msg->status_code != SOUP_STATUS_OK) { debug_printf (1, " Final status wrong: expected %u, got %u %s\n", SOUP_STATUS_OK, acd.msg->status_code, acd.msg->reason_phrase); errors++; } g_object_unref (acd.msg); soup_test_session_abort_unref (acd.session); soup_test_server_quit_unref (server); }
int main (int argc, char **argv) { test_init (argc, argv, NULL); server = soup_test_server_new (TRUE); soup_server_add_handler (server, NULL, server_callback, NULL, NULL); base_uri = soup_uri_new ("http://127.0.0.1/"); soup_uri_set_port (base_uri, soup_server_get_port (server)); do_coding_test (); soup_uri_free (base_uri); test_cleanup (); return errors != 0; }
int main (int argc, char **argv) { GMainLoop *loop; int opt; int port = SOUP_ADDRESS_ANY_PORT; g_thread_init (NULL); g_type_init (); signal (SIGINT, quit); while ((opt = getopt (argc, argv, "p:s:")) != -1) { switch (opt) { case 'p': port = atoi (optarg); break; default: fprintf (stderr, "Usage: %s [-p port] [-n]\n", argv[0]); exit (1); } } server = soup_server_new (SOUP_SERVER_PORT, port, NULL); if (!server) { fprintf (stderr, "Unable to bind to server port %d\n", port); exit (1); } soup_server_add_handler (server, NULL, server_callback, NULL, NULL); printf ("\nStarting proxy on port %d\n", soup_server_get_port (server)); soup_server_run_async (server); session = soup_session_async_new (); printf ("\nWaiting for requests...\n"); loop = g_main_loop_new (NULL, TRUE); g_main_loop_run (loop); g_main_loop_unref (loop); return 0; }
TestHttp* test_http_new( GMappedFile* resp_file, const char* resp_content_type, int resp_status) { TestHttp* http = g_new0(TestHttp, 1); http->ref_count = 1; if (resp_file) { http->resp_file = g_mapped_file_ref(resp_file); http->resp_content_type = g_strdup(resp_content_type); } http->resp_status = resp_status; 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); soup_server_run_async(http->server); return http; }
WebKitTestServer::WebKitTestServer(ServerType type) { GUniquePtr<char> sslCertificateFile; GUniquePtr<char> sslKeyFile; if (type == ServerHTTPS) { CString resourcesDir = Test::getResourcesDir(); sslCertificateFile.reset(g_build_filename(resourcesDir.data(), "test-cert.pem", NULL)); sslKeyFile.reset(g_build_filename(resourcesDir.data(), "test-key.pem", NULL)); } GRefPtr<SoupAddress> address = adoptGRef(soup_address_new("127.0.0.1", SOUP_ADDRESS_ANY_PORT)); soup_address_resolve_sync(address.get(), 0); m_soupServer = adoptGRef(soup_server_new(SOUP_SERVER_INTERFACE, address.get(), SOUP_SERVER_SSL_CERT_FILE, sslCertificateFile.get(), SOUP_SERVER_SSL_KEY_FILE, sslKeyFile.get(), nullptr)); m_baseURI = type == ServerHTTPS ? soup_uri_new("https://127.0.0.1/") : soup_uri_new("http://127.0.0.1/"); soup_uri_set_port(m_baseURI, soup_server_get_port(m_soupServer.get())); }