Commit Graph
316 Commits
Author SHA1 Message Date
Vinnie Falco fc0e356149 Rename to buffered_read_stream (API Change):
dynabuf_readstream is renamed to buffered_read_stream.
2017-07-20 08:12:16 -07:00
Vinnie Falco aa9f42cd06 Rename to static_buffer, static_buffer_n (API Change):
These classes are renamed:

* static_streambuf to static_buffer
* static_streambuf_n to static_buffer_n
2017-07-20 08:12:16 -07:00
Vinnie Falco 6e47e9a0ac Rename to flat_buffer, basic_flat_buffer (API Change):
These classes are renamed:

* flat_streambuf to flat_buffer
* basic_flat_streambuf to basic_flat_buffer
2017-07-20 08:12:16 -07:00
Vinnie Falco 24fd254690 Rename to multi_buffer, basic_multi_buffer (API Change):
These classes are renamed:

* streambuf to multi_buffer
* basic_streambuf to basic_multi_buffer
2017-07-20 08:12:16 -07:00
Vinnie Falco 38b473902a New buffers() replaces to_string() (API Change):
A new function, buffers(), returns an implementation defined object
which wraps a ConstBufferSequence and supports formatting to a
std::ostream.

The function to_string is removed, as the new implementation allows
conversion to string using boost::lexical_cast on the return value
of the call to buffers(). Streaming to an output stream is more
efficient: no dynamic allocations are performed.

Example:

    streambuf sb;
    std::cout << buffers(sb.data()) << std::endl;
2017-07-20 08:12:16 -07:00
Vinnie Falco 3add5f293c New ostream() returns dynamic buffer output stream (API Change):
This eliminates beast::write output for dynamic buffers and replaces
it with the function ostream() that wraps a caller provided dynamic
buffer and returns the result as a std::ostream derived object.
Callers may now produce formatted output into any object meeting the
requirements of DynamicBuffer using operator<< and the standard stream
modifiers such as std::endl.

This new technique is more efficient, as implementations of operator<<
can now write directly into the output using std::ostream::write and
std::ostream::put.

Example of use:

  beast::streambuf sb;
  beast::ostream(sb) << "Hello, world!" << std::endl;
2017-07-20 08:12:16 -07:00
Vinnie Falco 3f58d81fc4 Fix eof error on ssl::stream shutdown
fix #334
2017-07-20 08:12:16 -07:00
Vinnie Falco 415f94b150 Add websocket async echo ssl server test:
This adds a new asynchronous websocket echo server
which supports TLS/SSL connections.
2017-07-20 08:12:16 -07:00
Vinnie Falco a52914175b Refactor http::header contents (API Change):
fix #124

The http::header data members "method", "url", and "reason"
are changed from data members, to pairs of get and set
functions which forward the call to the Fields type used
to instantiate the template.

Previously, these data members were implemented using
std::string. With this change, the implementation of the
Fields type used to instantiate the template is now in
control of the representation of those values. This permits
custom memory allocation strategies including uniform use of
the Allocator type already provided to beast::http::basic_fields.
2017-07-20 08:12:16 -07:00
Vinnie Falco 02d4086061 Set version to 1.0.0-b38 2017-07-20 08:12:16 -07:00
Vinnie Falco 1a1a1d508b Prevent basic_fields operator[] assignment
fix #258
2017-07-20 08:12:16 -07:00
Vinnie Falco f7a0885d17 Remove websocket::keep_alive option (API Change):
fix #332

This removes the keep_alive option from the WebSocket stream.
Callers who wish to control the behavior of the Connection
header may do so in the decorator and completion handlers
for the handshake and accept functions.
2017-07-20 08:12:16 -07:00
Vinnie Falco 3da0d8b6a9 Refactor WebSocket error codes (API Change):
fix #325

