Commit Graph

235 Commits

Author SHA1 Message Date
Vinnie Falco df95a09024 Move prepare_buffers to prepare_buffer.hpp (API Change)
fix #338
2017-05-10 13:17:28 -07:00
Vinnie Falco 787de2111b Remove placeholders (API Change) 2017-05-10 13:08:43 -07:00
Vinnie Falco b7184f3a69 Return http::error::end_of_stream on HTTP read eof (API Change)
fix #350
2017-05-10 10:03:51 -07:00
Vinnie Falco f2d825594e Set version to 40 2017-05-10 09:17:54 -07:00
Vinnie Falco 9b240c71af Fix basic_streambuf movable trait 2017-05-10 05:36:00 -07:00
Vinnie Falco 76a2617d2e Consolidate get_lowest_layer in type_traits.hpp
fix #347
2017-05-09 19:38:49 -07:00
Vinnie Falco 6d003216b7 Add to_static_string:
This function converts integers to their decimal
representation as a static string.

In addition, static_string::resize no longer initializes
characters if the new size is larger.
2017-05-09 19:38:49 -07:00
Vinnie Falco f88813620c Set version to 39 2017-05-09 18:27:24 -07:00
Vinnie Falco 59b2f8fefd ostream workaround for gcc 4.8.4 2017-05-09 07:23:10 -07:00
Vinnie Falco 8363d869a0 Increase ostream test coverage 2017-05-09 07:23:10 -07:00
Vinnie Falco 5631936106 Tidy up HTTP reason_string (API Change):
fix #182

reason_string() is now located in <beast/http/message.hpp>
and returns a string view rather than char const*.
2017-05-09 07:23:10 -07:00
Vinnie Falco 2bf515069d Harmonize concepts and identifiers with net-ts (API Change):
fix #321

This synchronizes identifier names and some implementation details
with the Networking-TS document and reference implementation.
The following interfaces have changed:

* async_completion
* is_buffer_sequence (removed)
* is_const_buffer_sequence (was is_ConstBufferSequence)
* is_dynamic_buffer (was is_DynamicBuffer)
* is_mutable_buffer_sequence (was is_MutableBufferSequence)
* async_result (new)
* BEAST_HANDLER_TYPE macro (new)
* BEAST_INITFN_RESULT_TYPE macro (new)

Filename changes:

* async_result.hpp (was async_completion.hpp)
2017-05-09 07:23:09 -07:00
Vinnie Falco 728e9d8e70 Tidy up basic_parser javadocs 2017-05-09 07:23:09 -07:00
Vinnie Falco 1c9067b1da Use beast::string_view alias 2017-05-09 07:23:09 -07:00
Vinnie Falco e2b5c317fc Rename to buffered_read_stream (API Change):
dynabuf_readstream is renamed to buffered_read_stream.
2017-05-09 07:23:08 -07:00
Vinnie Falco a753f1cb38 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-05-09 07:23:08 -07:00
Vinnie Falco 24b66864d8 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-05-09 07:23:08 -07:00
Vinnie Falco 69259efe87 Rename to multi_buffer, basic_multi_buffer (API Change):
These classes are renamed:

* streambuf to multi_buffer
* basic_streambuf to basic_multi_buffer
2017-05-09 07:23:07 -07:00
Vinnie Falco bef9ae11ea 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-05-09 07:23:04 -07:00
Vinnie Falco a7ef4f53dc 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-05-08 15:46:03 -07:00
Vinnie Falco 87fd60c151 Fix eof error on ssl::stream shutdown
fix #334
2017-05-07 13:40:04 -07:00
Vinnie Falco ff5e659545 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-05-07 13:40:04 -07:00
Vinnie Falco dd02097d26 Set version to 1.0.0-b38 2017-05-07 13:39:44 -07:00
Vinnie Falco 5596e97656 Prevent basic_fields operator[] assignment
fix #258
2017-05-07 13:39:41 -07:00
Vinnie Falco c2b32dc740 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-05-07 13:39:40 -07:00
Vinnie Falco 32dbfb283b 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-05-07 13:39:40 -07:00
Vinnie Falco ba4228a832 Use static_string for WebSocket handshakes:
fix #328

This replaces usages of std::string with
static_string when performing WebSocket handshakes.
2017-05-07 13:39:40 -07:00
Vinnie Falco 6df3ff3f0f Refactor base64:
The implementation no longer uses std::string
and instead works on raw memory buffers, which
must be pre-sized accordingly.
2017-05-07 13:39:39 -07:00
Vinnie Falco 19b124dbd3 Refactor static_string:
static_string interface now closely matches std::basic_string.
2017-05-07 13:39:39 -07:00
Vinnie Falco 30e8d160a0 Set version to 1.0.0-b37 2017-05-07 13:20:18 -07:00
Vinnie Falco b14102092d Fix narrowing warning in table constants
fix #344
2017-05-07 13:18:41 -07:00
Vinnie Falco e1f08e9aa1 Fix flat_streambuf:
Don't call memcpy or memmove with null arguments.
2017-05-07 07:20:13 -07:00
Vinnie Falco 21ef97d220 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-05-05 21:00:56 -07:00
Vinnie Falco c86fee9513 Move everything in basic_fields.hpp to fields.hpp (API Change)
fix #320
2017-05-05 21:00:55 -07:00
Vinnie Falco a14a5d6b05 Rename to detail::is_invocable
Fix #323
2017-05-05 21:00:55 -07:00
Vinnie Falco 540d0373dc Rename to websocket::detail::pausation
Fix #324
2017-05-05 21:00:55 -07:00
Vinnie Falco 84e173943b Document websocket::stream thread safety
fix #329
2017-05-05 10:01:18 -07:00
Vinnie Falco dc274afcfa 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-05-05 10:01:18 -07:00
Vinnie Falco 2c17d04a3a 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-05-05 10:01:17 -07:00
Vinnie Falco 235fe68acb 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-05-05 10:01:17 -07:00
Vinnie Falco 32024d8b50 Set version to 1.0.0-b36 2017-05-05 09:55:01 -07:00
Vinnie Falco d8db5f1a0d Set version to 1.0.0-b35 2017-05-04 18:58:38 -07:00
Vinnie Falco dd2a514ef2 Tidy up doc declarations 2017-05-04 18:58:34 -07:00
Vinnie Falco 403011fdbe Remove http::empty_body (API Change) 2017-05-04 18:58:33 -07:00
Vinnie Falco f47b66179e 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-05-04 18:58:33 -07:00
Vinnie Falco f6835b8db4 Rename to BEAST_DOXYGEN
fix #316
2017-05-04 18:58:33 -07:00
Vinnie Falco 7e37723be0 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-05-04 18:58:33 -07:00
Vinnie Falco 3de46de96c Make websocket::close_code a proper enum:
fix #311

This changes close_code to be a proper enumeration.
2017-04-23 08:26:17 -07:00
Vinnie Falco 6d5547a32c Set version to 1.0.0-b34 2017-04-19 11:49:39 -07:00
Vinnie Falco ccefa54bf5 Set version to 1.0.0-b33 2017-04-14 19:30:33 -07:00