在检查处理信号“资源请求启动”时提供的数据时,我可以看到发布请求也是通过信号发出的:
static gboolean resourceRequestStartingWebViewCb(
WebKitWebView *web_view,
WebKitWebFrame *web_frame,
WebKitWebResource *web_resource,
WebKitNetworkRequest *request,
WebKitNetworkResponse *response,
gpointer user_data)
{
printf("RESOURCE REQUEST STARTING");
analyzeRequest(request);
return FALSE;
}
但是,发布的数据未通过:
static void analyzeRequest(WebKitNetworkRequest *request)
{
const char* uri=webkit_network_request_get_uri(request);
printf(" for %s.\n",uri);
SoupMessage* soupMessage=NULL;
if(request!=NULL) //REQUEST VALID
{
soupMessage=webkit_network_request_get_message(request);
printf("valid request\n");
}
SoupMessageBody* request_body=NULL;
if(soupMessage!=NULL) //SOUP MESSAGE VALID
{
request_body=soupMessage->request_body;
printf("valid soup message\n");
printf("method: %s\n",soupMessage->method);
}
SoupBuffer* soupBuffer=NULL;
if(request_body!=NULL) //REQUEST BODY VALID
{
//THIS SHOULD LOAD THE POST DATA, NO ???
soupBuffer=soup_message_body_flatten(request_body);
printf("valid request_body\n");
}
const char* requestData=NULL;
gsize requestLength=0;
if(soupBuffer!=NULL) //SOUP BUFFER VALID
{
requestData=soupBuffer->data;
printf("valid soup buffer\n");
requestLength=soupBuffer->length;
printf("length:%d\n",requestLength);
}
if(requestData!=NULL) //REQUEST DATA VALID
{
printf("request data\n%s\n",requestData);
printf("valid request_data\n");
}
}
我可以看到POST方法请求在stdout上飞过,但我似乎无法掌握他们的数据。有人知道如何抓住它吗?谢谢!