This removes unused and misleading handshake error codes.
All semantic handshake failures are now reported using
the same code, error::handshake_failed. Errors originating
from stream operations still use the underlying stream
error codes (for example: boost::asio::error::connection_reset).
2017-07-20 08:12:16 -07:00
Vinnie Falco 30d0e9b1e7 WebSocket doc work 2017-07-20 08:12:16 -07:00
Vinnie Falco f9996eee30 More flat_streambuf tests 2017-07-20 08:12:16 -07:00
Vinnie Falco b1f88a99b6 Add test_allocator to extras/test 2017-07-20 08:12:16 -07:00
Vinnie Falco 3c0d2a998e Simplify get_lowest_layer test 2017-07-20 08:12:16 -07:00
Vinnie Falco 707f5c867e Use static_string for WebSocket handshakes:
fix #328

This replaces usages of std::string with
static_string when performing WebSocket handshakes.
2017-07-20 08:12:16 -07:00
Vinnie Falco c5184bed47 Refactor base64:
The implementation no longer uses std::string
and instead works on raw memory buffers, which
must be pre-sized accordingly.
2017-07-20 08:12:16 -07:00
Vinnie Falco 040323305e Refactor static_string:
static_string interface now closely matches std::basic_string.
2017-07-20 08:12:16 -07:00
Vinnie Falco 360fe691c5 Set version to 1.0.0-b37 2017-07-20 08:12:16 -07:00
Vinnie Falco 43cf3ae1f8 Fix narrowing warning in table constants
fix #344
2017-07-20 08:12:16 -07:00
Vinnie Falco 434d4d0a55 Add -funsigned-char to asan build target 2017-07-20 08:12:16 -07:00
Vinnie Falco 7d7a360666 Add ub sanitizer blacklist 2017-07-20 08:12:15 -07:00
Vinnie Falco df81d509d5 Fix flat_streambuf:
Don't call memcpy or memmove with null arguments.
2017-07-20 08:12:15 -07:00
Brad Anderson 20c1ba78f1 Fix typo in documentation example 2017-07-20 08:12:15 -07:00
Vinnie Falco e4a204b145 Rename to http::dynamic_body, consolidate header:
fix #284

* streambuf_body is renamed to dynamic_body
* basic_dynabuf_body is renamed to basic_dynamic_body
2017-07-20 08:12:15 -07:00
Vinnie Falco 52028b8da1 Rename project to http-bench
fix #285
2017-07-20 08:12:15 -07:00
Vinnie Falco 28a994e8cb Move everything in basic_fields.hpp to fields.hpp (API Change)
fix #320
2017-07-20 08:12:15 -07:00
Vinnie Falco 4b19600dd2 Rename to detail::is_invocable
Fix #323
2017-07-20 08:12:15 -07:00
Vinnie Falco 512ab5ba7d Rename to websocket::detail::pausation
Fix #324
2017-07-20 08:12:15 -07:00
Vinnie Falco 4b02fe989f Document websocket::stream thread safety
fix #329
2017-07-20 08:12:15 -07:00
Vinnie Falco 4b3a21efec Add is_upgrade() free function:
fix #195

This function returns `true` when the passed HTTP Request
indicates a WebSocket Upgrade. It does not validate the
contents of the fields: it just trivially accepts requests
which can only be a WebSocket Upgrade message.

Callers who wish to manually read HTTP requests in their
server implementation can use this function to determine if
the request should be routed to an instance of websocket::stream.
2017-07-20 08:12:15 -07:00
Vinnie Falco fa1f4c7d56 Refactor websocket decorators (API Change):
fix #80, #212, fix #303, fix #314, fix #317

websocket::stream now provides the following families of
functions for performing handshakes:

When operating in the server role:

    * stream::accept
    * stream::accept_ex
    * stream::async_accept
    * stream::async_accept_ex

When operating in the client role:

    * stream::handshake
    * stream::handshake_ex
    * stream::async_handshake
    * stream::async_handshake_ex

Member functions ending with "_ex" allow an additional
RequestDecorator parameter (for the accept family of
functions) or ResponseDecorator parameter (for the
handshake family of functions).

