You can look at my example, its not in the best shape but worth looking at.
https://github.com/gorilla3d/Pawalicious/blob/master/admin/item/edit.vala#L55 As a big note libsoup's way of handling Post/Get is horrible. Uploading files and getting the post as well as get parameters is blah. On Sat, Nov 12, 2011 at 11:42 PM, Serge Hulne <[email protected]> wrote: > Thanks a lot ! > > That is just what I neede to get started. > > Thanks, > > Serge. > > > > On Sun, Nov 13, 2011 at 3:02 AM, Alexandre Rosenfeld < > [email protected]> wrote: > >> Couldn't find anything, so I just wrote a small app to do that. Probably >> has a few bugs, but it's only to show the idea. Also pasted at >> http://pastebin.com/6U2JGmuh >> >> >> 1. void default_handler (Soup.Server server, Soup.Message msg, string >> path, >> 2. GLib.HashTable<string,string?>? query, Soup. >> ClientContext client) >> 3. { >> 4. var form_data = query; >> 5. if (msg.method == "POST") { >> 6. msg.request_body.flatten(); >> 7. form_data = Soup.Form.decode((string) msg.request_body.data); >> 8. } >> 9. var user = (form_data != null) ? form_data.get("user") : ""; >> 10. >> 11. var welcome = ""; >> 12. if (user != null) >> 13. welcome = "<p>Welcome %s</p>".printf(user); >> 14. >> 15. var data = new HashTable<string, string>(str_hash, str_equal); >> 16. data.set("$user", user); >> 17. data.set("$welcome", welcome); >> 18. data.set("$path", path); >> 19. >> 20. string response_text = """ >> 21. <html> >> 22. <body> >> 23. <p>Current location: $path</p> >> 24. $welcome >> 25. <form name='input' action='$path' method='get'> >> 26. Name: <input type='text' name='user' value='$user' /> >> 27. <input type='submit' value='Submit GET' /> >> 28. </form> >> 29. <form name='input' action='$path' method='post'> >> 30. Name: <input type='text' name='user' value='$user' /> >> 31. <input type='submit' value='Submit POST'/> >> 32. </form> >> 33. </body> >> 34. </html>"""; >> 35. >> 36. data.foreach((k, v) => { >> 37. response_text = response_text.replace(k, v); >> 38. }); >> 39. >> 40. msg.set_response ("text/html", Soup.MemoryUse.COPY, >> 41. response_text.data); >> 42. } >> 43. >> 44. int main (string[] args) { >> 45. var port = 8088; >> 46. var server = new Soup.Server (Soup.SERVER_PORT, port); >> 47. server.add_handler ("/", default_handler); >> 48. stdout.printf("Serving on http://localhost:%d\n", port); >> 49. server.run (); >> 50. >> 51. return 0; >> 52. } >> >> >> *Alexandre Rosenfeld* >> >> On Sat, Nov 12, 2011 at 21:50, Serge Hulne <[email protected]> wrote: >> >>> Hi, >>> >>> I am looking for a slightly more complete example than the one from the >>> Vala tutorials on "Soup". >>> >>> More particularly, I am looking for a snippet that would show how to get >>> (and possibly decode) the data sent via HTTP from an HTML web form (in a >>> browser) to a (Soup-based) server. >>> >>> Thanks ! >>> >>> Serge. >>> >>> _______________________________________________ >>> vala-list mailing list >>> [email protected] >>> http://mail.gnome.org/mailman/listinfo/vala-list >>> >>> >> > > _______________________________________________ > vala-list mailing list > [email protected] > http://mail.gnome.org/mailman/listinfo/vala-list > > -- Joseph Montanez Web Developer Gorilla3D Design, Develop, Deploy _______________________________________________ vala-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/vala-list
