can't send data using post method

wkt55555 wkt55555 at 163.com
Sun Nov 21 12:19:46 UTC 2010


Hi,to all
I try to wirte a program using webkit/gtk but It do not work !Please help !
the program is like this:
#include <gtk/gtk.h>
#include <webkit/webkit.h>
#include <libsoup/soup.h>
#include <string.h>


const gchar *uri = "http://127.0.0.1/cgi-bin/cgi_get";
const char  *postdata = "Hi,I'm PostData";


void
soup_message_request_print(SoupMessage *sm)
{
SoupBuffer *sbf = NULL;
sbf = soup_message_body_flatten(sm->request_body);
g_warning("request_body->length:\n%llu\nend_length",sm->request_body->length);
g_warning("request_body->data:\n%s\nend_data",sm->request_body->data);
g_warning("flatten:\n%s\nend_faltten",sbf->data);
soup_buffer_free(sbf);
}


int main(int argc,char **argv)
{
GtkWidget *webkit;
GtkWidget *window;
GtkWidget *scroll;
WebKitNetworkRequest *nr;
SoupMessage *sm;


g_thread_init(NULL);
    gtk_init(&argc,&argv);


webkit = webkit_web_view_new ();
scroll = gtk_scrolled_window_new(NULL,NULL);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);


gtk_container_add(GTK_CONTAINER(scroll),webkit);
gtk_container_add(GTK_CONTAINER(window),scroll);


    sm =  soup_form_request_new (SOUP_METHOD_POST, uri,
                             "accountType", "HOSTED_OR_GOOGLE",
                             "Email", "username",
                             "Passwd", "password",
                             "service", "blogger",
                             "source", "GNOME-Drivel-VERSION",
                             NULL);




nr = WEBKIT_NETWORK_REQUEST(g_object_new(WEBKIT_TYPE_NETWORK_REQUEST, "message", sm, NULL));


soup_message_set_request (sm,
"text/html;charset=utf8",
SOUP_MEMORY_COPY,
postdata,
                    (gsize)strlen(postdata));


webkit_web_view_load_request(WEBKIT_WEB_VIEW(webkit),nr);
soup_message_request_print(sm);
gtk_window_resize(GTK_WINDOW(window),400,450);
gtk_widget_show_all(window);
g_signal_connect(window,"destroy",G_CALLBACK(gtk_main_quit),NULL);
gtk_main();
return 0;
}
///program code end
the cgi_get is:
#!/bin/bash
str=$(set|sed 's/$/\<br\>/g')


if [ "$REQUEST_METHOD" == "POST" ];then
str1="<b>YOU Post me :<br><I>
<font color=#FF0000 size=10>$(cat)</font>
</I><br>Post end<br></b>"
fi


cat <<lllllll >/tmp/jjj.h
Content-Type: text/html; charset=UTF8


<html>
<head>
<meta http-equiv=Content-Type content="text/html;charset=utf8">
<body>
${str1}
${str}
</body>
</html>
lllllll
chmod a+r /tmp/jjj.h
cat /tmp/jjj.h
###end cgi_get




--

--------weiketing------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-webkit-maintainers/attachments/20101121/374a7da4/attachment.htm>


More information about the Pkg-webkit-maintainers mailing list