Commit Graph

1309 Commits

Author SHA1 Message Date
Vinnie Falco
b9b1b53fda Fix race in pings during reads 2017-07-20 08:12:15 -07:00
Florian Behrens
8a1c7545e4 Fix doc link typo 2017-07-20 08:12:15 -07:00
Nik Bougalis
69f95c870b Check ostream modifier correctly 2017-07-20 08:12:15 -07:00
Steve Brain
c82cc218e1 Fix Writer return value documentation 2017-07-20 08:12:15 -07:00
Vinnie Falco
8fe07212f1 Document type-pun in buffer_cat 2017-07-20 08:12:15 -07:00
Vinnie Falco
e224d64949 Fix illegal HTTP characters accepted as hex zero 2017-07-20 08:12:15 -07:00
Vinnie Falco
f3a87a745e Fix Body requirements doc 2017-07-20 08:12:15 -07:00
Vinnie Falco
5e7780bbd9 Fix compilation error in non-template class
fix #267
2017-07-20 08:12:15 -07:00
Vinnie Falco
d735aa949e Fix race in writes during reads:
fix #261

This fixes a rare condition when responding to a ping or
close frame where the wr_block_ stream variable is not
correctly set for a short window of time.
2017-07-20 08:12:15 -07:00
Vinnie Falco
2b799b6371 Fix HTTP split parse edge case:
fix #257

This fixes a problem when doing split parsing (header then body).
The problem arises when the first buffer passed to the header
parser contains exactly the full header and nothing more. The
symptom is that when parsing the body, the parse will erroneously
be considered complete.
2017-07-20 08:12:15 -07:00
Vinnie Falco
dbfb7718fc Restyle async result constructions 2017-07-20 08:12:15 -07:00
Vinnie Falco
1f52f4a791 Split out and rename test stream classes 2017-07-20 08:12:15 -07:00
wilsonianb
04a0c9d91d Add documentation building instructions 2017-07-20 08:12:14 -07:00
Vinnie Falco
51aa614a10 Tidy up tests and docs:
* Add handler_ptr test and increase coverage
* Add test for prepare_buffer
* Move is_call_possible tests to a .cpp file
* Tidy up docs and declarations
2017-07-20 08:12:14 -07:00
Vinnie Falco
7ef72b6ebc Move basic_streambuf to streambuf.hpp (API Change):
* Also change allocator element type to char
2017-07-20 08:12:14 -07:00
Vinnie Falco
765cb22b48 Invoke callback on pings and pongs (API Change):
fix #248

This additionally invokes the pong callback for received pings, allowing
callers to more efficiently detect when a connection is still lively:

* pong_callback renamed to ping_callback
* Callback signature has an extra `bool` to indicate if the received
  control frame is a ping or pong.
2017-07-20 08:12:14 -07:00
Vinnie Falco
615e80dacd Tidy up warnings and tests:
* Enable WebSocket frame tests
* Remove read_message_max warning
* Remove permessage-deflate check offer warning
2017-07-20 08:12:14 -07:00
Vinnie Falco
e79f923c03 Fix deflate setup bug 2017-07-20 08:12:14 -07:00
Vinnie Falco
812271a782 WebSocket server examples and test tidying:
fix #238, fix #165

* Tidy up WebSocket echo servers
* Add WebSocket echo servers to examples
2017-07-20 08:12:14 -07:00
Vinnie Falco
47068de6ce Remove unnecessary include
fix #242
2017-07-20 08:12:14 -07:00
Vinnie Falco
8ea120f13f Fix 32-bit arm7 warnings
fix #232
2017-07-20 08:12:14 -07:00
Vinnie Falco
d7e9a7ca3c Better handler_ptr (API Change):
fix #242

* Add public constructors
* Add handler_ptr::empty()
* Add handler_ptr::element_type
* Remove make_handler_ptr free function
* Compiler error if element_type is an array type
* handler_ptr::get() returns nullptr if no object is owned
2017-07-20 08:12:14 -07:00
Vinnie Falco
e81a2864ab Fixes for websocket echo server:
* Decorator members are const
* Enable permessage-deflate extension
2017-07-20 08:12:14 -07:00
Vinnie Falco
911617c43f Add permessage-deflate WebSocket extension:
This implements the permessage-deflate WebSocket
extension as described in HyBi Working Group
draft-ietf-hybi-permessage-compression-28:
https://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-28

