static void tunnel_message_completed (SoupMessage *msg, gpointer user_data) { SoupMessageQueueItem *item = user_data; SoupSession *session = item->session; if (item->state == SOUP_MESSAGE_RESTARTING) { soup_message_restarted (msg); if (item->conn) { soup_session_send_queue_item (session, item, tunnel_message_completed); return; } soup_message_set_status (msg, SOUP_STATUS_TRY_AGAIN); } item->state = SOUP_MESSAGE_FINISHED; if (!SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { if (item->conn) soup_connection_disconnect (item->conn); if (msg->status_code == SOUP_STATUS_TRY_AGAIN) { item->related->state = SOUP_MESSAGE_AWAITING_CONNECTION; g_object_unref (item->related->conn); item->related->conn = NULL; } else soup_message_set_status (item->related->msg, msg->status_code); goto done; } if (!soup_connection_start_ssl (item->conn)) { if (item->conn) soup_connection_disconnect (item->conn); soup_message_set_status (item->related->msg, SOUP_STATUS_SSL_FAILED); goto done; } g_signal_connect (item->conn, "disconnected", G_CALLBACK (connection_closed), item->session); soup_connection_set_state (item->conn, SOUP_CONNECTION_IDLE); soup_connection_set_state (item->conn, SOUP_CONNECTION_IN_USE); item->related->state = SOUP_MESSAGE_READY; done: soup_message_finished (msg); if (item->related->msg->status_code) item->related->state = SOUP_MESSAGE_FINISHING; do_idle_run_queue (item->session); soup_message_queue_item_unref (item->related); soup_session_unqueue_item (session, item); soup_message_queue_item_unref (item); g_object_unref (session); }
static void soup_message_io_finished (SoupMessage *msg) { g_object_ref (msg); soup_message_io_cleanup (msg); if (SOUP_MESSAGE_IS_STARTING (msg)) soup_message_restarted (msg); else soup_message_finished (msg); g_object_unref (msg); }
static void process_queue_item (SoupMessageQueueItem *item, gboolean *should_prune, gboolean loop) { SoupSession *session = item->session; SoupProxyURIResolver *proxy_resolver; do { switch (item->state) { case SOUP_MESSAGE_STARTING: proxy_resolver = (SoupProxyURIResolver *)soup_session_get_feature_for_message (session, SOUP_TYPE_PROXY_URI_RESOLVER, item->msg); if (!proxy_resolver) { item->state = SOUP_MESSAGE_AWAITING_CONNECTION; break; } resolve_proxy_addr (item, proxy_resolver); return; case SOUP_MESSAGE_AWAITING_CONNECTION: if (!soup_session_get_connection (session, item, should_prune)) return; if (soup_connection_get_state (item->conn) != SOUP_CONNECTION_NEW) { item->state = SOUP_MESSAGE_READY; break; } item->state = SOUP_MESSAGE_CONNECTING; soup_message_queue_item_ref (item); g_object_ref (session); soup_connection_connect_async (item->conn, item->cancellable, got_connection, item); return; case SOUP_MESSAGE_READY: item->state = SOUP_MESSAGE_RUNNING; soup_session_send_queue_item (session, item, message_completed); break; case SOUP_MESSAGE_RESTARTING: item->state = SOUP_MESSAGE_STARTING; soup_message_restarted (item->msg); break; case SOUP_MESSAGE_FINISHING: item->state = SOUP_MESSAGE_FINISHED; soup_message_finished (item->msg); if (item->state != SOUP_MESSAGE_FINISHED) break; g_object_ref (session); soup_session_unqueue_item (session, item); if (item->callback) item->callback (session, item->msg, item->callback_data); g_object_unref (item->msg); do_idle_run_queue (session); g_object_unref (session); return; default: /* Nothing to do with this message in any * other state. */ return; } } while (loop && item->state != SOUP_MESSAGE_FINISHED); }