I'm trying to write a Gnome program in Javascript. HTTP requests are done with a library called Soup, and GET requests start with something like:

msg = Soup.Message.new('GET', self.url) ...

Examples for GET requests are all over the net, but how to do a POST request?

有帮助吗?

解决方案

Based on our chat conversation, this code will work:

msg = Soup.Message.new('POST', self.url);
var POSTparams = 'try=this';
msg.set_request ('application/x-www-form-urlencoded', 2, POSTparams, POSTparams.length);

The syntax seems to be:

msg.set_request('MIME type', (2), 'params=here', 'params=here'.length);

This answer was also based on the following:

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top