The decorator is called to optionally modify the contents
of the HTTP request or HTTP response object generated by
the implementation, before the message is sent. This
permits callers to set the User-Agent or Server fields,
add or modify HTTP fields related to subprotocols, or
perform any required transformation of the HTTP message
for application-specific needs.

The handshake() family of functions now have an additional
set of overloads accepting a parameter of type response_type&,
allowing the caller to receive the HTTP Response to the
Upgrade handshake. This permits inspection of the response
to handle things like subprotocols, authentication, or
other application-specific needs.

The new implementation does not require any state to be
stored in the stream object. Therefore, websocket::stream
objects are now smaller in size.

The overload of set_option for setting a decorator on the
stream is removed. The only way to set decorators now is
with a suitable overload of accept or handshake.
2017-07-20 08:12:15 -07:00
Vinnie Falco fab1015b89 Provide websocket::stream accept() overloads (API Change):
This adds enough functions to the accept and async_accept
overload set to cover all combinations of request, buffers,
and error_code parameters. This also fixes a defect where
providing a complete Upgrade request when there are additional
unprocessed octets remaining in the callers stream buffer
could not be furnished to the WebSocket implementation.
2017-07-20 08:12:15 -07:00
Vinnie Falco 8ba166a221 CMake hide command lines in .vcxproj Output windows 2017-07-20 08:12:15 -07:00
Vinnie Falco ad22f60666 Set version to 1.0.0-b36 2017-07-20 08:12:15 -07:00
Vinnie Falco 656017e36d Update README.md 2017-07-20 08:12:15 -07:00
Vinnie Falco 26440a90b7 Set version to 1.0.0-b35 2017-07-20 08:12:15 -07:00
Vinnie Falco 44714e3f04 Tidy up doc declarations 2017-07-20 08:12:15 -07:00
Vinnie Falco 7407e3adc3 Fix README.md CMake instructions
fix #318
2017-07-20 08:12:15 -07:00
Vinnie Falco 492391f749 Update .gitignore for VS2017 2017-07-20 08:12:15 -07:00
Vinnie Falco 19b75e5048 Remove http::empty_body (API Change) 2017-07-20 08:12:15 -07:00
Vinnie Falco e8be3fd7d3 New HTTP interfaces (API Change):
fix #123
fix #154
fix #265

This completely replaces the HTTP parser used to read and
parse incoming messages. The new version is faster than
the old one, and written in fewer lines. A summary of
changes:

* parse and async_parse renamed to read and async_read

* basic_parser is optimized for linear buffers,
  use flat_streambuf for the best performance with these
  functions:

  - http::read
  - http::read_some
  - http::async_read
  - http::async_read_some

* The overloads of read() and async_read() which take
  just a header have been removed, since they would
  throw away important parse metadata.

* The derived class callbacks for basic_parser have
  been streamlined. All strings passed to callbacks
  are presented in their entirety, instead of being
  provided in pieces.

These changes allow use-cases that were previously
difficult or impossible, such as:

- Efficient relaying

- Late body type commitment

- Expect: 100-continue handling
2017-07-20 08:12:15 -07:00
Vinnie Falco 34830a1780 Rename to BEAST_DOXYGEN
fix #316
2017-07-20 08:12:15 -07:00
Vinnie Falco e7319aade1 Add flat_streambuf:
Objects of this type meet the requirements of DynamicBuffer
and offer an additional invariant: buffer sequences returned
by data() and prepare() are always of length one.
2017-07-20 08:12:15 -07:00
Brad Chase 4d76089241 Doc XSL support for list and table markdown 2017-07-20 08:12:15 -07:00
Vinnie Falco 9774ed0e19 Make websocket::close_code a proper enum:
fix #311

This changes close_code to be a proper enumeration.
2017-07-20 08:12:15 -07:00
Vinnie Falco bd4ad15856 Tidy up MSVC CMake configuration 2017-07-20 08:12:15 -07:00
Vinnie Falco 75b8e30a15 Add appveyor build script
Fix #75
2017-07-20 08:12:15 -07:00