kirit.com

Created 26th April, 2005 13:12 (UTC), last edited 30th December, 2013 06:38 (UTC)

Writing about C++, Programming, Fost 4, the web, Thailand and anything else that catches my attention—with some photos thrown in

Dependency injected exceptions or error handling

Posted 15th October, 2016 05:22 (UTC), last edited 16th October, 2016 04:37 (UTC)

Let's say we want to check that a Unicode code point is within the valid range before working out how many bytes it's UTF-8 representation is going to be:

void assert_valid(uint32_t cp) {
    if ( cp >= 0xd800 && cp <= 0xdbff ) {
        throw std::domain_error("UTF32 code point is in the leading UTF16 surrogate pair range");
    } else if ( cp >= 0xdc00 && cp <= 0xdfff ) {
        throw std::domain_error("UTF32 code point is in the trailing UTF16 surrogate pair range");
    } else if ( cp == 0xfffe || cp == 0xffff ) {
        throw std::domain_error("UTF32 code point is invalid");
    } else if ( cp > 0x10ffff ) {
        throw std::domain_error("UTF32 code point is beyond the allowable range");
   }
}

And we can now use it like this:

std::size_t u8length(uint32_t cp) {
    check_valid(cp);
    if ( cp < 0x00080 ) return 1u;
    else if ( cp < 0x00800 ) return 2u;
    else if ( cp < 0x10000 ) return 3u;
    else return 4u;
}

We now get an exception thrown if the Unicode is invalid. But what if we don't like the exception that is thrown? Maybe we want to throw our own exception class because it has some extra facilities?

We can refactor both functions to take the exception class to throw as a parameter:

template<typename E = std::domain_error> inline
void assert_valid(uint32_t cp) {
    if ( cp >= 0xd800 && cp <= 0xdbff ) {
        throw E("UTF32 code point is in the leading UTF16 surrogate pair range");
    } else if ( cp >= 0xdc00 && cp <= 0xdfff ) {
        throw E("UTF32 code point is in the trailing UTF16 surrogate pair range");
    } else if ( cp == 0xfffe || cp == 0xffff ) {
        throw E("UTF32 code point is invalid");
    } else if ( cp > 0x10ffff ) {
        throw E("UTF32 code point is beyond the allowable range");
    }
}

template<typename E = std::domain_error> inline
std::size_t u8length(uint32_t cp) {
    check_valid<E>(cp);
    if ( cp < 0x00080 ) return 1u;
    else if ( cp < 0x00800 ) return 2u;
    else if ( cp < 0x10000 ) return 3u;
    else return 4u;
}

Most of our users of u8length can still write u8length(cp) and get the default exception, but in my code I can now use it as u8length<fostlib::exceptions::unicode_error>(cp) and I get my exception class instead.

Error return

If we stopped there it's a little bit interesting, but hardly worthy of much note. With another couple of refactorings though we can have this same code returns errors for those who want that rather than exceptions. First of all let's factor out the throwing of the exception:

template<typename E> inline
void raise(const char *what) {
    throw E(what);
}

template<typename E = std::domain_error> inline
void assert_valid(uint32_t cp) {
    if ( cp >= 0xd800 && cp <= 0xdbff ) {
        raise<E>("UTF32 code point is in the leading UTF16 surrogate pair range");
    } else if ( cp >= 0xdc00 && cp <= 0xdfff ) {
        raise<E>("UTF32 code point is in the trailing UTF16 surrogate pair range");
    } else if ( cp == 0xfffe || cp == 0xffff ) {
        raise<E>("UTF32 code point is invalid");
    } else if ( cp > 0x10ffff ) {
        raise<E>("UTF32 code point is beyond the allowable range");
    }
}

The next thing to note is that the domains of our return values allow for errors to be returned. assert_valid can return a bool and u8length could return zero if the code point is invalid. This would then look like this:

