|
| static std::string_view | mediaType () noexcept |
| static anch::rest::FormLimits & | limits (anch::codec::Side side) |
| static anch::codec::MediaType | contentType (const anch::rest::Form &form) |
| template<anch::rest::FormMapped T> |
| static anch::codec::MediaType | contentType (const T &value) |
| static std::string | randomBoundary () |
| static void | serialize (const anch::rest::Form &form, std::ostream &out, const anch::codec::MediaType &contentType, anch::codec::Side side) |
| static anch::rest::BodyStream | stream (const anch::rest::Form &form, const anch::codec::MediaType &contentType, anch::codec::Side side) |
| static void | deserialize (anch::rest::Form &form, std::istream &input, const anch::codec::MediaType &contentType, anch::codec::Side side) |
| template<anch::rest::FormMapped T> |
| static void | serialize (const T &value, std::ostream &out, const anch::codec::MediaType &contentType, anch::codec::Side side) |
| template<anch::rest::FormMapped T> |
| static anch::rest::BodyStream | stream (const T &value, const anch::codec::MediaType &contentType, anch::codec::Side side) |
| template<anch::rest::FormMapped T> |
| static void | deserialize (T &value, std::istream &input, const anch::codec::MediaType &contentType, anch::codec::Side side) |
multipart/form-data codec for Form (RFC 7578), parts in memory.
Writing: a random boundary is chosen by contentType (it does not appear in parts), names and file names are escaped as browsers do (double quote, CR and LF are percent-encoded), Content-Type is written for files and for fields which are not text/plain , other part headers are written as they are (CR and LF are refused).
Parts larger than FormLimits::maxMemoryPartSize are read in temporary files (deleted with their last Part copy) and file parts are written from their file: large bodies do not need memory. The client sends bodies with stream .
Reading: boundary parameter is required, delimiters end with CRLF, preamble and epilogue are ignored, close delimiter is required. Each part needs a Content-Disposition: form-data header with a name ; filename* (RFC 5987, UTF-8) has priority over filename . Part Content-Type is text/plain by default, application/octet-stream for files. Other part headers are kept ( Content-Transfer-Encoding is not applied). Malformed bodies raise std::invalid_argument ( 400 on server side), bodies over limits raise anch::codec::ContentTooLarge ( 413 ).
Types with a FormMapper are read and written through a Form .
return savePhoto(id, photo);
})
.consumes<anch::rest::Multipart>();
- Author
- Vincent Lachenal
- Since
- 0.2