This extension allows messages to be compressed using
the raw "deflate" algorithm described in RFC 1951,
"DEFLATE Compressed Data Format Specification version 1.3":
https://www.ietf.org/rfc/rfc1951.txt
2017-07-20 08:12:14 -07:00
Vinnie Falco
99706347cd Make decorator copyable 2017-07-20 08:12:14 -07:00
Vinnie Falco
c594bbac3f Add optional yield_to arguments 2017-07-20 08:12:14 -07:00
Edward Hennis
6840f5840f Simplify Travis package install specification 2017-07-20 08:12:14 -07:00
Miguel Portilla
896b462c1f bjam use clang on MACOSX 2017-07-20 08:12:14 -07:00
Vinnie Falco
133d926e2f Fix message constructor and special members
fix #196
2017-07-20 08:12:14 -07:00
Vinnie Falco
93e58f7dab Update documentation examples
fix #222
2017-07-20 08:12:14 -07:00
Vinnie Falco
606ad187ba Disable Boost.Coroutine deprecation warning 2017-07-20 08:12:14 -07:00
Vinnie Falco
ffe2e8e02b Avoid copies in handler_alloc 2017-07-20 08:12:14 -07:00
Vinnie Falco
4ab2b5e5e7 Add handler helpers 2017-07-20 08:12:14 -07:00
Vinnie Falco
01e1fa2dc9 Implement asio dealloc-before-invoke guarantee:
fix #215

This change guarantees that temporary memory allocated
through the asio hooks by the Beast implementation is
deallocated before invoking the final handler when performing
composed operations.

The change is accomplished by replacing std::shared_ptr with
a thread-safe custom container handler_ptr to manage composed
operation state. The container tracks other instances which
manage the same object and resets them in a safe way before
invoking the final handler.

handler_ptr is provided as a public interface so that users of
this library can utilize the same idiom to write their own
composed operations.
2017-07-20 08:12:14 -07:00
Vinnie Falco
f70ac4cb86 Fix broken Intellisense (MSVC)
Fix #213
2017-07-20 08:12:14 -07:00
Vinnie Falco
5089cf59ee Add zlib module:
The zlib module is a port of ZLib's raw deflate
algorithm to header-only C++11.
2017-07-20 08:12:14 -07:00
Vinnie Falco
e3848e7281 Refactor HTTP identifier names (API Change):
fix #171

Several names and  HTTP identifiers are renamed to be
more consistent, self-explanatory, and concise:

* "Fields" is a collection of HTTP header fields (rfc7230 section 3.2)
* "Header" is the Start Line plus Fields. Another way to look at it is,
  the HTTP message minus the body.
* `basic_fields` replaces `basic_headers`
* `fields` replaces `headers`
* `Fields` replaces `Headers` in template parameter lists
* `header` replaces `message_headers`
* `header::fields` replaces `message_headers::fields`

The changes are cosmetic and do not affect run-time behavior.
2017-07-20 08:12:13 -07:00
Vinnie Falco
be67224390 Better buffer_cat:
buffer_cat now determines if all of the buffer sequences in
the list of passed buffer sequences each have value types which
are convertible to mutable_buffer. The returned concatenated
sequence will be a MutableBufferSequence if all the passed
buffer sequences meet the requirements of MutableBufferSequence,
else the returned concatenated sequence will be a ConstBufferSequence.
2017-07-20 08:12:13 -07:00
Vinnie Falco
6afa6afc98 Fix consuming_buffers value_type (API Change):
This fixes a bug where instantiations of consuming_buffers with
buffer sequence types whose value_type is not const_buffer or
mutable_buffer can cause compilation errors.

