Commit Graph

732 Commits

Author SHA1 Message Date
Vinnie Falco
1947cb4e30 Fix rfc2616 Section 4.2 compliance:
basic_headers no longer combines fields with the same name by appending
a comma and concatenating the two values together. This was breaking
certain header fields which expect each value to be distinct, such as
the "Set-Cookie" header.

Now the container behaves more like a multi set with respect to insertion
of multiple values with the same field name. Additional member functions
are provided to provide extra functionality.
2017-07-20 08:12:07 -07:00
Casey Bodley
28bd98073e Use Threads::Threads interface library in cmake
in addition to passing ${CMAKE_THREAD_LIBS_INIT} to the linker, this
interface library will also add -pthread to the compile options when
supported

Signed-off-by: Casey Bodley <cbodley@redhat.com>
2017-07-20 08:12:07 -07:00
Vinnie Falco
344e4c942c Add skip_body parser option 2017-07-20 08:12:07 -07:00
Vinnie Falco
8b71afa63f Remove extraneous header file status.hpp 2017-07-20 08:12:07 -07:00
Vinnie Falco
589e18c199 rfc7230 compliance, limits, and tests for basic_parser_v1:
New parser set_option function for controlling independent size limits
on headers and body. By default request and response parsers are set up
with reasonable limits to prevent resource exhaustion attacks.

* Parser adheres strictly to rfc7230
* Increased test coverage
* Headers and body maximum size limit options
2017-07-20 08:12:07 -07:00
Vinnie Falco
6c30ee1a98 Rename concept to DynamicBuffer (API change):
Conform to the Networking TS by renaming the Streambuf concept
to DynamicBuffer in all places. Values of types meeting the
requirements of DynamicBuffer are renamed to dynabuf.

See:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4478.html#requirements.dynamic_buffers

* Headers renamed
* Formal parameter names renamed
* Template argument types renamed
* Documentation updated
2017-07-20 08:12:07 -07:00
Vinnie Falco
e8019fa9d4 Add message swap members and free functions 2017-07-20 08:12:07 -07:00
Vinnie Falco
db68ce4d97 Add HTTP field value parsers:
ext_list:
    Iterable container of comma separated extensions, where each extension
    is a token followed an optional list of semicolon delimited parameters,
    with each parameter consisting of a name / value pair. The value can
    be a token or quoted-string.

param_list:
    Iterable container of semicolon delimited parameters, where each parameter
    is a name / value pair. The value can be a token or quoted-string.

token_list
    Iterable container of comma delimited tokens.

* Remove obsolete rfc2616 functions

* Refactor and consolidate case-insensitive string helpers
2017-07-20 08:12:07 -07:00
Vinnie Falco
19256b85f0 HTTP improvements:
* Increased code coverage

* New Body concepts:
    is_Body
    is_ReadableBody
    is_WritableBody
2017-07-20 08:12:07 -07:00
Vinnie Falco
039244cda4 WebSocket ping, fixes, coverage:
* Improve test coverage
* tests for invokable in composed ops

* Update documentation
* Add License badge to README
* Target Windows 7 SDK and later
* Make role_type private
* Remove extra unused masking functions
* Allow stream reuse / reconnect after failure
* Restructure logic of composed operations
* Allow 0 for read_message_max meaning no limit
* Respect keep alive when building HTTP responses
* Check version in upgrade request
* Response with 426 status on unsupported WebSocket version
* Remove unnecessary Sec-WebSocket-Key in HTTP responses
* Rename to mask_buffer_size

* Remove maybe_throw
* Add ping, async_ping, async_on_pong
* Add ping_op
* Add pong_op
* Fix crash in accept_op
* Fix suspend in close_op
* Fix read_frame_op logic
* Fix crash in read_op
* Fix races in echo sync and async echo servers
2017-07-20 08:12:07 -07:00
Vinnie Falco
bfb840fe8e Fix parser off by one accessing buffer bug:
This fixed a bug where in some cases the parser could dereference
past the end of the caller provided buffer. The unit test is
improved to allocate memory in separate pieces for the split-buffer
matrix test, to give address-sanitizer more to work with.
2017-07-20 08:12:07 -07:00
Vinnie Falco
e47811bef2 Refactor unit_test logging:
The log member is changed to derive from std::ostream. A new
class dstream is derived from std::ostream to support redirection
to the Visual Studio Output Window if a debugger is attached.

Obsolete classes abstract_ostream and its derived variants are
removed.
2017-07-20 08:12:07 -07:00
seelabs
da78f3cec4 Tidying and fix warnings 2017-07-20 08:12:07 -07:00
seelabs
bbfe44cc10 Update CMakeLists for non-Windows platforms 2017-07-20 08:12:06 -07:00
Vinnie Falco
4f1b9089b8 Parser concept, fixes:
A new concept Parser is introduced with routines to read from a stream
into the parser. This solves a problem with the old read interface where
messages must be default constructible and move assignable.

Parser fixes:

* Fix detect invalid reason-phrase octets
* Fix write_eof to set the 'complete' state on success
* Fix consider parse complete if eof received on empty body

WebSocket:

* Increase coverage
2017-07-20 08:12:06 -07:00
Vinnie Falco
b62d1b2164 Fixes, fail testing:
Core:

