--
You received this message because you are subscribed to the Google Groups "The C++ Network Library" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cpp-netlib+...@googlegroups.com.
To post to this group, send email to cpp-n...@googlegroups.com.
Visit this group at http://groups.google.com/group/cpp-netlib.
For more options, visit https://groups.google.com/d/optout.
Thanks Basile (sorry for the delay, I'm based in Sydney, and timezones are hard) -- quick points as I'm prepping for travel to the US this weekend:- See https://github.com/cpp-netlib/cpp-netlib/pull/468 to find an example of how to do this.
<!doctype html>
<html>
<head>
<title>Simple post example</title>
</head>
<body>
Write something:
<form method='POST' action='data'>
<input type='text' name='text'>
<input type='submit' name='send' value='do'>
</form>
</body>
</html>
<!doctype html>
<html>
<head><title>hello</title></head>
<body>
<h1>hello</h1>
Hello, <i>Basile Starynkevitch</i>
</body></html>
On Saturday, March 21, 2015 at 1:52:57 AM UTC+1, Dean Michael Berris wrote:Thanks Basile (sorry for the delay, I'm based in Sydney, and timezones are hard) -- quick points as I'm prepping for travel to the US this weekend:- See https://github.com/cpp-netlib/cpp-netlib/pull/468 to find an example of how to do this.
Thanks for that URL, but I find that example completely opaque and non-understandable for a newbie like me.
To be specific, examples/post of libonion is doing the following:
It starts a web server on e.g. http://localhost:8080/ and when you GET that URL (that is, you issue an HTTP GET request from your browser) the program answers the following content of text/html MIME type
<!doctype html>
<html>
<head>
<title>Simple post example</title>
</head>
<body>
Write something:
<form method='POST' action='data'>
<input type='text' name='text'>
<input type='submit' name='send' value='do'>
</form>
</body>
</html>
The next HTTP request (done from the user's browser) is of course a POST request for http://localhost:8080/data with a body of MIME type application/x-www-form-urlencoded and with content
text=Basile+Starynkevitch&send=do
In my wildest dreams I would want the example to answer the following text/html content:
<!doctype html>
<html>
<head><title>hello</title></head>
<body>
<h1>hello</h1>
Hello, <i>Basile Starynkevitch</i>
</body></html>
Unfortunately, after spending two hours trying various things, I am not able to make something as simple as that working with ccp-netlib. I really believe that you should have more than one single hello_world_server.html in your documentation. It is simply not enough.
BTW, standard C++ <iostream> is also internally a complex template library, but every tutorial gives the std::cout << "hello world" << std::endl; example then the int i; std::cin >> i; example, and the equivalent is missing in cpp-netlib. It would be really nice if the documentation contained a few graduately increasing examples (not just the single hello world one) about HTTP server library in cpp-netlib.
If any cpp-netlib guru could take a few minutes to give such a simple example (which I did not found on the web with Google!), I would be very grateful.
BTW, the stackoverflow Accessing request headers in cpp-netlib http server question stays unanswered since October 2013, and that is IMHO significant. It looks that very few people
are actually using cpp-netlib for HTTP server side.
First, thanks for your feedback Basile -- it's been a while since I've gotten new user feedback this detailed!
--
On Wed, Mar 25, 2015 at 08:31:53PM +0000, 'Dean Michael Berris' via The C++ Network Library wrote:
> You're going to have to parse the incoming body of the request to do that.
> The server doesn't do any pre-parsing for you, because there's other kinds
> of data that can come through in a POST request.
>
I know that, but I believe that HTTP server libraries in C++
are in particular useful for an embedded web server
(either embedded in a device, like most home or small office printers
or wifi routers toda, or embedded in a bigger software, like e.g. CUPS)
In both cases, simple GET or POST requests with a small content
(fitting into memory) are common, and POST requests in
application/x-www-form-urlencoded MIME types are really common
(and they are also used in many AJAX requests).
So I would suggest to have convenience functions and classes
for these common cases (which have simple support both in POCO
and in libonion -for C-).
I don't believe that most usages of cpp-netlib would be to
write Apache, Lighttpd, or Facebook or Google like things.
Obviously, it is a guess and I could be very wrong.