p≡p MIME library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.5 KiB

  1. // This file is under GNU General Public License 3.0
  2. // see LICENSE.txt
  3. // Defines data structures for Content-Type, Content-Disposition and Content-Transfer-Encoding headers
  4. #ifndef PEP_MIME_MIME_HEADERS_HH
  5. #define PEP_MIME_MIME_HEADERS_HH
  6. #include "pEpMIME_internal.hh"
  7. namespace pEpMIME
  8. {
  9. struct ContentType
  10. {
  11. //ContentType() = default;
  12. explicit ContentType(sv header_line);
  13. std::string type;
  14. std::string subtype;
  15. std::vector<NameValue> tparams;
  16. void tolower(); // only for ASCII chars, but that's sufficient here.
  17. void sanitize()
  18. {
  19. tolower();
  20. if(type.empty()) { type = "text"; subtype="plain"; }
  21. }
  22. std::string mime_type() const { return type + "/" + subtype; }
  23. };
  24. struct ContentDisposition
  25. {
  26. explicit ContentDisposition(sv header_line);
  27. content_disposition_type dispo_type = PEP_CONTENT_DISP_INLINE;
  28. std::vector<NameValue> dparams;
  29. };
  30. struct MimeHeaders : public ContentType, public ContentDisposition
  31. {
  32. typedef char* (*Decoder)(const BodyLines&, size_t&);
  33. explicit MimeHeaders(const HeaderSection& headers);
  34. std::string transfer_encoding;
  35. Decoder decoder;
  36. };
  37. std::ostream& operator<<(std::ostream& o, const ContentType&);
  38. std::ostream& operator<<(std::ostream& o, const ContentDisposition&);
  39. std::ostream& operator<<(std::ostream& o, const MimeHeaders&);
  40. } // end of namespace pEpMIME
  41. #endif // PEP_MIME_MIME_HEADERS_HH