The function consumed_buffers is removed.
2017-07-20 08:12:13 -07:00
Vinnie Falco
8f535ba74f prepared_buffers is private (API Change) 2017-07-20 08:12:13 -07:00
Vinnie Falco
08d8a2ae35 Fix prepare_buffers value_type:
This fixes a bug where calling prepare_buffers on a buffer
sequence whose value_type is not const_buffer or mutable_buffer
causes compilation errors.

The documentation is also tidied up.
2017-07-20 08:12:13 -07:00
Vinnie Falco
aa8e7432c2 Use boost::lexical_cast instead of std::to_string
fix #176
2017-07-20 08:12:13 -07:00
Vinnie Falco
2a50915322 Fix with_body example:
fix #177
2017-07-20 08:12:13 -07:00
Vinnie Falco
5b041193f2 Increase code coverage 2017-07-20 08:12:13 -07:00
Vinnie Falco
6d2195514d Boost library min/max guidance:
fix #170
2017-07-20 08:12:13 -07:00
Vinnie Falco
1eb673dd7d Add read, async_read for message_headers:
fix #172, fix #173

This provides overloads of read and async_read to allow
reading message_headers objects.
2017-07-20 08:12:13 -07:00
Vinnie Falco
8035dac88c Add write, async_write, operator<< for message_headers:
fix #155

This adds overloads of write, async_write, and operator<<
for message_headers.
2017-07-20 08:12:13 -07:00
Vinnie Falco
f98ec17121 Make chunk_encode public:
fix #154, fix #156

This adds public interfaces for transforming buffer
sequences into their chunk-encoded equivalents. The
transformations are O(1) in space and time.
2017-07-20 08:12:13 -07:00
Vinnie Falco
50bc9a58cd Refactor message and message_headers declarations:
message_headers is now a set of partial class template
specializations instead of a template class alias. This solves
a problem where template functions taking message_headers as a
parameter could not deduce argument types, since std::conditional
obscured the deduced context.

Both classes are refactored to share declarations using an #ifdef,
to eliminate an ugly set of extra declarations needed when building
the documentation.

Copy and move class special members are added.

A new function message::base() is provided which returns the
message_headers portion of a message.
2017-07-20 08:12:13 -07:00
Vinnie Falco
312bd6b21d Optimize mask operations 2017-07-20 08:12:13 -07:00
Miguel Portilla
d91fbd0611 Optimize utf8 validation 2017-07-20 08:12:13 -07:00
Vinnie Falco
f904759877 Add websocket::stream pong and async_pong 2017-07-20 08:12:13 -07:00
Vinnie Falco
f56d4fe74b Close connection during async_read on close frame:
fix #163
2017-07-20 08:12:13 -07:00
Vinnie Falco
a878165e36 Fix write_frame masking and auto-fragment handling 2017-07-20 08:12:13 -07:00
Vinnie Falco
dfb2d05be3 Write buffer option does not change capacity 2017-07-20 08:12:13 -07:00
Vinnie Falco
74e77682c7 Meet DynamicBuffer requirements for static_streambuf 2017-07-20 08:12:13 -07:00
Vinnie Falco
c75992a4af Higher optimization settings for MSVC builds 2017-07-20 08:12:13 -07:00
Vinnie Falco
1a53f52e34 Check invariants in parse_op:
This adds more assertions, comments, and clarification.
2017-07-20 08:12:13 -07:00
Vinnie Falco
bac57e08e9 unit_test improvements:
* New overload of fail() specifies file and line
* BEAST_EXPECTS only evaluates the reason string on a failure
  - This speeds up tests that call BEAST_EXPECTS
2017-07-20 08:12:13 -07:00
Vinnie Falco
8f6e238ab9 Clean up message docs 2017-07-20 08:12:13 -07:00
Vinnie Falco
4f68ec7b7b Doc fixes 2017-07-20 08:12:13 -07:00
Miguel Portilla
0a1c24eb9f Refactor read_size_helper 2017-07-20 08:12:13 -07:00
Denis Andrejew
753281959e Improve websocket example in README.md
fix #138

