00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00020
00021 #ifndef NET_INSTAWEB_HTTP_PUBLIC_CONTENT_TYPE_H_
00022 #define NET_INSTAWEB_HTTP_PUBLIC_CONTENT_TYPE_H_
00023
00024 #include "net/instaweb/util/public/string.h"
00025 #include "net/instaweb/util/public/string_util.h"
00026
00027 namespace net_instaweb {
00028
00029 struct ContentType {
00030 public:
00031 enum Type {
00032 kHtml,
00033 kXhtml,
00034 kCeHtml,
00035 kJavascript,
00036 kCss,
00037 kText,
00038 kXml,
00039 kPng,
00040 kGif,
00041 kJpeg,
00042 kSwf,
00043 kWebp,
00044 };
00045
00049 static int MaxProducedExtensionLength();
00050
00051 const char* mime_type() const { return mime_type_; }
00053 const char* file_extension() const { return file_extension_; }
00054 Type type() const { return type_; }
00055
00058 bool IsHtmlLike() const;
00059
00062 bool IsXmlLike() const;
00063
00065 bool IsFlash() const;
00066
00068 bool IsImage() const;
00069
00073 const char* mime_type_;
00074 const char* file_extension_;
00075 Type type_;
00076 };
00077
00079 extern const ContentType& kContentTypeHtml;
00080 extern const ContentType& kContentTypeXhtml;
00081 extern const ContentType& kContentTypeCeHtml;
00083 extern const ContentType& kContentTypeJavascript;
00084 extern const ContentType& kContentTypeCss;
00085 extern const ContentType& kContentTypeText;
00086 extern const ContentType& kContentTypeXml;
00088 extern const ContentType& kContentTypePng;
00089 extern const ContentType& kContentTypeGif;
00090 extern const ContentType& kContentTypeJpeg;
00091 extern const ContentType& kContentTypeSwf;
00092 extern const ContentType& kContentTypeWebp;
00093
00096 const ContentType* NameExtensionToContentType(const StringPiece& name);
00097 const ContentType* MimeTypeToContentType(const StringPiece& mime_type);
00098
00104 bool ParseContentType(const StringPiece& content_type_str,
00105 GoogleString* mime_type,
00106 GoogleString* charset);
00107
00108 }
00109
00110 #endif ///< NET_INSTAWEB_HTTP_PUBLIC_CONTENT_TYPE_H_