template<typename E = std::domain_error> inline
bool assert_valid(uint32_t cp) {
    if ( cp >= 0xd800 && cp <= 0xdbff ) {
        raise<E>("UTF32 code point is in the leading UTF16 surrogate pair range");
    } else if ( cp >= 0xdc00 && cp <= 0xdfff ) {
        raise<E>("UTF32 code point is in the trailing UTF16 surrogate pair range");
    } else if ( cp == 0xfffe || cp == 0xffff ) {
        raise<E>("UTF32 code point is invalid");
    } else if ( cp > 0x10ffff ) {
        raise<E>("UTF32 code point is beyond the allowable range");
    } else {
        return true;
    }
    return false;
}

template<typename E = std::domain_error> inline
std::size_t u8length(uint32_t cp) {
    if ( !check_valid<E>(cp) ) return 0u;
    else if ( cp < 0x00080 ) return 1u;
    else if ( cp < 0x00800 ) return 2u;
    else if ( cp < 0x10000 ) return 3u;
    else return 4u;
}

Of course we'll still always get the exception because raise throws. What we can do though is to choose a type that means “don't throw” and then specialise raise on that type. void seems like it's probably a good choice:

template<> inline
void raise<void>(const char *) {}

Now we have two choices about how to use u8length:

auto bytes = u8length(cp);
dosomething(bytes, cp);

The use of exceptions by default is important from a security context. Unicode errors are a common attack vector, and throwing an exception if something is wrong simply makes the software a good deal safer as error handling code is just too easy to get wrong. But of course, sometimes we will want to do this sort of thing:

if ( auto bytes = u8length<void>(cp); bytes ) { // C++17
    dosomething(bytes, cp);
} else {
    // Handle error
}

Most API uses get the safety of the exception being thrown, but you can also opt out of that and just get an error return for the cases where that is preferable.