* Refactoring for clarity
2017-07-20 08:12:13 -07:00
Vinnie Falco
ae58a7f457 Engaged invokable is destructible:
fix #147
2017-07-20 08:12:13 -07:00
Vinnie Falco
f3b22f74b2 Add headers_parser:
This allows just the HTTP headers to be parsed, and
the choice of body to be deferred to a subsequent
call to parse.
2017-07-20 08:12:13 -07:00
Vinnie Falco
4ded6cff76 Fix handling of body_what::pause in basic_parser_v1 2017-07-20 08:12:13 -07:00
Vinnie Falco
6832bd57d3 Add basic_parser_v1::reset 2017-07-20 08:12:13 -07:00
Vinnie Falco
83556937f6 Add on_body_what parser callback (API Change):
These changes support parsing the headers separately from the body.

* on_headers now returns void
* on_body_what is a new required callback which returns body_what
2017-07-20 08:12:13 -07:00
Vinnie Falco
ac07d0c3ed Fix parser traits detection (API Change):
basic_parser_v1 now requires that all callbacks appropriate
to the message are present and have the correct signatures.
Compile errors will result from compiling parsers which are
missing callbacks.
2017-07-20 08:12:13 -07:00
Vinnie Falco
e45a6418ee Tidy up documentation:
fix #135

* Fix broken references
* Move doc debug headers to extras/
* Add rfc7230 utility classes to quick reference
2017-07-20 08:12:13 -07:00
Vinnie Falco
81cd98ece5 Tidy up basic_headers for documentation 2017-07-20 08:12:13 -07:00
Vinnie Falco
a4d8a154b1 Refine message class hierarchy:
Two new objects, request_headers and response_headers,
represent the portion of HTTP messages excluding the body.
2017-07-20 08:12:13 -07:00
Vinnie Falco
056d6b94c2 Rework HTTP concepts (API Change):
fix #139, fix #140

* Writer uses write instead of operator()
* Refactor traits to use void_t
* Remove is_ReadableBody, is_WritableBody
* Add has_reader, has_writer, is_Reader, is_Writer
* More friendly compile errors on failed concept checks
2017-07-20 08:12:13 -07:00
Vinnie Falco
f110e51dd1 HTTP Reader (API Change):
fix #114, fix #117, fix #136

* Added init() to Reader requirements
* Reader must be nothrow constructible
* Reader is now constructed right before reading the body
  - The message passed on construction is filled in
2017-07-20 08:12:13 -07:00
Vinnie Falco
35d1ee54bc Parser callbacks may not throw (API Change) 2017-07-20 08:12:13 -07:00
Vinnie Falco
6732af5822 Add basic_streambuf::alloc_size
fix #133
2017-07-20 08:12:13 -07:00
Vinnie Falco
92e7afb801 Fix basic_streambuf::capacity 2017-07-20 08:12:13 -07:00
Vinnie Falco
52be0dd06e Tidying:
fix #85

* Remove unnecessary boost/system includes
* Remove unused headers_type from write_preparation
* Use braced-init style construction
* handler_alloc doc update
2017-07-20 08:12:13 -07:00
Evgeniy
8a64367d98 Change implicit_value to default_value 2017-07-20 08:12:13 -07:00
Vinnie Falco
bfaa4d2530 Fix websocket failure tests 2017-07-20 08:12:13 -07:00
Vinnie Falco
aed6c0e288 Relax ForwardIterator requirements in FieldSequence 2017-07-20 08:12:13 -07:00
Vinnie Falco
0eb3605232 Refactor base_parser_v1 callback traits:
When the derived class provides a member function with the
corresponding callback name, but the signature is different,
a compile error will be generated instead of silently ignoring
the member function.
2017-07-20 08:12:13 -07:00
Vinnie Falco
2106f364f6 Add pause option to on_headers interface:
* on_headers returns enum body_what
* body_what::pause lets caller receive headers during the parse
2017-07-20 08:12:12 -07:00
Vinnie Falco
ce18124566 Improve first line serialization 2017-07-20 08:12:12 -07:00
Vinnie Falco
a26a8ea433 Constrain parser_v1 constructor 2017-07-20 08:12:12 -07:00
Vinnie Falco
bca43529b0 Refine Parser concept:
* Parser is not HTTP-specific
* parse algorithms are in their own header
* Update documentation
2017-07-20 08:12:12 -07:00
Vinnie Falco
18eeddfab6 Fix on_headers called twice from basic_parser_v1 2017-07-20 08:12:12 -07:00
Vinnie Falco
5855b34d6e Make auto_fragment a boolean option 2017-07-20 08:12:12 -07:00
Vinnie Falco
1156b483c4 Rename to write_buffer_size 2017-07-20 08:12:12 -07:00
Vinnie Falco
74f9211366 Frame processing routines are member functions 2017-07-20 08:12:12 -07:00
Vinnie Falco
fbc8ddbc81 Make value optional in param-list 2017-07-20 08:12:12 -07:00
Radoslaw Zarzynski
bc665ee1ec Fix handling empty HTTP headers in parser_v1.hpp
This patch rectifies flush() of beast::http::parser_v1
to properly handle the case when an HTTP header has
empty value.

Without the fix an empty-valued HTTP header is being
concatenated with the header directly following it.
This situation can be replicated using eg. curl:

  curl <url> -H "X-First;" -H "X-Second: bla"

What Beast's client would see is a single header named
as "X-FirstX-Second".
2017-07-20 08:12:12 -07:00
Vinnie Falco
6b0b016b21 Tidy up error types:
* Restructure header material
* Clean up namespace type injections
* Remove extraneous 'success' constants
2017-07-20 08:12:12 -07:00
Vinnie Falco
f2a283ed10 Tidy up DynamicBuffer requirements 2017-07-20 08:12:12 -07:00
Vinnie Falco
9135cdff1a Fix message_v1 constructor 2017-07-20 08:12:12 -07:00
Vinnie Falco
e8527babeb Add Secure WebSocket example 2017-07-20 08:12:12 -07:00
Vinnie Falco
2ad5223d80 Add HTTPS example 2017-07-20 08:12:12 -07:00
Vinnie Falco
62bd4bb13f rfc7230 section 3.3.2 compliance 2017-07-20 08:12:12 -07:00
Vinnie Falco
9cc65c8850 Update and tidy documentation 2017-07-20 08:12:12 -07:00
Vinnie Falco
dff2751c07 Use BOOST_ASSERT 2017-07-20 08:12:09 -07:00
Vinnie Falco
41a8342d3b Better WebSocket decorator:
* Caller provided type can omit one or both overloads
* Omitted overloads yield default behavior
* Documentation no longer refers to a detail type
2017-07-20 08:12:09 -07:00
Evgeniy
42073a925a Update build scripts for MSVC, MinGW 2017-07-20 08:12:09 -07:00
Vinnie Falco
0c0b2f2545 Add missing rebind to handler_alloc 2017-07-20 08:12:09 -07:00
Vinnie Falco
dfea8ff266 Set version to 1.0.0-b13 2017-07-20 08:12:09 -07:00
Vinnie Falco
a443be208c Remove bin and bin64 directories:
These directories are removed, to make it easier for developers
to delete the entire directory contents when rebuilding CMake targets
after a configuration change.
2017-07-20 08:12:09 -07:00
Vinnie Falco
59cb3ee098 Use -p to print suites from unit test main 2017-07-20 08:12:09 -07:00
Vinnie Falco
28cabc5e28 Add BEAST_EXPECTS test failure macro:
New overloads of suite::expect take the file and line number
as individual parameters, cleaning up the file name output
by showing only the filename part (to not leak the full path,
which might contain sensitive information).

A new macro BEAST_EXPECTS allows an additional reason
string as well as reporting the file and line. Typical usage:

    ```
    error_code ec;
    ...
    if(! BEAST_EXPECTS(! ec, ec.message()))
        return;
    ```
2017-07-20 08:12:09 -07:00
Vinnie Falco
f144619e7c Fix unit test runner to output all case names:
Also fixes a bug where suite::log was incorrectly flushed.
2017-07-20 08:12:09 -07:00
Vinnie Falco
5f8f6c0b75 Update README, rename CHANGELOG 2017-07-20 08:12:09 -07:00