These are some useful utilities included with SHOW, but in their own header files so they're optional.
These are utilities for handling base64-encoded strings, very commonly used for transporting binary data in web applications. They are included in show/base64.hpp.
Multipart content is used to send a number of data segments each with their own separate headers. As such, text and binary data can be mixed in the same message.
SHOW provides the following utilities for parsing multipart requests in show/multipart.hpp. Typically, the Content-Type
header for these types of requests will look something like:
Content-Type: multipart/form-data; boundary=AaB03x
The boundary string must be extracted from the header to pass to :cppmultipart
's constructor. A simple example with no error handling:
const auto& header_value = request.headers()[ "Content-Type" ][ 0 ];
auto content_supertype = header_value.substr( 0, header_value.find( "/" ) )
if( content_supertype == "multipart" )
{
show::multipart parser{
request,
header_value.substr( header_value.find( "boundary=" ) + 9 )
};
// Iterate over multipart data ...
}
else
// Process data as single message ...