static void do_async_auth_no_password_test (void) { SoupSession *session; SoupMessage *msg; guint auth_id; char *uri; int remaining; gboolean been_there; /* Test that giving no password doesn't cause multiple * authenticate signals the second time. */ g_test_bug ("583462"); SOUP_TEST_SKIP_IF_NO_APACHE; loop = g_main_loop_new (NULL, TRUE); session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); uri = g_strconcat (base_uri, "Basic/realm1/", NULL); remaining = 0; /* Send a message that doesn't actually authenticate */ msg = soup_message_new ("GET", uri); g_object_set_data (G_OBJECT (msg), "id", GINT_TO_POINTER (1)); auth_id = g_signal_connect (session, "authenticate", G_CALLBACK (async_authenticate), NULL); g_object_ref (msg); remaining++; soup_session_queue_message (session, msg, async_finished, &remaining); g_main_loop_run (loop); g_signal_handler_disconnect (session, auth_id); soup_session_unpause_message (session, msg); g_main_loop_run (loop); g_object_unref(msg); /* Now send a second message */ msg = soup_message_new ("GET", uri); g_object_set_data (G_OBJECT (msg), "id", GINT_TO_POINTER (2)); g_object_ref (msg); been_there = FALSE; auth_id = g_signal_connect (session, "authenticate", G_CALLBACK (async_authenticate_assert_once_and_stop), &been_there); remaining++; soup_session_queue_message (session, msg, async_finished, &remaining); g_main_loop_run (loop); soup_session_unpause_message (session, msg); g_main_loop_run (loop); g_signal_handler_disconnect (session, auth_id); soup_test_session_abort_unref (session); g_object_unref (msg); g_free (uri); g_main_loop_unref (loop); }
static void response_callback(GtkDialog *dialog, gint response_id, LuakitAuthData *auth_data) { const gchar *login; const gchar *password; SoupURI *uri; gboolean store_password; switch(response_id) { case GTK_RESPONSE_OK: login = gtk_entry_get_text(GTK_ENTRY(auth_data->login_entry)); password = gtk_entry_get_text(GTK_ENTRY(auth_data->password_entry)); soup_auth_authenticate(auth_data->auth, login, password); store_password = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auth_data->checkbutton)); if (store_password) { uri = soup_message_get_uri(auth_data->msg); luakit_store_password(uri, login, password); } default: break; } soup_session_unpause_message(auth_data->session, auth_data->msg); free_auth_data(auth_data); gtk_widget_destroy(GTK_WIDGET(dialog)); }
static gboolean fully_async_request_chunk (gpointer user_data) { FullyAsyncData *ad = user_data; if (!ad->did_first_timeout) { debug_printf (1, " first timeout\n"); ad->did_first_timeout = TRUE; } else debug_printf (2, " timeout\n"); ad->timeout = 0; /* ad->chunks_ready and ad->chunk_wanted are used because * there's a race condition between the application requesting * the first chunk, and the message reaching a point where * it's actually ready to read chunks. If chunks_ready has * been set, we can just call soup_session_unpause_message() to * cause the first chunk to be read. But if it's not, we just * set chunk_wanted, to let the got_headers handler below know * that a chunk has already been requested. */ if (ad->chunks_ready) soup_session_unpause_message (ad->session, ad->msg); else ad->chunk_wanted = TRUE; return FALSE; }
static void soup_input_stream_prepare_for_io (GInputStream *stream, GCancellable *cancellable, guchar *buffer, gsize count) { SoupInputStreamPrivate *priv = SOUP_INPUT_STREAM_GET_PRIVATE (stream); int cancel_fd; priv->cancellable = cancellable; cancel_fd = g_cancellable_get_fd (cancellable); if (cancel_fd != -1) { GIOChannel *chan = g_io_channel_unix_new (cancel_fd); priv->cancel_watch = soup_add_io_watch (priv->async_context, chan, G_IO_IN | G_IO_ERR | G_IO_HUP, soup_input_stream_cancelled, stream); g_io_channel_unref (chan); } priv->caller_buffer = buffer; priv->caller_bufsize = count; priv->caller_nread = 0; if (priv->got_headers) soup_session_unpause_message (priv->session, priv->msg); }
static void write_next_chunk (SoupMessage *msg, gpointer user_data) { PutTestData *ptd = user_data; debug_printf (2, " writing chunk %d\n", ptd->next); if (ptd->next > 0 && ptd->chunks[ptd->next - 1]) { if (ptd->streaming) { debug_printf (1, " error: next chunk requested before last one freed!\n"); errors++; } else { debug_printf (0, " ignoring bug in test case... FIXME!\n"); } } if (ptd->next < G_N_ELEMENTS (ptd->chunks)) { soup_message_body_append_buffer (msg->request_body, ptd->chunks[ptd->next]); soup_buffer_free (ptd->chunks[ptd->next]); ptd->next++; } else soup_message_body_complete (msg->request_body); soup_session_unpause_message (ptd->session, msg); }
static void got_passwords (SoupPasswordManager *password_manager, SoupMessage *msg, SoupAuth *auth, gboolean retrying, gpointer session) { soup_session_unpause_message (session, msg); SOUP_SESSION_CLASS (soup_session_async_parent_class)-> auth_required (session, msg, auth, retrying); g_object_unref (auth); }
static gboolean auth_close_idle_authenticate (gpointer user_data) { AuthCloseData *acd = user_data; soup_auth_authenticate (acd->auth, "user", "good-basic"); soup_session_unpause_message (acd->session, acd->msg); g_object_unref (acd->auth); return FALSE; }
static void do_async_auth_bad_password_test (void) { SoupSession *session; SoupMessage *msg; guint auth_id; char *uri; SoupAuth *auth = NULL; int remaining; gboolean been_there; /* Test that giving the wrong password doesn't cause multiple * authenticate signals the second time. */ g_test_bug ("522601"); SOUP_TEST_SKIP_IF_NO_APACHE; loop = g_main_loop_new (NULL, TRUE); session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); uri = g_strconcat (base_uri, "Basic/realm1/", NULL); remaining = 0; auth = NULL; msg = soup_message_new ("GET", uri); g_object_set_data (G_OBJECT (msg), "id", GINT_TO_POINTER (1)); auth_id = g_signal_connect (session, "authenticate", G_CALLBACK (async_authenticate), &auth); g_object_ref (msg); remaining++; soup_session_queue_message (session, msg, async_finished, &remaining); g_main_loop_run (loop); g_signal_handler_disconnect (session, auth_id); soup_auth_authenticate (auth, "user1", "wrong"); g_object_unref (auth); soup_session_unpause_message (session, msg); been_there = FALSE; auth_id = g_signal_connect (session, "authenticate", G_CALLBACK (async_authenticate_assert_once), &been_there); g_main_loop_run (loop); g_signal_handler_disconnect (session, auth_id); soup_test_assert (been_there, "authenticate not emitted"); soup_test_session_abort_unref (session); g_object_unref (msg); g_free (uri); g_main_loop_unref (loop); }
static void soup_download_start (GDownloadable *download, gboolean resume) { SoupDownload *soup_download = SOUP_DOWNLOAD (download); if (soup_download->priv->paused) { soup_session_unpause_message (soup_download->priv->session, soup_download->priv->message); } else { if (soup_download->priv->message == NULL) { /* New Download */ soup_download->priv->message = soup_message_new ("GET", download->priv->url); soup_message_connect_signals (soup_download->priv->message, soup_download); } soup_session_queue_message (soup_download->priv->session, soup_download->priv->message, NULL, NULL); } g_downloadable_set_status (G_DOWNLOADABLE(download), G_DOWNLOADABLE_DOWNLOADING); }
void GtkAuthenticationDialog::destroy() { bool shouldDelete = true; soup_session_unpause_message(m_session, m_message.get()); gtk_widget_destroy(m_dialog); #ifdef SOUP_TYPE_PASSWORD_MANAGER shouldDelete = !m_isSavingPassword; #endif // Do not delete the object if it's still saving the password, // the save password callback will delete it. if (shouldDelete) delete this; }
/* Tries to read a chunk. Returns %NULL on error/end-of-response. */ static SoupBuffer * sync_async_read_chunk (SoupMessage *msg) { SyncAsyncData *ad = g_object_get_data (G_OBJECT (msg), "SyncAsyncData"); guint handler; if (sync_async_is_finished (msg)) return NULL; ad->chunk = NULL; handler = g_signal_connect (msg, "got_chunk", G_CALLBACK (sync_async_copy_chunk), ad); soup_session_unpause_message (ad->session, msg); g_main_loop_run (ad->loop); g_signal_handler_disconnect (msg, handler); return ad->chunk; }
static void authentication_dialog_response_cb (GtkWidget* dialog, gint response, KatzeHttpAuthSave* save) { SoupSession* session; SoupMessage* msg; msg = g_object_get_data (G_OBJECT (dialog), "msg"); if (response == GTK_RESPONSE_OK) { GtkEntry* username = g_object_get_data (G_OBJECT (dialog), "username"); GtkEntry* password = g_object_get_data (G_OBJECT (dialog), "password"); GtkToggleButton* remember = g_object_get_data (G_OBJECT (dialog), "remember"); soup_auth_authenticate (save->auth, gtk_entry_get_text (username), gtk_entry_get_text (password)); if (gtk_toggle_button_get_active (remember) && save->http_auth->filename) { save->username = g_strdup (gtk_entry_get_text (username)); save->password = g_strdup (gtk_entry_get_text (password)); g_signal_connect (msg, "got-headers", G_CALLBACK (authentication_message_got_headers_cb), save); } else { g_object_unref (save->auth); g_slice_free (KatzeHttpAuthSave, save); } } session = g_object_get_data (G_OBJECT (dialog), "session"); if (g_object_get_data (G_OBJECT (msg), "paused")) soup_session_unpause_message (session, msg); gtk_widget_destroy (dialog); g_object_unref (msg); }
static void response_callback(GtkDialog* dialog, gint response_id, WebKitAuthData* authData) { gboolean freeAuthData = TRUE; if (response_id == GTK_RESPONSE_OK) { authData->username = g_strdup(gtk_entry_get_text(GTK_ENTRY(authData->loginEntry))); authData->password = g_strdup(gtk_entry_get_text(GTK_ENTRY(authData->passwordEntry))); soup_auth_authenticate(authData->auth, authData->username, authData->password); #ifdef SOUP_TYPE_PASSWORD_MANAGER if (authData->checkButton && gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(authData->checkButton))) { g_signal_connect(authData->msg, "got-headers", G_CALLBACK(save_password_callback), authData); freeAuthData = FALSE; } #endif } soup_session_unpause_message(authData->session, authData->msg); if (freeAuthData) free_authData(authData); gtk_widget_destroy(GTK_WIDGET(dialog)); }
static void gst_soup_http_src_session_unpause_message (GstSoupHTTPSrc * src) { soup_session_unpause_message (src->session, src->msg); }
static void do_async_auth_test (const char *base_uri) { SoupSession *session; SoupMessage *msg1, *msg2, *msg3, msg2_bak; guint auth_id; char *uri; SoupAuth *auth = NULL; int remaining; gboolean been_there; debug_printf (1, "\nTesting async auth:\n"); session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); remaining = 0; uri = g_strconcat (base_uri, "Basic/realm1/", NULL); msg1 = soup_message_new ("GET", uri); g_object_set_data (G_OBJECT (msg1), "id", GINT_TO_POINTER (1)); auth_id = g_signal_connect (session, "authenticate", G_CALLBACK (async_authenticate), &auth); g_object_ref (msg1); remaining++; soup_session_queue_message (session, msg1, async_finished, &remaining); g_main_loop_run (loop); g_signal_handler_disconnect (session, auth_id); /* async_authenticate will pause msg1 and quit loop */ msg2 = soup_message_new ("GET", uri); g_object_set_data (G_OBJECT (msg2), "id", GINT_TO_POINTER (2)); soup_session_send_message (session, msg2); if (msg2->status_code == SOUP_STATUS_UNAUTHORIZED) debug_printf (1, " msg2 failed as expected\n"); else { debug_printf (1, " msg2 got wrong status! (%u)\n", msg2->status_code); errors++; } /* msg2 should be done at this point; assuming everything is * working correctly, the session won't look at it again; we * ensure that if it does, it will crash the test program. */ memcpy (&msg2_bak, msg2, sizeof (SoupMessage)); memset (msg2, 0, sizeof (SoupMessage)); msg3 = soup_message_new ("GET", uri); g_object_set_data (G_OBJECT (msg3), "id", GINT_TO_POINTER (3)); auth_id = g_signal_connect (session, "authenticate", G_CALLBACK (async_authenticate), NULL); g_object_ref (msg3); remaining++; soup_session_queue_message (session, msg3, async_finished, &remaining); g_main_loop_run (loop); g_signal_handler_disconnect (session, auth_id); /* async_authenticate will pause msg3 and quit loop */ /* Now do the auth, and restart */ if (auth) { soup_auth_authenticate (auth, "user1", "realm1"); g_object_unref (auth); soup_session_unpause_message (session, msg1); soup_session_unpause_message (session, msg3); g_main_loop_run (loop); /* async_finished will quit the loop */ } else { debug_printf (1, " msg1 didn't get authenticate signal!\n"); errors++; } if (msg1->status_code == SOUP_STATUS_OK) debug_printf (1, " msg1 succeeded\n"); else { debug_printf (1, " msg1 FAILED! (%u %s)\n", msg1->status_code, msg1->reason_phrase); errors++; } if (msg3->status_code == SOUP_STATUS_OK) debug_printf (1, " msg3 succeeded\n"); else { debug_printf (1, " msg3 FAILED! (%u %s)\n", msg3->status_code, msg3->reason_phrase); errors++; } soup_test_session_abort_unref (session); g_object_unref (msg1); g_object_unref (msg3); memcpy (msg2, &msg2_bak, sizeof (SoupMessage)); g_object_unref (msg2); /* Test that giving the wrong password doesn't cause multiple * authenticate signals the second time. */ debug_printf (1, "\nTesting async auth with wrong password (#522601):\n"); session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); remaining = 0; auth = NULL; msg1 = soup_message_new ("GET", uri); g_object_set_data (G_OBJECT (msg1), "id", GINT_TO_POINTER (1)); auth_id = g_signal_connect (session, "authenticate", G_CALLBACK (async_authenticate), &auth); g_object_ref (msg1); remaining++; soup_session_queue_message (session, msg1, async_finished, &remaining); g_main_loop_run (loop); g_signal_handler_disconnect (session, auth_id); soup_auth_authenticate (auth, "user1", "wrong"); g_object_unref (auth); soup_session_unpause_message (session, msg1); been_there = FALSE; auth_id = g_signal_connect (session, "authenticate", G_CALLBACK (async_authenticate_assert_once), &been_there); g_main_loop_run (loop); g_signal_handler_disconnect (session, auth_id); if (!been_there) { debug_printf (1, " authenticate not emitted?\n"); errors++; } soup_test_session_abort_unref (session); g_object_unref (msg1); /* Test that giving no password doesn't cause multiple * authenticate signals the second time. */ debug_printf (1, "\nTesting async auth with no password (#583462):\n"); session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); remaining = 0; /* Send a message that doesn't actually authenticate */ msg1 = soup_message_new ("GET", uri); g_object_set_data (G_OBJECT (msg1), "id", GINT_TO_POINTER (1)); auth_id = g_signal_connect (session, "authenticate", G_CALLBACK (async_authenticate), NULL); g_object_ref (msg1); remaining++; soup_session_queue_message (session, msg1, async_finished, &remaining); g_main_loop_run (loop); g_signal_handler_disconnect (session, auth_id); soup_session_unpause_message (session, msg1); g_main_loop_run (loop); g_object_unref(msg1); /* Now send a second message */ msg1 = soup_message_new ("GET", uri); g_object_set_data (G_OBJECT (msg1), "id", GINT_TO_POINTER (2)); g_object_ref (msg1); been_there = FALSE; auth_id = g_signal_connect (session, "authenticate", G_CALLBACK (async_authenticate_assert_once_and_stop), &been_there); remaining++; soup_session_queue_message (session, msg1, async_finished, &remaining); g_main_loop_run (loop); soup_session_unpause_message (session, msg1); g_main_loop_run (loop); g_signal_handler_disconnect (session, auth_id); soup_test_session_abort_unref (session); g_object_unref (msg1); g_free (uri); }
static void do_async_auth_good_password_test (void) { SoupSession *session; SoupMessage *msg1, *msg2, *msg3, msg2_bak; guint auth_id; char *uri; SoupAuth *auth = NULL; int remaining; SOUP_TEST_SKIP_IF_NO_APACHE; loop = g_main_loop_new (NULL, TRUE); session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC, NULL); uri = g_strconcat (base_uri, "Basic/realm1/", NULL); remaining = 0; msg1 = soup_message_new ("GET", uri); g_object_set_data (G_OBJECT (msg1), "id", GINT_TO_POINTER (1)); auth_id = g_signal_connect (session, "authenticate", G_CALLBACK (async_authenticate), &auth); g_object_ref (msg1); remaining++; soup_session_queue_message (session, msg1, async_finished, &remaining); g_main_loop_run (loop); g_signal_handler_disconnect (session, auth_id); /* async_authenticate will pause msg1 and quit loop */ msg2 = soup_message_new ("GET", uri); g_object_set_data (G_OBJECT (msg2), "id", GINT_TO_POINTER (2)); soup_session_send_message (session, msg2); soup_test_assert_message_status (msg2, SOUP_STATUS_UNAUTHORIZED); /* msg2 should be done at this point; assuming everything is * working correctly, the session won't look at it again; we * ensure that if it does, it will crash the test program. */ memcpy (&msg2_bak, msg2, sizeof (SoupMessage)); memset (msg2, 0, sizeof (SoupMessage)); msg3 = soup_message_new ("GET", uri); g_object_set_data (G_OBJECT (msg3), "id", GINT_TO_POINTER (3)); auth_id = g_signal_connect (session, "authenticate", G_CALLBACK (async_authenticate), NULL); g_object_ref (msg3); remaining++; soup_session_queue_message (session, msg3, async_finished, &remaining); g_main_loop_run (loop); g_signal_handler_disconnect (session, auth_id); /* async_authenticate will pause msg3 and quit loop */ /* Now do the auth, and restart */ if (auth) { soup_auth_authenticate (auth, "user1", "realm1"); g_object_unref (auth); soup_session_unpause_message (session, msg1); soup_session_unpause_message (session, msg3); g_main_loop_run (loop); /* async_finished will quit the loop */ } else soup_test_assert (auth, "msg1 didn't get authenticate signal"); soup_test_assert_message_status (msg1, SOUP_STATUS_OK); soup_test_assert_message_status (msg3, SOUP_STATUS_OK); soup_test_session_abort_unref (session); g_object_unref (msg1); g_object_unref (msg3); memcpy (msg2, &msg2_bak, sizeof (SoupMessage)); g_object_unref (msg2); g_free (uri); g_main_loop_unref (loop); }