Commit Graph

208 Commits

Author SHA1 Message Date
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
Vinnie Falco 32afe415c4 Set internal state correctly when writing frames:
fix #300

Correctly set wr_.cont when performing synchronous frame
writes, for the case where masking and autofragment are used.
2017-04-14 19:25:05 -07:00
Vinnie Falco df661658ee Require Visual Studio 2015 Update 3 or later
fix #216
2017-04-12 18:36:59 -07:00
Vinnie Falco b8e5a21bfd Set version to 1.0.0-b32 2017-04-10 16:48:16 -07:00
Vinnie Falco b893749e29 Remove http Writer suspend and resume feature (API Change):
fix #154

The resume_context parameter passed to instances
of Writer during HTTP serialization is removed.
2017-04-10 15:54:29 -07:00
Vinnie Falco eba05a76e7 Set version to 1.0.0-b31 2017-03-21 15:52:01 -04:00
Florian Behrens 5663bea6cd Add missing dynabuf_readstream member
fix #277
2017-03-16 07:29:39 -04:00
Vinnie Falco 0fd4030738 Move the handler, don't copy it 2017-03-16 07:29:34 -04:00
Vinnie Falco 1b9a714833 Set version to 1.0.0-b30 2017-02-27 11:55:19 -05:00
Vinnie Falco faed9e57f2 Allow concurrent websocket async ping and writes:
fix #271

This modifies the websocket stream implementation's composed
operations to allow caller-initiated asynchronous pings and
frame/message writes to take place at the same time.
2017-02-27 10:50:32 -05:00
Vinnie Falco 31cda067fa Fix race when write suspends 2017-02-27 10:50:29 -05:00
Vinnie Falco 48dd38eb55 Fix race in close frames during reads 2017-02-27 10:45:05 -05:00
Vinnie Falco e2d1bb062b Fix race in pings during reads 2017-02-27 10:39:53 -05:00
Vinnie Falco 36143be195 Set version to 1.0.0-b29 2017-02-24 13:25:05 -05:00
Vinnie Falco 6406da06b9 Document type-pun in buffer_cat 2017-02-24 13:24:30 -05:00
Vinnie Falco 66cdb378f2 Fix illegal HTTP characters accepted as hex zero 2017-02-24 13:24:30 -05:00
Vinnie Falco 6dfd9f9fe8 Fix compilation error in non-template class
fix #267
2017-02-22 18:15:48 -05:00
Vinnie Falco fa7fea8f02 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-02-22 18:15:43 -05:00
Vinnie Falco 9f10b11eff Set version to 1.0.0-b28 2017-02-07 19:59:14 -05:00
Vinnie Falco 195f974872 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-02-07 19:59:04 -05:00
Vinnie Falco 264fd41342 Restyle async result constructions 2017-02-07 19:59:03 -05:00
Vinnie Falco 95b6646167 Tidy up some WebSocket javadocs 2017-02-07 19:59:03 -05:00
Vinnie Falco f6938d3760 Set version to 1.0.0-b27 2017-02-07 15:20:34 -05:00
Vinnie Falco a6120cd8be Update copyright dates 2017-02-07 15:20:25 -05:00
Vinnie Falco f6c91ce9f5 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-02-06 11:34:29 -05:00
Vinnie Falco f03985f3e8 Move basic_streambuf to streambuf.hpp (API Change):
* Also change allocator element type to char
2017-02-06 11:34:29 -05:00
Vinnie Falco b8639a791a 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-02-05 18:45:22 -05:00
Vinnie Falco 06f74f05f7 Set version to 1.0.0-b26 2017-02-02 09:04:25 -05:00