Как получить данные в header в http и данные, которые отправляются мне методом post? [webkit2gtk]
Подключил обработчик к webkit_web_view по сигналу submit-form. хотел получить данные заголовка http, но я не нашел простого способа. я попробовал в этой же функции получить эти заголовки, но не работает.
/* * hcareer - программа test * * Copyright (C) 2020 Naidolinsky Dmitry * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY of FITNESS for A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * -------------------------------------------------------------------/ */
#include <stdio.h>
#include <signal.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <gtk/gtk.h>
#include <json-c/json.h>
#include <canberra-gtk.h>
#include <webkit2/webkit2.h>
#include <math.h>
#include "sql.h"
GtkApplication *app;
GtkWidget *window;
GtkWidget *web_view;
char *config_dir;
char *config_file;
char *config_db;
char *config_file_error;
GNotification *notify;
static gboolean window_delete_event_cb ( GtkWidget *widget, GdkEvent *event, gpointer data ) {
gtk_widget_hide ( widget );
return TRUE;
}
static void ai_show_window ( GtkMenuItem *item, gpointer data ) {
gtk_widget_show_all ( window );
}
static void ai_exit_program ( GtkMenuItem *item, gpointer data ) {
g_application_quit ( ( GApplication * ) app );
exit ( EXIT_SUCCESS );
}
const char *uri = "https://career.habr.com/integrations/oauth/authorize?client_id={id приложения}&redirect_uri=https://api.moikrug.ru&response_type=code";
static gboolean web_view_user_message_received_cb ( WebKitWebView *view, WebKitUserMessage *message, gpointer data ) {
printf ( "web_view_user_message_received_cb\n" );
return TRUE;
}
static void handler_soup ( const char *name, const char *value, gpointer data ) {
printf ( "%s: %s\n", name, value );
}
static void web_view_submit_form_cb ( WebKitWebView *webview, WebKitFormSubmissionRequest *request, gpointer data ) {
printf ( "web_view_submit_form_cb\n" );
}
static void web_view_resource_load_started_cb ( WebKitWebView *webview, WebKitWebResource *resource, WebKitURIRequest *request, gpointer data ) {
printf ( "web_view_resource_load_started_cb\n" );
const char *n_uri = webkit_web_view_get_uri ( webview );
WebKitDownload *wd = webkit_web_view_download_uri ( webview, n_uri );
if ( !wd ) printf ( "wd error\n" );
WebKitURIResponse *wer = webkit_download_get_response ( wd );
if ( wer ) {
SoupMessageHeaders *h = webkit_uri_response_get_http_headers ( wer );
if ( !h ) printf ( "h error\n" );
soup_message_headers_foreach ( h, handler_soup, NULL );
}
}
static void g_startup_cb ( GtkApplication *app, gpointer data ) {
GMainLoop *loop = g_main_loop_new ( NULL, FALSE );
window = gtk_application_window_new ( app );
gtk_window_set_default_size ( ( GtkWindow * ) window, 1024, 600 );
web_view = webkit_web_view_new ( );
webkit_web_view_load_uri ( ( WebKitWebView * ) web_view, uri );
g_signal_connect ( web_view, "user-message-received", G_CALLBACK ( web_view_user_message_received_cb ), NULL );
g_signal_connect ( web_view, "submit-form", G_CALLBACK ( web_view_submit_form_cb ), NULL );
g_signal_connect ( web_view, "resource-load-started", G_CALLBACK ( web_view_resource_load_started_cb ), NULL );
gtk_container_add ( ( GtkContainer * ) window, web_view );
gtk_widget_show_all ( window );
g_main_loop_run ( loop );
}
int main ( int argc, char **argv ) {
app = gtk_application_new ( "com.xverizex.hcareer", G_APPLICATION_FLAGS_NONE );
g_application_register ( ( GApplication * ) app, NULL, NULL );
g_signal_connect ( app, "activate", G_CALLBACK ( g_startup_cb ), NULL );
return g_application_run ( ( GApplication * ) app, argc, argv );
}