* Test buffer_cat iterator move members

HTTP:

* Fixed yield / resume in writer
* Fixed message serialization with chunked encoding

* Test yield / resume in writer
* Test all conditional branches during message serialization
* Test chunked encoding
* Increase coverage on parse_error
* Add parse_error::general

WebSocket:

* Add error::general
* Increase coverage in error
2017-07-20 08:12:06 -07:00
Vinnie Falco
c49cde844b New constructors for message:
The message class now behaves like a pair with respect to the construction
of the body and headers. Additional constructors allow construction of
just the body portion from a tuple, leaving the headers default
constructed.

Previous constructors are removed as they were a notational convenience
for assembling HTTP/1 requests and responses. They are not necessary
as this library aims at library writers and not end users.
2017-07-20 08:12:06 -07:00
Vinnie Falco
3484996048 Tidy up core sources:
The core headers are moved to their own directory (but remain in
the same namespace).
2017-07-20 08:12:06 -07:00
Vinnie Falco
a59329ff8e Improvements to code coverage:
More tests and test cases are added to bring up
the percentage of library code covered by tests.
2017-07-20 08:12:06 -07:00
Vinnie Falco
00d8ed71fd Tidy up test sources:
Test support classes are moved to beast/extras/test.
2017-07-20 08:12:06 -07:00
Vinnie Falco
b14434456c Refactor extras:
A new directory extras/ is added, and code not part of the official
public Beast interface is moved there.
2017-07-20 08:12:06 -07:00
Vinnie Falco
133e7a3b16 Improvements to increase code coverage:
* Don't include the test code in coverage reports
* Add test code for missing coverage

Other:

* Improve the README.md
* Fix warning in sha1_context
* Tidy up the examples use of namespaces
* Various fixes to documentation and javadocs
2017-07-20 08:12:06 -07:00
Vinnie Falco
231988622c websocket::stream fail testing 2017-07-20 08:12:06 -07:00
Vinnie Falco
aea2f939d7 Put echo peer logging on toggle, default to off 2017-07-20 08:12:06 -07:00
Vinnie Falco
4bbf393e38 Tidy up declarations and files:
* Adjust formatting
* Fix inline namespace warning in main.cpp
* Fix streambuf op ambiguous variadic constructor
* Rename variables for clarity
2017-07-20 08:12:06 -07:00
Vinnie Falco
79913e6759 Fix SHA1 calculation 2017-07-20 08:12:06 -07:00
Vinnie Falco
313620ce7e Tidy up tests, build scripts, and documentation:
* Concepts split up into individual files
* Function definitions moved to .ipp files
* Add more tests to fill gaps in coverage
* Fix documentation Xsl
2017-07-20 08:12:06 -07:00
Vinnie Falco
c309f53ed2 Distinguish HTTP/1 messages from general HTTP messages:
The version field is moved into message_v1, all public interfaces
are reworked to identify HTTP/1 wire format operations (suffix "_v1")
versus general HTTP.
2017-07-20 08:12:05 -07:00
Nicholas Dudfield
cdde9b5ef1 Travis-CI additions:
* Address sanitizer target
* Code coverage target
* Results for codecov.io
2017-07-20 08:12:05 -07:00
Vinnie Falco
4104eca1f1 WebSocket refactoring and tests:
websocket:

* Move echo server to test/
* Fix warnings
* Fix maskgen being uncopyable
* Simplify utf8_checker special member declarations
* Fix stream move assignable when owning the next layer
* Add javadocs for stream special members
* Add stream unit tests
* Move throwing member definitions to the .ipp file
* Use get_lowest_layer in stream declaration
* Perform type checks at each call site instead of constructor
* Demote close_code to a non-class enum:
    Otherwise, application specific close codes
    cannot be assigned without using static_cast.

core:

* Add streambuf_readstream special members tests
* Add move assignment operator to streambuf_readstream
* Add detail/get_lowest_layer trait
* Add static_string tests
* Move static_string from websocket to core
2017-07-20 08:12:05 -07:00
Vinnie Falco
a0b04bdff2 Refactor beast core, http, tests, and examples:
* Fix warnings
* Port cmake scripts to linux
* Add command line options for running test suites
* Add examples to CMakeLists
* Return std::uint64_t from writer::content_length
* basic_parser::write takes asio::const_buffer instead of pointer and size
* Turn message test back on now that it passes
* Rename to http::headers, use std::allocator, remove http_headers
* http::message::method is now a string
* Refactor to_string for ConstBufferSequence
* Remove chunk_encode from the public interface
* Initialize members for default constructed iterators
* Disallow default construction for dependent buffer sequences

Refactor http::message serialization:

* Serialization no longer creates a copy of the
  headers and modifies them
* New function prepare(), sets Connection, Transfer-Encoding,
  Content-Length based on the body attributes and caller options.
  Callers can use prepare() to have the fields set automatically,
  or they can set the fields manually.
* Use write for operator<<
* Tests for serialization
2017-07-20 08:12:05 -07:00
Vinnie Falco
9a3a42a644 Truncate history, version 1.0.0-b2 2017-07-20 08:01:46 -07:00