Real code for raise and the UTF encodings can be found in the f5-cord library* [*This code isn't in master yet. Check out the previously linked commits instead.]. Note that this version is also constexpr, which is also pretty cool.

The (approximate) final versions are reproduced below. And yes, raise is probably a stupid name now.

namespace f5 {

/// Raise an error of type E giving it the specified error text
template<typename E>
constexpr inline
void raise(f5::cord::lstring error) {
    throw E(error.c_str());
}

/// Specialisation for when we want an error return
template<>
constexpr inline
void raise<void>(f5::cord::lstring) {
}

/// A UTF-8 code point
typedef unsigned char utf8;
/// A UTF-32 code point
typedef uint32_t utf32;

/// Check that the UTF32 code point is valid. Throw an exception if not.
template<typename E = std::domain_error>
constexpr inline
bool check_valid(utf32 cp) {
    if ( cp >= 0xd800 && cp <= 0xdbff ) {
        raise<E>("UTF32 code point is in the leading UTF16 surrogate pair range");
    } else if ( cp >= 0xdc00 && cp <= 0xdfff ) {
        raise<E>("UTF32 code point is in the trailing UTF16 surrogate pair range");
    } else if ( cp == 0xfffe || cp == 0xffff ) {
        raise<E>("UTF32 code point is invalid");
    } else if ( cp > 0x10ffff ) {
        raise<E>("UTF32 code point is beyond the allowable range");
    } else {
        return true;
    }
    return false;
}

/// Return the number of UTF8 values that this code point will
/// occupy. If the code point falls in an invalid range then an
/// exception will be thrown.
template<typename E = std::domain_error>
constexpr inline
std::size_t u8length(utf32 cp) {
    if ( not check_valid<E>(cp) ) return 0u;
    else if ( cp < 0x00080 ) return 1u;
    else if ( cp < 0x00800 ) return 2u;
    else if ( cp < 0x10000 ) return 3u;
    else return 4u;
}

}

And some tests to show that it is also usable at compile time:

static_assert(f5::check_valid(' '), "Space is a valid UTF32 code point");
static_assert(not f5::check_valid<void>(0xff'ff'ff), "0xff'ff'ff is not a valid code point");

static_assert(f5::u8length(0) == 1, "Zero is still 1 byte long");
static_assert(f5::u8length(' ') == 1, "Space is 1 byte long");
static_assert(f5::u8length(0xa3) == 2, "Pounds are 2 bytes long");
static_assert(f5::u8length(0xe01) == 3, "Thai chickens are 3 bytes long");
static_assert(f5::u8length(0x1d11e) == 4, "The treble clef is 4 bytes long");

The most obvious improvement is for raise to perfectly forward any arguments on to the exception constructor, but we still can't partially specialise functions so the implementation will be a bit more complex as the specialisation will have to be done in a class.


Categories:

Fost 5 release 5.16.09.44992 now out

Posted 25th September, 2016 04:00 (UTC), last edited 27th September, 2016 02:30 (UTC)

There's a lot of new things this time. There's a new Fost 5 library, f5-cord, for string handling. There's also a new module, Fostgres, for the Mengmom web server — Fostgres is going to get it's own announcement sometime soon.

The development work being done has been showing up the problems in the old web server and framework (fost-web). We're designing a newer and better one that will be built on top of Boost ASIO (or C++17 networking?). There'll be a compatibility layer so that the old views will continue to work in the new code.

I was hoping that we'd be able to deprecate the mutex and locking wrapper around boost::spirit::parse, but despite setting the build to be thread safe the implementation isn't actually thread safe. At some point this code needs to move off Spirit Classic, and that looks like it'll be significantly simpler to do with C++14 than it has been in the past.

What we will deprecate though is all of the unfinished O/RM code in fost-orm. We've been building some new abstractions for Postgres in fost-postgres and that seems to be a simpler way of doing things — just thin wrappers around SQL itself. Coming up soon I also hope we'll be able to start to deprecate and then remove a lot of the older abstractions that have now been included in C++, for example the futures.

Some good news: Ubuntu Xenial is now fixed and builds work properly with both clang and gcc.

Building on Linux

git clone --branch=5.16.09.44992 --recursive git@github.com:KayEss/fost-hello.git
cd fost-hello
Boost/build 58 0
Boost/install 58 0
hello/compile
dist/bin/hello-world-d

Download locations

Applications

  • beanbag — Stand alone transactional JSON database server — git@github.com:KayEss/beanbag.git
  • beanbag-seed — Seed project for giving you a starting point to develop web applications using Beanbag — git@github.com:KayEss/beanbag-seed.git
  • fost-hello — Sample seed project — git@github.com:KayEss/fost-hello.git
  • mengmon — Stand alone web server — git@github.com:KayEss/mengmom.git

Libraries

  • f5-cord — First version of a new string library —
  • f5-threading — Preview of the first Fost 5 library which includes help for threading.
  • fost-aws — Amazon AWS and OpenStack — git@github.com:KayEss/fost-aws.git
  • fost-android — Eclipse project for Android that allows Fost 4 and Beanbags to be used on mobile devices — git@github.com:KayEss/fost-android.git
  • fost-android-ndk — The native code for Android. Includes required parts of Boost configured to use the standard Android build system.
  • fost-beanbag — Transactional JSON database — git@github.com:KayEss/fost-beanbag.git
  • fost-base — Build system and core libraries — git@github.com:KayEss/fost-base.git
  • fost-internet — Internet protocols, servers & clients — git@github.com:KayEss/fost-internet.git
  • fost-meta — All libraries in one wrapper — git@github.com:KayEss/fost-meta.git
  • fost-orm — Object/Relational mapping — git@github.com:KayEss/fost-orm.git
  • fost-postgres — PostgreSQL — git@github.com:KayEss/fost-postgres.git
  • fost-py — Python (2.x) bindings — git@github.com:KayEss/fost-py.git
  • fost-web — Web server libraries — git@github.com:KayEss/fost-web.git

Detailed change log

fost-base

  • The colourised logger now considers logging levels around each level when choosing a colour.
  • Remove direct calls to boost::spirit::parse due to threading problems.
  • Initial version of new splitter API that uses views to cut down on memory allocations.
  • Add additional APIs for utf::u8_view
  • Allow construction and assignment of fostlib::json from nullable atomic types.
  • Added a UTF8 string view
  • Added a JSON parse overload for UTF8 buffers and added extra tests.
  • Add json_embedded_parser which doesn't allow whitespace around the JSON.
  • Add default constructors to the JSON parsers so they can be const constructed.
  • Ensure that the lengths match before comparing the data in crypto_compare.
  • Added initial support for minting and checking JWT.
  • Extra information for the not_implemented constructor can now be anything coercible to JSON. Also remove the exception from the fost/core header.
  • Make public a jcursor constructor so we can copy part of another one.
  • jcursor parts can be compared for equaility with string literals.
  • The not_implemented exception can now be given JSON as its third argument.
  • Add in nliteral comparison overloads in a couple of places they were missing.
  • Fix a long standing bug in the Base64 encoder where it would add bad data when the data length was exactly divisible by 3.

fost-beanbag

  • Make the function for converting a path to a jcursor generally available.

fost-internet

  • Make the remote address properly available on the server HTTP request.
  • The HTTP server now adds a header describing the remote address.
  • Handle setting MIME headers via JSON.
  • Swap a std::list for a std::vector in the query string interface.
  • Fix a bug in the server request so it properly returns a reference to the query string.
  • Allow a jcursor to access header sub-values.
  • Allow header content to be created from a JSON object.
  • Allow access to some parts of the server request using a jcursor.
  • Drop MIME headers that have an underscore in their names.
  • Add shortcut method on HTTP request for getting to the headers.

fost-postgres

  • Add ability to set other settings on the database connection.
  • Add basic API that allows SELECT to be ordered.
  • Add support for setting the zone info on the connection.
  • Add APIs for creating and deleting databases.
  • Added support for fetching varchar and time values.
  • Stored procedures can now be called with JSON arguments.
  • Make the database connection move constructible.
  • Add support for JSON objects in the SQL, on the assumption that they are for either json or jsonb in Postgres.
  • Make use of table OIDs to distinguish names of columns.
  • Warn about type OIDs that are unkown and completely disallow time stamps with time zone information.
  • Allow JSON to be used in connection configuration and for the effective configuration to be retrieved.
  • Add basic support for stored procedures.
  • Add support for fetching the column names.
  • Start to sketch out a new Postgres specific API which will eventually displace libpqxx.

fost-web

  • Add a middleware that logs the HTTP request details and some response details.
  • fost.view.pathprefix can now take an embedded configuration.
  • fost.response.401 can now be given an inner view for the response data.
  • Add middleware that can alter the request by adding headers to it.
  • Add execute method to the view to make forwarding to embedded views easier.
  • Add a basic 401 response.
  • Improve some diagnostic output whilst loading.
  • Include configuration files for various logging levels.
  • Show type information for caught std::exception instances.

fostgres

  • Set the remote address as fostgres.remote_addr on the database connection.
  • Set source address on the network connection when possible.
  • The test script can now check CSJ results are what is expected.
  • Can configure a zone info on the view to control which time zone to use.
  • Logging options can be set for fostgres-test.
  • The fostgres-test testserver can now be given header values to use for all requests.
  • fostgres-test only turns not_implemented exceptions into 501s if that is the expected response.
  • Add a command for running SQL from a file.
  • Add a language extension mechanism.
  • Object PUT support can now have configurations for multiple tables.
  • Add DELETE support and a scripting language for testing the views.
  • Deprecate the old configuration for JSON based PATCH.
  • SQL can be run with a list of JSON arguments.
  • Add a connection factory function that can read some values from the request.
  • Basic implementation of CSJ and JSON options for views that fetch data from the database.

Categories:

Fost 5 release 5.16.06.44985 now out

Posted 30th June, 2016 07:24 (UTC), last edited 30th June, 2016 08:12 (UTC)

This release features a significantly faster JSON unparser/stringifier which can be given a std::string to use as a buffer to stringify into. This is used by a new module for the web server that we should be releasing over the next month or two.

The Android switch from gcc to clang has just been done, but didn't make it into this release. The clang versions are far in advance of gcc so we can start to use some more of the C++14 features we'd like to.

The bad news is that gcc have made a breaking change to their ABI. Although use of the new ABI is optional many distributions have picked it up, including Ubuntu. This breaks clang builds on all of these platforms. It isn't at all clear what the resolution will be or when it will land. This seems especially shameful on Ubuntu where the broken compiler first hit an LTS release.

Building on Linux

git clone --branch=5.16.03.44971 --recursive git@github.com:KayEss/fost-hello.git
cd fost-hello
Boost/build 58 0
Boost/install 58 0
hello/compile
dist/bin/hello-world-d

Download locations

Applications

  • beanbag — Stand alone transactional JSON database server — git@github.com:KayEss/beanbag.git
  • beanbag-seed — Seed project for giving you a starting point to develop web applications using Beanbag — git@github.com:KayEss/beanbag-seed.git
  • fost-hello — Sample seed project — git@github.com:KayEss/fost-hello.git
  • mengmon — Stand alone web server — git@github.com:KayEss/mengmom.git

Libraries

  • f5-threading — Preview of the first Fost 5 library which includes help for threading.
  • fost-aws — Amazon AWS and OpenStack — git@github.com:KayEss/fost-aws.git
  • fost-android — Eclipse project for Android that allows Fost 4 and Beanbags to be used on mobile devices — git@github.com:KayEss/fost-android.git
  • fost-android-ndk — The native code for Android. Includes required parts of Boost configured to use the standard Android build system.
  • fost-beanbag — Transactional JSON database — git@github.com:KayEss/fost-beanbag.git
  • fost-base — Build system and core libraries — git@github.com:KayEss/fost-base.git
  • fost-internet — Internet protocols, servers & clients — git@github.com:KayEss/fost-internet.git
  • fost-meta — All libraries in one wrapper — git@github.com:KayEss/fost-meta.git
  • fost-orm — Object/Relational mapping — git@github.com:KayEss/fost-orm.git
  • fost-postgres — PostgreSQL — git@github.com:KayEss/fost-postgres.git
  • fost-py — Python (2.x) bindings — git@github.com:KayEss/fost-py.git
  • fost-web — Web server libraries — git@github.com:KayEss/fost-web.git

Detailed change log

fost-base

  • Add the F5 threading library to the standard project includes.
  • Optimise the JSON unparse, especially for the case where we can unparse into a buffer.
  • Add a fostlib::json::unparse that takes a fostlib::string.
  • Add a fostlib::json::get overload that can be given a default to substitute if the value doesn't exist.
  • Added coercion for std::vector to JSON, which will give an array of the vector values coerced to JSON.

fost-beanbag

  • Downgrade two log messages to debug level.
  • Add PATCH method to the raw beanbag view and operations for manipulating them.
  • Add op:remove and op:created transformations for PATCH requests.

fost-orm

  • Fix up the use of the root position in the jsondb::local and add a new rebase method for changing it. This causes a breaking change in the transformation function signature which now needs to take the transaction root as an argument.

fost-py

  • Fixed which JSON unparse gets used by Python.

fost-web

  • Improve error display and add logging of errors.

Categories:

Comma Separated JSON

Created 18th June, 2016 07:32 (UTC), last edited 21st June, 2016 13:05 (UTC)

Comma Separated JSON (CSJ) is a CSV like file format designed for stream processing where each cell is valid JSON. This makes it very similar to CSV, but without the problems that CSV has.

The problem with JSON is that to produce it you need to build a memory structure of everything you want to dump out, and to parse it you have to build everything in one go back into memory. This is fine for small JSON blobs, but isn't really ideal when the data consists of many mega bytes, or more.

XML solves this by having event based parsers that allow you to read sub-sections of the structure as they stream past. Kind of great, but who really wants to go back to XML?

CSV solves this in a different way. By having each line of data pretty much independent we can both generate and parse it one line at a time. This makes streaming it out and streaming it into things pretty painless. But the problem is that CSV isn't really a well defined file format with a well defined syntax.

  • What is the correct way to embed a new line? Do you expect \n or quoted text where the cell data actually goes into the next line?
  • What about embedded double quotes? Are they doubled up "" or slash escaped \"?
  • Are you going to parse the phone number +6686555123456 as 6.6865551e12?
  • What about dates and times? Actually, let's not even think about that.
  • If you have a single column of data, is the blank line at the end an empty cell and part of the data or not? What about blank lines in the middle?

All of these cases are solved in CSJ by using a JSON base to produce something that looks almost the same as CSV but without the parsing difficulties.

Below is a tiny CSJ file:

"name", "age", "job"
"Kirit Sælensminde", 45, "Minister Without  Portfolio"
"Freyja Sælensminde", 5, null

This looks almost exactly like the same CSV file would, and that's no accident. However we now know a few more things about the file. Following JSON's encoding rules the file is UTF-8. The strings are escaped using JSON rules so Unicode is simple to deal with. As are embedded new lines and double quotes.

Empty cells can now also be properly explicit making use of null. We would also have access to proper booleans. Never again get telephone numbers and actual numbers confused in processing.

Because it's a new format we can also be a bit stricter on specifying how we want a last tricky aspect to be dealt with:

  • All dates and times are ISO formatted
  • Times always have a time zone offset associated with them

Notes on consumption and production

Semantically a CSJ file is an array of JSON objects which share a common set of keys.

The media type for CSJ should be application/csj (following on from JSON's media type).

A single line from a CSJ file can be prepended with [ and suffixed by ] and run through a standard JSON parser.

Because it is JSON a cell doesn't have to be a JSON atom. You can embed JSON objects and arrays into a line and everything will work exactly as you'd expect with no ambiguity of how to produce or consume the data.

Like CSV, it can be produced with very low overhead. Our code that turns Postgres SQL statements into CSJ is able to stream the data over a HTTP connection at twice the speed that psql is able to stream the same SQL statement data into /dev/null. For my 32GB desktop producing JSON output for 10 million rows of half-a-dozen columns requires more RAM than I have. The RAM overhead to produce the CSJ data stream barely registers.

The example below includes embedded arrays:

"slug", "title", "released", "length_minutes", "created","tags", "watched__last", "watched__times"
"t1","Terminator","1984-10-26",null,"2016-06-11 08:54:09.006744+00",["adventure","action","dystopian","robots","time-travel","sci-fi"],"2016-06-11 08:55:31.54614+00",6
"t2","Terminator 2: Judgement Day","1991-07-01",94,"2016-06-11 08:54:12.895416+00",["adventure","action","dystopian","robots","time-travel","sci-fi"],null,null

It would be really cool if spreadsheets had a “CSJ export” option where we wouldn't suffer the sort of data corruption that all too often occurs

Now we'd never have to worry about a user loading a file into a spreadsheet, doing some work, and then corrupting half the data we need to process when it's saved.

Onward and upward

We've been introducing this in a few APIs that we've been building recently and are now in the process of building larger systems that use CSJ. Probably at some point in the near future we'll have a little JavaScript library that can be used to process server requests that return data in CSJ.

This is really a small part of a larger ecosystem that we're in the process of building out and you should be hearing more about in the coming months.


Categories:
Posted: 19th June, 2016 04:28 (UTC)
First on the front page.

Fost 5 release 5.16.03.44971 now out

Posted 29th March, 2016 11:11 (UTC), last edited 25th April, 2016 10:39 (UTC)

Most obvious change is the version bump has finally come through. There's also some new functionality in the crypto wrappers for better password hashes.

There's a couple of new libraries that we're going to be included sometime in the next few releases. We're also redesigning the Postgres handling which hopefully will lead to the removal of most, if not all, of the old O/RM code for a simpler and lighter wrapper around the core Postgres features.

There's also a big change in the pipeline for Android to support the switch from gcc to clang — watch this space.

Building on Linux

git clone --branch=5.16.03.44971 --recursive git@github.com:KayEss/fost-hello.git
cd fost-hello
Boost/build 58 0
Boost/install 58 0
hello/compile
dist/bin/hello-world-d

Download locations

Applications

  • beanbag — Stand alone transactional JSON database server — git@github.com:KayEss/beanbag.git
  • beanbag-seed — Seed project for giving you a starting point to develop web applications using Beanbag — git@github.com:KayEss/beanbag-seed.git
  • fost-hello — Sample seed project — git@github.com:KayEss/fost-hello.git
  • mengmon — Stand alone web server — git@github.com:KayEss/mengmom.git

Libraries

  • f5-threading — Preview of the first Fost 5 library which includes help for threading.
  • fost-aws — Amazon AWS and OpenStack — git@github.com:KayEss/fost-aws.git
  • fost-android — Eclipse project for Android that allows Fost 4 and Beanbags to be used on mobile devices — git@github.com:KayEss/fost-android.git
  • fost-android-ndk — The native code for Android. Includes required parts of Boost configured to use the standard Android build system.
  • fost-beanbag — Transactional JSON database — git@github.com:KayEss/fost-beanbag.git
  • fost-base — Build system and core libraries — git@github.com:KayEss/fost-base.git
  • fost-internet — Internet protocols, servers & clients — git@github.com:KayEss/fost-internet.git
  • fost-meta — All libraries in one wrapper — git@github.com:KayEss/fost-meta.git
  • fost-orm — Object/Relational mapping — git@github.com:KayEss/fost-orm.git
  • fost-postgres — PostgreSQL — git@github.com:KayEss/fost-postgres.git
  • fost-py — Python (2.x) bindings — git@github.com:KayEss/fost-py.git
  • fost-web — Web server libraries — git@github.com:KayEss/fost-web.git

Detailed change log

fost-aws

  • Removed use of deprecated Fost APIs.

fost-base

  • New fostlib::crypto_bytes function returns an array of bytes from a cryptographically secure location.
  • Add new fostlib::array_view that allows for looking at memory areas.
  • Implement PKBKDF2 with HMAC and SHA256 that produces a fixed length (64 bytes) derived key and one that produces a derived key whose length can be chosen at run time.
  • Added fostlib::crypto_compare which is intended to be as close as possible to constant time for comparison of memory blocks (byte arrays and strings).
  • Allow HMAC with std::array<unsigned char, n> secrets.
  • gcc doesn't really get [[deprecated]] so disable the warnings.
  • Add a new werror build option which sets the -Werror compile flag and turns warnings into errors. Fix remaining warnings in clang builds.
  • Deprecated the fostlib::exceptions::exception::info members. Added a coercion from fostlib::exceptions::exception to fostlib::json. Add a new forwarded exception type. Add #define FOST_NO_STD_EXCEPTION_PTR to control use of std::exception_ptr.
  • Fix a problem with the variadic insert where it expected a jcursor rather than converted to one.
  • Add digest and HMAC overloads for std::vector<unsigned char>.

fost-beanbag

  • Removed use of deprecated Fost APIs.

fost-internet

  • Removed use of deprecated Fost APIs.
  • Make sure the web server logs an error message when it catches an excepion.

fost-orm

  • Improved an error message for file backed JSON databases.
  • Removed use of deprecated Fost APIs.

fost-py

  • Removed use of deprecated Fost APIs.

fost-web

  • Allow multiple configuration files to be loaded by the web server and explicitly load up the logging options.
  • Added Date, Expires to static response headers.
  • Implemented 304 response.
  • Removed use of deprecated Fost APIs.

Categories: