Skip to content

Commit 84dd2cc

Browse files
committed
Updated documentation.
1 parent dedf276 commit 84dd2cc

18 files changed

+232
-151
lines changed

README.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,9 @@ you will need. These are:
105105
* A build tool (CMake [#]_ recommended, Boost.Build also an option)
106106
* OpenSSL headers (optional)
107107

108-
.. note:: This assumes that you have the cpp-netlib distribution package
109-
unpacked somwhere in your home directory. This specifically assumes that you
110-
have cpp-netlib at the toplevel of your home directory.
111-
.. [#] http://www.cmake.org/
108+
.. note:: This assumes that you have cpp-netlib at the top-level of
109+
your home directory.
110+
[#] http://www.cmake.org/
112111

113112
Hacking on cpp-netlib
114113
---------------------

libs/network/doc/atom_reader.rst

+36-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,44 @@
44
Atom reader
55
*************
66

7-
The Code
7+
The code
88
========
99

10+
.. code-block:: c++
1011

11-
Building and Running The Code
12-
=============================
12+
#include "atom.hpp"
13+
#include <boost/network/protocol/http/client.hpp>
14+
#include <boost/foreach.hpp>
15+
#include <iostream>
1316

14-
Diving into the Code
17+
int main(int argc, char * argv[]) {
18+
using namespace boost::network;
19+
20+
if (argc != 2) {
21+
std::cout << "Usage: " << argv[0] << " <url>" << std::endl;
22+
return 1;
23+
}
24+
25+
try {
26+
http::client client;
27+
http::client::request request(argv[1]);
28+
request << header("Connection", "close");
29+
http::client::response response = client.get(request);
30+
atom::feed feed(response);
31+
32+
std::cout << "Feed: " << feed.title()
33+
<< " (" << feed.subtitle() << ")" << std::endl;
34+
BOOST_FOREACH(const atom::entry &entry, feed) {
35+
std::cout << entry.title()
36+
<< " (" << entry.published() << ")" << std::endl;
37+
}
38+
}
39+
catch (std::exception &e) {
40+
std::cerr << e.what() << std::endl;
41+
}
42+
43+
return 0;
44+
}
45+
46+
Diving into the code
1547
====================

libs/network/doc/examples_http.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ embedded into larger applications.
88
.. toctree::
99
:maxdepth: 2
1010

11-
http_client.rst
11+
simple_wget.rst
1212
hello_world_server.rst
1313
hello_world_client.rst
14-
simple_wget.rst
14+
fileserver.rst
1515
atom_reader.rst
1616
rss_reader.rst
1717
twitter_search.rst

libs/network/doc/fileserver.rst

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.. _fileserver_http:
2+
3+
*******************
4+
Fileserver (HTTP)
5+
*******************
6+
7+
The code
8+
========
9+
10+
Diving into the code
11+
====================

libs/network/doc/getting_started.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Building On Windows
158158
If you're using the Microsoft Visual C++ compiler or the Microsoft Visual Studio
159159
IDE and you would like to build cpp-netlib from within Visual Studio, you can
160160
look for the solution and project files as the artifacts of the call to
161-
``cmake`` -- the file should be named ``cpp-netlib.sln`` (the solution) along
161+
``cmake`` -- the file should be named ``CPP-NETLIB.sln`` (the solution) along
162162
with a number of project files for Visual Studio.
163163

164164
Reporting Issues, Getting Support
@@ -173,5 +173,5 @@ for the project at http://github.com/cpp-netlib/cpp-netlib/issues.
173173

174174
You can also opt to join the developers mailing list for a more personal
175175
interaction with the developers of the project. You can join the mailing list
176-
through https://groups.google.com/group/cpp-netlib.
176+
through http://groups.google.com/forum/#!forum/cpp-netlib.
177177

libs/network/doc/hello_world_client.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Just like with the HTTP Server and HTTP client example before, we can build this
5151
example by doing the following on the shell:
5252

5353
.. code-block:: bash
54-
54+
5555
$ cd ~/cpp-netlib
5656
$ g++ -o hello_world_client \
5757
> libs/network/example/http/hello_world_client.cpp \
@@ -70,7 +70,7 @@ This example can be run from the command line as follows:
7070
.. note:: This assumes that you have the ``hello_world_server`` running on
7171
localhost port 8000.
7272

73-
Diving into the Code
73+
Diving into the code
7474
====================
7575

7676
All this example shows is how easy it is to write an HTTP client that connects
@@ -92,7 +92,7 @@ perform the request via HTTP:
9292

9393
http::client client;
9494
http::client::request request("http://my.webservice.com/");
95-
http::client::response =
95+
http::client::response =
9696
client.post(request, "application/xml", some_xml_string);
9797
std::data = body(response);
9898

libs/network/doc/hello_world_server.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ simple response to any HTTP request.
5959

6060
This is about a straightforward as server programming will get in C++.
6161

62-
Building the Server
62+
Building the server
6363
===================
6464

6565
Just like with the HTTP client, we can build this example by doing the following
@@ -86,7 +86,7 @@ a command line as follows:
8686
.. note:: If you're going to run the server on port 80, you may have to run it
8787
as an administrator.
8888

89-
Diving into the Code
89+
Diving into the code
9090
====================
9191

9292
Let's take a look at the code listing above in greater detail.

libs/network/doc/index.rst

-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ Contents
123123
in_depth.rst
124124
techniques.rst
125125
history.rst
126-
install.rst
127126
reference.rst
128127
references.rst
129128

libs/network/doc/install.rst

-2
This file was deleted.

libs/network/doc/reference_http_server.rst

+9-9
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Handler function object.
3535
There are two different Handler concepts, one concept for `Synchronous Servers`_
3636
and another for `Asynchronous Servers`.
3737

38-
The SynchronusHandler concept for `Synchronous Servers`_ is described by the
38+
The SynchronousHandler concept for `Synchronous Servers`_ is described by the
3939
following table:
4040

4141
---------------
@@ -145,7 +145,7 @@ API Documentation
145145
The following sections assume that the following file has been included:
146146

147147
.. code-block:: c++
148-
148+
149149
#include <boost/network/include/http/server.hpp>
150150

151151
And that the following typedef's have been put in place:
@@ -226,14 +226,14 @@ Constructor
226226
To use the above supported named parameters, you'll have code that looks like the following:
227227

228228
.. code-block:: c++
229-
229+
230230
using namespace boost::network::http; // parameters are in this namespace
231231
boost::asio::io_service my_io_service;
232232
boost::network::utils::thread_pool pool(2);
233233
handler handler_instance;
234234
async_server<handler> instance(_address="0.0.0.0", _port="80", _handler=handler_instance,
235235
_io_service=my_io_service, _thread_pool=pool,
236-
_reuse_address=true);
236+
_reuse_address=true);
237237
instance.run();
238238

239239
Public Members
@@ -270,8 +270,8 @@ helpful in certain simple situations.
270270

271271
``response = http_server::response::stock_reply(status, body)``
272272
Code like the above should go inside the handler's ``operator()`` overload.
273-
The body parameter is an ``std::string``. The status parameter is any of
274-
the following values from the ``http_server::response`` enum
273+
The body parameter is an ``std::string``. The status parameter is any of
274+
the following values from the ``http_server::response`` enum
275275
``status_type``:
276276

277277
.. code-block:: c++
@@ -313,7 +313,7 @@ which can be directly manipulated by the handler.
313313
.. [#] A header is a struct of type
314314
``response_header<http::tags::http_server>``. An instance always has the
315315
members ``name`` and ``value`` both of which are of type ``string_type``.
316-
.. [#] ``string_type`` is
316+
.. [#] ``string_type`` is
317317
``boost::network::string<http::tags::http_server>::type``.
318318
319319
Asynchronous Servers
@@ -358,7 +358,7 @@ synchronous server implementation.
358358
The general pattern for using the ``async_server`` template is shown below:
359359

360360
.. code-block:: c++
361-
361+
362362
struct handler;
363363
typedef boost::network::http::async_server<handler> http_server;
364364

@@ -367,7 +367,7 @@ The general pattern for using the ``async_server`` template is shown below:
367367
http_server::request const & req,
368368
http_server::connection_ptr connection
369369
) {
370-
// handle the request here, and use the connection to
370+
// handle the request here, and use the connection to
371371
// either read more data or write data out to the client
372372
}
373373
};

libs/network/doc/references.rst

+2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ Other sources
1414
* `HTTP 1.0`_: The HTTP 1.0 specification.
1515
* `HTTP 1.1 (RFC 2616)`_: The HTTP 1.1 specification.
1616
* `URI Generic Syntax (RFC 3986)`_: Generic URI syntax specification.
17+
* `Format for Literal IPv6 Addresses in URLs (RFC 2732)`_: Literal IPv6 Addresses in URLs.
1718

1819
.. _`BoostCon 2010 Slides`: http://www.filetolink.com/b0e89d06
1920
.. _`BoostCon 2010 Paper`: http://github.com/downloads/mikhailberis/cpp-netlib-boostcon-paper/cpp-netlib.pdf
2021
.. _`Template Metaprogramming`: http://www.boostpro.com/mplbook/
2122
.. _`HTTP 1.0`: http://www.w3.org/Protocols/HTTP/1.0/spec.html
2223
.. _`HTTP 1.1 (RFC 2616)`: http://www.w3.org/Protocols/rfc2616/rfc2616.html
2324
.. _`URI Generic Syntax (RFC 3986)`: http://www.ietf.org/rfc/rfc3986.txt
25+
.. _`Format for Literal IPv6 Addresses in URLs (RFC 2732)`: http://www.ietf.org/rfc/rfc2732.txt

libs/network/doc/rss_reader.rst

+34-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,41 @@
44
RSS reader
55
************
66

7-
The Code
8-
========
7+
.. code-block:: c++
98

9+
#include "rss.hpp"
10+
#include <boost/network/protocol/http/client.hpp>
11+
#include <boost/foreach.hpp>
12+
#include <iostream>
1013

11-
Building and Running The Code
12-
=============================
14+
int main(int argc, char * argv[]) {
15+
using namespace boost::network;
1316

14-
Diving into the Code
17+
if (argc != 2) {
18+
std::cout << "Usage: " << argv[0] << " <url>" << std::endl;
19+
return 1;
20+
}
21+
22+
try {
23+
http::client client;
24+
http::client::request request(argv[1]);
25+
request << header("Connection", "close");
26+
http::client::response response = client.get(request);
27+
rss::channel channel(response);
28+
29+
std::cout << "Channel: " << channel.title()
30+
<< " (" << channel.description() << ")" << std::endl;
31+
BOOST_FOREACH(const rss::item &item, channel) {
32+
std::cout << item.title()
33+
<< " (" << item.author() << ")" << std::endl;
34+
}
35+
}
36+
catch (std::exception &e) {
37+
std::cerr << e.what() << std::endl;
38+
}
39+
40+
return 0;
41+
}
42+
43+
Diving into the code
1544
====================

0 commit comments

Comments
 (0)