diff --git a/http-message/ContentType.php b/http-message/ContentType.php index 8ee0d2c5..31c3f35a 100644 --- a/http-message/ContentType.php +++ b/http-message/ContentType.php @@ -6,367 +6,367 @@ namespace Http\Message; class ContentType { - const OPTION_X = 'application/x-'; - const OPTION_OCTET_STREAM = 'application/octet-stream'; - const OPTION_PDF = 'application/pdf'; - const OPTION_AI = 'application/postscript'; - const OPTION_ATOM_XML = 'application/atom+xml'; - const OPTION_JS = 'application/ecmascript'; - const OPTION_EDI_X12 = 'application/EDI-X12'; - const OPTION_EDIFACT = 'application/EDIFACT'; - const OPTION_JSON = 'application/json'; - const OPTION_JAVASCRIPT = 'application/javascript'; - const OPTION_OGG = 'application/ogg'; - const OPTION_RDF = 'application/rdf+xml'; - const OPTION_RSS_XML = 'application/rss+xml'; - const OPTION_SOAP_XML = 'application/soap+xml'; - const OPTION_WOFF = 'application/font-woff'; - const OPTION_XHTML_XML = 'application/xhtml+xml'; - const OPTION_XML = 'application/xml'; - const OPTION_DTD = 'application/xml-dtd'; - const OPTION_XOP_XML = 'application/xop+xml'; - const OPTION_ZIP = 'application/zip'; - const OPTION_GZIP = 'application/gzip'; - const OPTION_XLS = 'application/x-xls'; - const OPTION_001 = 'application/x-001'; - const OPTION_301 = 'application/x-301'; - const OPTION_906 = 'application/x-906'; - const OPTION_A11 = 'application/x-a11'; - const OPTION_AWF = 'application/vnd.adobe.workflow'; - const OPTION_BMP = 'application/x-bmp'; - const OPTION_C4T = 'application/x-c4t'; - const OPTION_CAL = 'application/x-cals'; - const OPTION_CDF = 'application/x-netcdf'; - const OPTION_CEL = 'application/x-cel'; - const OPTION_CG4 = 'application/x-g4'; - const OPTION_CIT = 'application/x-cit'; - const OPTION_BOT = 'application/x-bot'; - const OPTION_C90 = 'application/x-c90'; - const OPTION_CAT = 'application/vnd.ms-pki.seccat'; - const OPTION_CDR = 'application/x-cdr'; - const OPTION_CER = 'application/x-x509-ca-cert'; - const OPTION_CGM = 'application/x-cgm'; - const OPTION_CMX = 'application/x-cmx'; - const OPTION_CRL = 'application/pkix-crl'; - const OPTION_CSI = 'application/x-csi'; - const OPTION_CUT = 'application/x-cut'; - const OPTION_DBM = 'application/x-dbm'; - const OPTION_CMP = 'application/x-cmp'; - const OPTION_COT = 'application/x-cot'; - const OPTION_CRT = 'application/x-x509-ca-cert'; - const OPTION_DBF = 'application/x-dbf'; - const OPTION_DBX = 'application/x-dbx'; - const OPTION_DCX = 'application/x-dcx'; - const OPTION_DGN = 'application/x-dgn'; - const OPTION_DLL = 'application/x-msdownload'; - const OPTION_DOT = 'application/msword'; - const OPTION_DER = 'application/x-x509-ca-cert'; - const OPTION_DIB = 'application/x-dib'; - const OPTION_DOC = 'application/msword'; - const OPTION_DRW = 'application/x-drw'; - const OPTION_DWF = 'application/x-dwf'; - const OPTION_DXB = 'application/x-dxb'; - const OPTION_EDN = 'application/vnd.adobe.edn'; - const OPTION_DWG = 'application/x-dwg'; - const OPTION_DXF = 'application/x-dxf'; - const OPTION_EMF = 'application/x-emf'; - const OPTION_EPI = 'application/x-epi'; - const OPTION_EPS = 'application/postscript'; - const OPTION_EXE = 'application/x-msdownload'; - const OPTION_FDF = 'application/vnd.fdf'; - const OPTION_X_EPS = 'application/x-ps'; - const OPTION_ETD = 'application/x-ebx'; - const OPTION_FIF = 'application/fractals'; - const OPTION_FRM = 'application/x-frm'; - const OPTION_GBR = 'application/x-gbr'; - const OPTION_G4 = 'application/x-g4'; - const OPTION_GL2 = 'application/x-gl2'; - const OPTION_HGL = 'application/x-hgl'; - const OPTION_HPG = 'application/x-hpgl'; - const OPTION_HQX = 'application/mac-binhex40'; - const OPTION_HTA = 'application/hta'; - const OPTION_GP4 = 'application/x-gp4'; - const OPTION_HMR = 'application/x-hmr'; - const OPTION_HPL = 'application/x-hpl'; - const OPTION_HRF = 'application/x-hrf'; - const OPTION_ICB = 'application/x-icb'; - const OPTION_ICO = 'application/x-ico'; - const OPTION_IG4 = 'application/x-g4'; - const OPTION_III = 'application/x-iphone'; - const OPTION_INS = 'application/x-internet-signup'; - const OPTION_IFF = 'application/x-iff'; - const OPTION_IGS = 'application/x-igs'; - const OPTION_IMG = 'application/x-img'; - const OPTION_ISP = 'application/x-internet-signup'; - const OPTION_JPE = 'application/x-jpe'; - const OPTION_X_JAVASCRIPT = 'application/x-javascript'; - const OPTION_JPG = 'application/x-jpg'; - const OPTION_LAR = 'application/x-laplayer-reg'; - const OPTION_LATEX = 'application/x-latex'; - const OPTION_LBM = 'application/x-lbm'; - const OPTION_LS = 'application/x-javascript'; - const OPTION_LTR = 'application/x-ltr'; - const OPTION_MAN = 'application/x-troff-man'; - const OPTION_MDB = 'application/msaccess'; - const OPTION_MAC = 'application/x-mac'; - const OPTION_X_MDB = 'application/x-mdb'; - const OPTION_MFP = 'application/x-shockwave-flash'; - const OPTION_MI = 'application/x-mi'; - const OPTION_MIL = 'application/x-mil'; - const OPTION_MOCHA = 'application/x-javascript'; - const OPTION_MPD = 'application/vnd.ms-project'; - const OPTION_MPP = 'application/vnd.ms-project'; - const OPTION_MPT = 'application/vnd.ms-project'; - const OPTION_MPW = 'application/vnd.ms-project'; - const OPTION_MPX = 'application/vnd.ms-project'; - const OPTION_MXP = 'application/x-mmxp'; - const OPTION_NRF = 'application/x-nrf'; - const OPTION_OUT = 'application/x-out'; - const OPTION_P12 = 'application/x-pkcs12'; - const OPTION_P7C = 'application/pkcs7-mime'; - const OPTION_P7R = 'application/x-pkcs7-certreqresp'; - const OPTION_PC5 = 'application/x-pc5'; - const OPTION_PCL = 'application/x-pcl'; - const OPTION_PDX = 'application/vnd.adobe.pdx'; - const OPTION_PGL = 'application/x-pgl'; - const OPTION_PKO = 'application/vnd.ms-pki.pko'; - const OPTION_P10 = 'application/pkcs10'; - const OPTION_P7B = 'application/x-pkcs7-certificates'; - const OPTION_P7M = 'application/pkcs7-mime'; - const OPTION_P7S = 'application/pkcs7-signature'; - const OPTION_PCI = 'application/x-pci'; - const OPTION_PCX = 'application/x-pcx'; - const OPTION_PFX = 'application/x-pkcs12'; - const OPTION_PIC = 'application/x-pic'; - const OPTION_PL = 'application/x-perl'; - const OPTION_PLT = 'application/x-plt'; - const OPTION_PNG = 'application/x-png'; - const OPTION_PPA = 'application/vnd.ms-powerpoint'; - const OPTION_PPS = 'application/vnd.ms-powerpoint'; - const OPTION_X_PPT = 'application/x-ppt'; - const OPTION_PRF = 'application/pics-rules'; - const OPTION_PRT = 'application/x-prt'; - const OPTION_PS = 'application/postscript'; - const OPTION_PWZ = 'application/vnd.ms-powerpoint'; - const OPTION_RA = 'audio/vnd.rn-realaudio'; - const OPTION_RAS = 'application/x-ras'; - const OPTION_POT = 'application/vnd.ms-powerpoint'; - const OPTION_PPM = 'application/x-ppm'; - const OPTION_PPT = 'application/vnd.ms-powerpoint'; - const OPTION_PR = 'application/x-pr'; - const OPTION_PRN = 'application/x-prn'; - const OPTION_X_PS = 'application/x-ps'; - const OPTION_PTN = 'application/x-ptn'; - const OPTION_RED = 'application/x-red'; - const OPTION_RJS = 'application/vnd.rn-realsystem-rjs'; - const OPTION_RLC = 'application/x-rlc'; - const OPTION_RM = 'application/vnd.rn-realmedia'; - const OPTION_RAT = 'application/rat-file'; - const OPTION_REC = 'application/vnd.rn-recording'; - const OPTION_RGB = 'application/x-rgb'; - const OPTION_RJT = 'application/vnd.rn-realsystem-rjt'; - const OPTION_RLE = 'application/x-rle'; - const OPTION_RMF = 'application/vnd.adobe.rmf'; - const OPTION_RMJ = 'application/vnd.rn-realsystem-rmj'; - const OPTION_RMP = 'application/vnd.rn-rn_music_package'; - const OPTION_RMVB = 'application/vnd.rn-realmedia-vbr'; - const OPTION_RNX = 'application/vnd.rn-realplayer'; - const OPTION_RPM = 'audio/x-pn-realaudio-plugin'; - const OPTION_RMS = 'application/vnd.rn-realmedia-secure'; - const OPTION_RMX = 'application/vnd.rn-realsystem-rmx'; - const OPTION_RSML = 'application/vnd.rn-rsml'; - const OPTION_RTF = 'application/msword'; - const OPTION_RV = 'video/vnd.rn-realvideo'; - const OPTION_SAT = 'application/x-sat'; - const OPTION_SDW = 'application/x-sdw'; - const OPTION_SLB = 'application/x-slb'; - const OPTION_X_RTF = 'application/x-rtf'; - const OPTION_SAM = 'application/x-sam'; - const OPTION_SDP = 'application/sdp'; - const OPTION_SIT = 'application/x-stuffit'; - const OPTION_SLD = 'application/x-sld'; - const OPTION_SMI = 'application/smil'; - const OPTION_SMK = 'application/x-smk'; - const OPTION_SMIL = 'application/smil'; - const OPTION_SPC = 'application/x-pkcs7-certificates'; - const OPTION_SPL = 'application/futuresplash'; - const OPTION_SSM = 'application/streamingmedia'; - const OPTION_STL = 'application/vnd.ms-pki.stl'; - const OPTION_SST = 'application/vnd.ms-pki.certstore'; - const OPTION_TDF = 'application/x-tdf'; - const OPTION_TGA = 'application/x-tga'; - const OPTION_STY = 'application/x-sty'; - const OPTION_SWF = 'application/x-shockwave-flash'; - const OPTION_TG4 = 'application/x-tg4'; - const OPTION_TIF = 'application/x-tif'; - const OPTION_VDX = 'application/vnd.visio'; - const OPTION_VPG = 'application/x-vpeg005'; - const OPTION_VSD = 'application/x-vsd'; - const OPTION_VST = 'application/vnd.visio'; - const OPTION_VSW = 'application/vnd.visio'; - const OPTION_VTX = 'application/vnd.visio'; - const OPTION_TORRENT = 'application/x-bittorrent'; - const OPTION_VDA = 'application/x-vda'; - const OPTION_VND_VISIO = 'application/vnd.visio'; - const OPTION_VSS = 'application/vnd.visio'; - const OPTION_X_VST = 'application/x-vst'; - const OPTION_VSX = 'application/vnd.visio'; - const OPTION_WB1 = 'application/x-wb1'; - const OPTION_WB3 = 'application/x-wb3'; - const OPTION_WIZ = 'application/msword'; - const OPTION_WK4 = 'application/x-wk4'; - const OPTION_WKS = 'application/x-wks'; - const OPTION_WB2 = 'application/x-wb2'; - const OPTION_WK3 = 'application/x-wk3'; - const OPTION_WKQ = 'application/x-wkq'; - const OPTION_WMF = 'application/x-wmf'; - const OPTION_WMD = 'application/x-ms-wmd'; - const OPTION_WP6 = 'application/x-wp6'; - const OPTION_WPG = 'application/x-wpg'; - const OPTION_WQ1 = 'application/x-wq1'; - const OPTION_WRI = 'application/x-wri'; - const OPTION_WS = 'application/x-ws'; - const OPTION_WMZ = 'application/x-ms-wmz'; - const OPTION_WPD = 'application/x-wpd'; - const OPTION_WPL = 'application/vnd.ms-wpl'; - const OPTION_WR1 = 'application/x-wr1'; - const OPTION_WRK = 'application/x-wrk'; - const OPTION_WS2 = 'application/x-ws'; - const OPTION_XDP = 'application/vnd.adobe.xdp'; - const OPTION_XFD = 'application/vnd.adobe.xfd'; - const OPTION_XFDF = 'application/vnd.adobe.xfdf'; - const OPTION_VND_MS_EXCEL = 'application/vnd.ms-excel'; - const OPTION_XWD = 'application/x-xwd'; - const OPTION_SIS = 'application/vnd.symbian.install'; - const OPTION_X_T = 'application/x-x_t'; - const OPTION_APK = 'application/vnd.android.package-archive'; - const OPTION_X_B = 'application/x-x_b'; - const OPTION_SISX = 'application/vnd.symbian.install'; - const OPTION_IPA = 'application/vnd.iphone'; - const OPTION_XAP = 'application/x-silverlight-app'; - const OPTION_XLW = 'application/x-xlw'; - const OPTION_XPL = 'audio/scpls'; - const OPTION_ANV = 'application/x-anv'; - const OPTION_UIN = 'application/x-icq'; - const OPTION_323 = 'text/h323'; - const OPTION_BIZ = 'text/xml'; - const OPTION_CML = 'text/xml'; - const OPTION_ASA = 'text/asa'; - const OPTION_ASP = 'text/asp'; - const OPTION_CSS = 'text/css'; - const OPTION_CSV = 'text/csv'; - const OPTION_DCD = 'text/xml'; - const OPTION_X_DTD = 'text/xml'; - const OPTION_ENT = 'text/xml'; - const OPTION_FO = 'text/xml'; - const OPTION_HTC = 'text/x-component'; - const OPTION_HTML = 'text/html'; - const OPTION_HTX = 'text/html'; - const OPTION_HTM = 'text/html'; - const OPTION_HTT = 'text/webviewhtml'; - const OPTION_JSP = 'text/html'; - const OPTION_MATH = 'text/xml'; - const OPTION_MML = 'text/xml'; - const OPTION_MTX = 'text/xml'; - const OPTION_PLG = 'text/html'; - const OPTION_X_RDF = 'text/xml'; - const OPTION_RT = 'text/vnd.rn-realtext'; - const OPTION_SOL = 'text/plain'; - const OPTION_SPP = 'text/xml'; - const OPTION_STM = 'text/html'; - const OPTION_SVG = 'text/xml'; - const OPTION_TLD = 'text/xml'; - const OPTION_TXT = 'text/plain纯文字内容'; - const OPTION_ULS = 'text/iuls'; - const OPTION_VML = 'text/xml'; - const OPTION_TSD = 'text/xml'; - const OPTION_VCF = 'text/x-vcard'; - const OPTION_VXML = 'text/xml'; - const OPTION_WML = 'text/vnd.wap.wml'; - const OPTION_WSDL = 'text/xml'; - const OPTION_WSC = 'text/scriptlet'; - const OPTION_XDR = 'text/xml'; - const OPTION_XQL = 'text/xml'; - const OPTION_XSD = 'text/xml'; - const OPTION_XSLT = 'text/xml'; - const OPTION_X_XML = 'text/xml'; - const OPTION_XQ = 'text/xml'; - const OPTION_XQUERY = 'text/xml'; - const OPTION_XSL = 'text/xml'; - const OPTION_XHTML = 'text/html'; - const OPTION_ODC = 'text/x-ms-odc'; - const OPTION_R3T = 'text/vnd.rn-realtext3d'; - const OPTION_SOR = 'text/plain'; - const OPTION_ACP = 'audio/x-mei-aac'; - const OPTION_AIF = 'audio/aiff'; - const OPTION_AIFF = 'audio/aiff'; - const OPTION_AIFC = 'audio/aiff'; - const OPTION_AU = 'audio/basic'; - const OPTION_LA1 = 'audio/x-liquid-file'; - const OPTION_LAVS = 'audio/x-liquid-secure'; - const OPTION_LMSFF = 'audio/x-la-lms'; - const OPTION_M3U = 'audio/mpegurl'; - const OPTION_MIDI = 'audio/mid'; - const OPTION_MID = 'audio/mid'; - const OPTION_MP2 = 'audio/mp2'; - const OPTION_MP3 = 'audio/mp3'; - const OPTION_MP4 = 'audio/mp4'; - const OPTION_MND = 'audio/x-musicnet-download'; - const OPTION_MP1 = 'audio/mp1'; - const OPTION_MNS = 'audio/x-musicnet-stream'; - const OPTION_MPGA = 'audio/rn-mpeg'; - const OPTION_PLS = 'audio/scpls'; - const OPTION_RAM = 'audio/x-pn-realaudio'; - const OPTION_RMI = 'audio/mid'; - const OPTION_RMM = 'audio/x-pn-realaudio'; - const OPTION_SND = 'audio/basic'; - const OPTION_WAV = 'audio/wav'; - const OPTION_WAX = 'audio/x-ms-wax'; - const OPTION_WMA = 'audio/x-ms-wma'; - const OPTION_ASF = 'video/x-ms-asf'; - const OPTION_ASX = 'video/x-ms-asf'; - const OPTION_AVI = 'video/avi'; - const OPTION_IVF = 'video/x-ivf'; - const OPTION_M1V = 'video/x-mpeg'; - const OPTION_M2V = 'video/x-mpeg'; - const OPTION_M4E = 'video/mpeg4'; - const OPTION_MOVIE = 'video/x-sgi-movie'; - const OPTION_MP2V = 'video/mpeg'; - const OPTION_X_MP4 = 'video/mpeg4'; - const OPTION_MPA = 'video/x-mpg'; - const OPTION_MPE = 'video/x-mpeg'; - const OPTION_MPG = 'video/mpg'; - const OPTION_MPEG = 'video/mpg'; - const OPTION_MPS = 'video/x-mpeg'; - const OPTION_MPV = 'video/mpg'; - const OPTION_MPV2 = 'video/mpeg'; - const OPTION_WM = 'video/x-ms-wm'; - const OPTION_WMV = 'video/x-ms-wmv'; - const OPTION_WMX = 'video/x-ms-wmx'; - const OPTION_WVX = 'video/x-ms-wvx'; - const OPTION_TIFF = 'image/tiff'; - const OPTION_FAX = 'image/fax'; - const OPTION_GIF = 'image/gif'; - const OPTION_ICON = 'image/x-icon'; - const OPTION_JFIF = 'image/jpeg'; - const OPTION_X_JPE = 'image/jpeg'; - const OPTION_JPEG = 'image/jpeg'; - const OPTION_X_JPG = 'image/jpeg'; - const OPTION_NET = 'image/pnetvue'; - const OPTION_X_PNG = 'image/png'; - const OPTION_RP = 'image/vnd.rn-realpix'; - const OPTION_X_TIF = 'image/tiff'; - const OPTION_X_TIFF = 'image/tiff'; - const OPTION_WBMP = 'image/vnd.wap.wbmp'; - const OPTION_EML = 'message/rfc822'; - const OPTION_MHT = 'message/rfc822'; - const OPTION_MHTML = 'message/rfc822'; - const OPTION_NWS = 'message/rfc822'; - const OPTION_907 = 'drawing/907'; - const OPTION_SLK = 'drawing/x-slk'; - const OPTION_TOP = 'drawing/x-top'; - const OPTION_CLASS = 'java/*'; - const OPTION_JAVA = 'java/*'; - const OPTION_X_DWF = 'Model/vnd.dwf'; + const X = 'application/x-'; + const OCTET_STREAM = 'application/octet-stream'; + const PDF = 'application/pdf'; + const AI = 'application/postscript'; + const ATOM_XML = 'application/atom+xml'; + const JS = 'application/ecmascript'; + const EDI_X12 = 'application/EDI-X12'; + const EDIFACT = 'application/EDIFACT'; + const JSON = 'application/json'; + const JAVASCRIPT = 'application/javascript'; + const OGG = 'application/ogg'; + const RDF = 'application/rdf+xml'; + const RSS_XML = 'application/rss+xml'; + const SOAP_XML = 'application/soap+xml'; + const WOFF = 'application/font-woff'; + const XHTML_XML = 'application/xhtml+xml'; + const XML = 'application/xml'; + const DTD = 'application/xml-dtd'; + const XOP_XML = 'application/xop+xml'; + const ZIP = 'application/zip'; + const GZIP = 'application/gzip'; + const XLS = 'application/x-xls'; + const X_001 = 'application/x-001'; + const X_301 = 'application/x-301'; + const X_906 = 'application/x-906'; + const A11 = 'application/x-a11'; + const AWF = 'application/vnd.adobe.workflow'; + const BMP = 'application/x-bmp'; + const C4T = 'application/x-c4t'; + const CAL = 'application/x-cals'; + const CDF = 'application/x-netcdf'; + const CEL = 'application/x-cel'; + const CG4 = 'application/x-g4'; + const CIT = 'application/x-cit'; + const BOT = 'application/x-bot'; + const C90 = 'application/x-c90'; + const CAT = 'application/vnd.ms-pki.seccat'; + const CDR = 'application/x-cdr'; + const CER = 'application/x-x509-ca-cert'; + const CGM = 'application/x-cgm'; + const CMX = 'application/x-cmx'; + const CRL = 'application/pkix-crl'; + const CSI = 'application/x-csi'; + const CUT = 'application/x-cut'; + const DBM = 'application/x-dbm'; + const CMP = 'application/x-cmp'; + const COT = 'application/x-cot'; + const CRT = 'application/x-x509-ca-cert'; + const DBF = 'application/x-dbf'; + const DBX = 'application/x-dbx'; + const DCX = 'application/x-dcx'; + const DGN = 'application/x-dgn'; + const DLL = 'application/x-msdownload'; + const DOT = 'application/msword'; + const DER = 'application/x-x509-ca-cert'; + const DIB = 'application/x-dib'; + const DOC = 'application/msword'; + const DRW = 'application/x-drw'; + const DWF = 'application/x-dwf'; + const DXB = 'application/x-dxb'; + const EDN = 'application/vnd.adobe.edn'; + const DWG = 'application/x-dwg'; + const DXF = 'application/x-dxf'; + const EMF = 'application/x-emf'; + const EPI = 'application/x-epi'; + const EPS = 'application/postscript'; + const EXE = 'application/x-msdownload'; + const FDF = 'application/vnd.fdf'; + const X_EPS = 'application/x-ps'; + const ETD = 'application/x-ebx'; + const FIF = 'application/fractals'; + const FRM = 'application/x-frm'; + const GBR = 'application/x-gbr'; + const G4 = 'application/x-g4'; + const GL2 = 'application/x-gl2'; + const HGL = 'application/x-hgl'; + const HPG = 'application/x-hpgl'; + const HQX = 'application/mac-binhex40'; + const HTA = 'application/hta'; + const GP4 = 'application/x-gp4'; + const HMR = 'application/x-hmr'; + const HPL = 'application/x-hpl'; + const HRF = 'application/x-hrf'; + const ICB = 'application/x-icb'; + const ICO = 'application/x-ico'; + const IG4 = 'application/x-g4'; + const III = 'application/x-iphone'; + const INS = 'application/x-internet-signup'; + const IFF = 'application/x-iff'; + const IGS = 'application/x-igs'; + const IMG = 'application/x-img'; + const ISP = 'application/x-internet-signup'; + const JPE = 'application/x-jpe'; + const X_JAVASCRIPT = 'application/x-javascript'; + const JPG = 'application/x-jpg'; + const LAR = 'application/x-laplayer-reg'; + const LATEX = 'application/x-latex'; + const LBM = 'application/x-lbm'; + const LS = 'application/x-javascript'; + const LTR = 'application/x-ltr'; + const MAN = 'application/x-troff-man'; + const MDB = 'application/msaccess'; + const MAC = 'application/x-mac'; + const X_MDB = 'application/x-mdb'; + const MFP = 'application/x-shockwave-flash'; + const MI = 'application/x-mi'; + const MIL = 'application/x-mil'; + const MOCHA = 'application/x-javascript'; + const MPD = 'application/vnd.ms-project'; + const MPP = 'application/vnd.ms-project'; + const MPT = 'application/vnd.ms-project'; + const MPW = 'application/vnd.ms-project'; + const MPX = 'application/vnd.ms-project'; + const MXP = 'application/x-mmxp'; + const NRF = 'application/x-nrf'; + const OUT = 'application/x-out'; + const P12 = 'application/x-pkcs12'; + const P7C = 'application/pkcs7-mime'; + const P7R = 'application/x-pkcs7-certreqresp'; + const PC5 = 'application/x-pc5'; + const PCL = 'application/x-pcl'; + const PDX = 'application/vnd.adobe.pdx'; + const PGL = 'application/x-pgl'; + const PKO = 'application/vnd.ms-pki.pko'; + const P10 = 'application/pkcs10'; + const P7B = 'application/x-pkcs7-certificates'; + const P7M = 'application/pkcs7-mime'; + const P7S = 'application/pkcs7-signature'; + const PCI = 'application/x-pci'; + const PCX = 'application/x-pcx'; + const PFX = 'application/x-pkcs12'; + const PIC = 'application/x-pic'; + const PL = 'application/x-perl'; + const PLT = 'application/x-plt'; + const PNG = 'application/x-png'; + const PPA = 'application/vnd.ms-powerpoint'; + const PPS = 'application/vnd.ms-powerpoint'; + const X_PPT = 'application/x-ppt'; + const PRF = 'application/pics-rules'; + const PRT = 'application/x-prt'; + const PS = 'application/postscript'; + const PWZ = 'application/vnd.ms-powerpoint'; + const RA = 'audio/vnd.rn-realaudio'; + const RAS = 'application/x-ras'; + const POT = 'application/vnd.ms-powerpoint'; + const PPM = 'application/x-ppm'; + const PPT = 'application/vnd.ms-powerpoint'; + const PR = 'application/x-pr'; + const PRN = 'application/x-prn'; + const X_PS = 'application/x-ps'; + const PTN = 'application/x-ptn'; + const RED = 'application/x-red'; + const RJS = 'application/vnd.rn-realsystem-rjs'; + const RLC = 'application/x-rlc'; + const RM = 'application/vnd.rn-realmedia'; + const RAT = 'application/rat-file'; + const REC = 'application/vnd.rn-recording'; + const RGB = 'application/x-rgb'; + const RJT = 'application/vnd.rn-realsystem-rjt'; + const RLE = 'application/x-rle'; + const RMF = 'application/vnd.adobe.rmf'; + const RMJ = 'application/vnd.rn-realsystem-rmj'; + const RMP = 'application/vnd.rn-rn_music_package'; + const RMVB = 'application/vnd.rn-realmedia-vbr'; + const RNX = 'application/vnd.rn-realplayer'; + const RPM = 'audio/x-pn-realaudio-plugin'; + const RMS = 'application/vnd.rn-realmedia-secure'; + const RMX = 'application/vnd.rn-realsystem-rmx'; + const RSML = 'application/vnd.rn-rsml'; + const RTF = 'application/msword'; + const RV = 'video/vnd.rn-realvideo'; + const SAT = 'application/x-sat'; + const SDW = 'application/x-sdw'; + const SLB = 'application/x-slb'; + const X_RTF = 'application/x-rtf'; + const SAM = 'application/x-sam'; + const SDP = 'application/sdp'; + const SIT = 'application/x-stuffit'; + const SLD = 'application/x-sld'; + const SMI = 'application/smil'; + const SMK = 'application/x-smk'; + const SMIL = 'application/smil'; + const SPC = 'application/x-pkcs7-certificates'; + const SPL = 'application/futuresplash'; + const SSM = 'application/streamingmedia'; + const STL = 'application/vnd.ms-pki.stl'; + const SST = 'application/vnd.ms-pki.certstore'; + const TDF = 'application/x-tdf'; + const TGA = 'application/x-tga'; + const STY = 'application/x-sty'; + const SWF = 'application/x-shockwave-flash'; + const TG4 = 'application/x-tg4'; + const TIF = 'application/x-tif'; + const VDX = 'application/vnd.visio'; + const VPG = 'application/x-vpeg005'; + const VSD = 'application/x-vsd'; + const VST = 'application/vnd.visio'; + const VSW = 'application/vnd.visio'; + const VTX = 'application/vnd.visio'; + const TORRENT = 'application/x-bittorrent'; + const VDA = 'application/x-vda'; + const VND_VISIO = 'application/vnd.visio'; + const VSS = 'application/vnd.visio'; + const X_VST = 'application/x-vst'; + const VSX = 'application/vnd.visio'; + const WB1 = 'application/x-wb1'; + const WB3 = 'application/x-wb3'; + const WIZ = 'application/msword'; + const WK4 = 'application/x-wk4'; + const WKS = 'application/x-wks'; + const WB2 = 'application/x-wb2'; + const WK3 = 'application/x-wk3'; + const WKQ = 'application/x-wkq'; + const WMF = 'application/x-wmf'; + const WMD = 'application/x-ms-wmd'; + const WP6 = 'application/x-wp6'; + const WPG = 'application/x-wpg'; + const WQ1 = 'application/x-wq1'; + const WRI = 'application/x-wri'; + const WS = 'application/x-ws'; + const WMZ = 'application/x-ms-wmz'; + const WPD = 'application/x-wpd'; + const WPL = 'application/vnd.ms-wpl'; + const WR1 = 'application/x-wr1'; + const WRK = 'application/x-wrk'; + const WS2 = 'application/x-ws'; + const XDP = 'application/vnd.adobe.xdp'; + const XFD = 'application/vnd.adobe.xfd'; + const XFDF = 'application/vnd.adobe.xfdf'; + const VND_MS_EXCEL = 'application/vnd.ms-excel'; + const XWD = 'application/x-xwd'; + const SIS = 'application/vnd.symbian.install'; + const X_T = 'application/x-x_t'; + const APK = 'application/vnd.android.package-archive'; + const X_B = 'application/x-x_b'; + const SISX = 'application/vnd.symbian.install'; + const IPA = 'application/vnd.iphone'; + const XAP = 'application/x-silverlight-app'; + const XLW = 'application/x-xlw'; + const XPL = 'audio/scpls'; + const ANV = 'application/x-anv'; + const UIN = 'application/x-icq'; + const H323 = 'text/h323'; + const BIZ = 'text/xml'; + const CML = 'text/xml'; + const ASA = 'text/asa'; + const ASP = 'text/asp'; + const CSS = 'text/css'; + const CSV = 'text/csv'; + const DCD = 'text/xml'; + const X_DTD = 'text/xml'; + const ENT = 'text/xml'; + const FO = 'text/xml'; + const HTC = 'text/x-component'; + const HTML = 'text/html'; + const HTX = 'text/html'; + const HTM = 'text/html'; + const HTT = 'text/webviewhtml'; + const JSP = 'text/html'; + const MATH = 'text/xml'; + const MML = 'text/xml'; + const MTX = 'text/xml'; + const PLG = 'text/html'; + const X_RDF = 'text/xml'; + const RT = 'text/vnd.rn-realtext'; + const SOL = 'text/plain'; + const SPP = 'text/xml'; + const STM = 'text/html'; + const SVG = 'text/xml'; + const TLD = 'text/xml'; + const TXT = 'text/plain纯文字内容'; + const ULS = 'text/iuls'; + const VML = 'text/xml'; + const TSD = 'text/xml'; + const VCF = 'text/x-vcard'; + const VXML = 'text/xml'; + const WML = 'text/vnd.wap.wml'; + const WSDL = 'text/xml'; + const WSC = 'text/scriptlet'; + const XDR = 'text/xml'; + const XQL = 'text/xml'; + const XSD = 'text/xml'; + const XSLT = 'text/xml'; + const X_XML = 'text/xml'; + const XQ = 'text/xml'; + const XQUERY = 'text/xml'; + const XSL = 'text/xml'; + const XHTML = 'text/html'; + const ODC = 'text/x-ms-odc'; + const R3T = 'text/vnd.rn-realtext3d'; + const SOR = 'text/plain'; + const ACP = 'audio/x-mei-aac'; + const AIF = 'audio/aiff'; + const AIFF = 'audio/aiff'; + const AIFC = 'audio/aiff'; + const AU = 'audio/basic'; + const LA1 = 'audio/x-liquid-file'; + const LAVS = 'audio/x-liquid-secure'; + const LMSFF = 'audio/x-la-lms'; + const M3U = 'audio/mpegurl'; + const MIDI = 'audio/mid'; + const MID = 'audio/mid'; + const MP2 = 'audio/mp2'; + const MP3 = 'audio/mp3'; + const MP4 = 'audio/mp4'; + const MND = 'audio/x-musicnet-download'; + const MP1 = 'audio/mp1'; + const MNS = 'audio/x-musicnet-stream'; + const MPGA = 'audio/rn-mpeg'; + const PLS = 'audio/scpls'; + const RAM = 'audio/x-pn-realaudio'; + const RMI = 'audio/mid'; + const RMM = 'audio/x-pn-realaudio'; + const SND = 'audio/basic'; + const WAV = 'audio/wav'; + const WAX = 'audio/x-ms-wax'; + const WMA = 'audio/x-ms-wma'; + const ASF = 'video/x-ms-asf'; + const ASX = 'video/x-ms-asf'; + const AVI = 'video/avi'; + const IVF = 'video/x-ivf'; + const M1V = 'video/x-mpeg'; + const M2V = 'video/x-mpeg'; + const M4E = 'video/mpeg4'; + const MOVIE = 'video/x-sgi-movie'; + const MP2V = 'video/mpeg'; + const X_MP4 = 'video/mpeg4'; + const MPA = 'video/x-mpg'; + const MPE = 'video/x-mpeg'; + const MPG = 'video/mpg'; + const MPEG = 'video/mpg'; + const MPS = 'video/x-mpeg'; + const MPV = 'video/mpg'; + const MPV2 = 'video/mpeg'; + const WM = 'video/x-ms-wm'; + const WMV = 'video/x-ms-wmv'; + const WMX = 'video/x-ms-wmx'; + const WVX = 'video/x-ms-wvx'; + const TIFF = 'image/tiff'; + const FAX = 'image/fax'; + const GIF = 'image/gif'; + const ICON = 'image/x-icon'; + const JFIF = 'image/jpeg'; + const X_JPE = 'image/jpeg'; + const JPEG = 'image/jpeg'; + const X_JPG = 'image/jpeg'; + const NET = 'image/pnetvue'; + const X_PNG = 'image/png'; + const RP = 'image/vnd.rn-realpix'; + const X_TIF = 'image/tiff'; + const X_TIFF = 'image/tiff'; + const WBMP = 'image/vnd.wap.wbmp'; + const EML = 'message/rfc822'; + const MHT = 'message/rfc822'; + const MHTML = 'message/rfc822'; + const NWS = 'message/rfc822'; + const D_907 = 'drawing/907'; + const SLK = 'drawing/x-slk'; + const TOP = 'drawing/x-top'; + const CLASS = 'java/*'; + const JAVA = 'java/*'; + const X_DWF = 'Model/vnd.dwf'; } diff --git a/http-message/Response.php b/http-message/Response.php index ebceebd8..8d85b386 100644 --- a/http-message/Response.php +++ b/http-message/Response.php @@ -19,7 +19,10 @@ class Response implements ResponseInterface use Message; - const CONTENT_TYPE_HTML = 'text/html;charset=utf-8'; + const CONTENT_TYPE_HTML = 'text/html'; + + + protected string $charset = 'utf8'; protected int $statusCode = 200; @@ -148,7 +151,7 @@ class Response implements ResponseInterface * @param string $contentType * @return static */ - public function json($data, string $contentType = 'application/json;charset=utf-8'): static + public function json($data, string $contentType = 'application/json'): static { $this->stream->write(json_encode($data)); @@ -161,7 +164,7 @@ class Response implements ResponseInterface * @param string $contentType * @return static */ - public function html($data, string $contentType = 'text/html;charset=utf-8'): static + public function html($data, string $contentType = 'text/html'): static { if (!is_string($data)) { $data = json_encode($data); @@ -178,7 +181,7 @@ class Response implements ResponseInterface * @param string $contentType * @return static */ - public function xml($data, string $contentType = 'application/xml;charset=utf-8'): static + public function xml($data, string $contentType = 'application/xml'): static { $this->stream->write(Help::toXml($data)); @@ -186,6 +189,20 @@ class Response implements ResponseInterface } + /** + * @param string $charset + * @return $this + */ + public function withCharset(string $charset): static + { + $type = explode('charset', $this->getContentType())[0]; + $this->withContentType( + rtrim($type,';') . ';charset=' . $charset + ); + return $this; + } + + /** * @param $path * @param bool $isChunk diff --git a/http-server/Worker/OnTaskerStart.php b/http-server/Abstracts/OnTaskerStart.php similarity index 95% rename from http-server/Worker/OnTaskerStart.php rename to http-server/Abstracts/OnTaskerStart.php index 072105c8..b3c6a161 100644 --- a/http-server/Worker/OnTaskerStart.php +++ b/http-server/Abstracts/OnTaskerStart.php @@ -1,6 +1,6 @@ withContentType($contentType)->withCharset('utf-8'); + } + + + /** * @param string $name * @return mixed */ diff --git a/http-server/Constrict/ResponseEmitter.php b/http-server/Constrict/ResponseEmitter.php index acb3183a..76c41143 100644 --- a/http-server/Constrict/ResponseEmitter.php +++ b/http-server/Constrict/ResponseEmitter.php @@ -22,7 +22,7 @@ class ResponseEmitter implements Emitter /** - * @param mixed $response + * @param \Swoole\Http\Response $response * @param \Http\Message\Response|ResponseInterface $emitter * @throws \Exception */ diff --git a/http-server/ExceptionHandlerDispatcher.php b/http-server/ExceptionHandlerDispatcher.php index bb865112..9b30329d 100644 --- a/http-server/ExceptionHandlerDispatcher.php +++ b/http-server/ExceptionHandlerDispatcher.php @@ -3,6 +3,7 @@ namespace Server; +use Http\Message\ContentType; use Http\Message\Stream; use Server\Constrict\Response; use Server\Constrict\ResponseInterface; @@ -23,7 +24,7 @@ class ExceptionHandlerDispatcher implements ExceptionHandlerInterface */ public function emit(Throwable $exception, Response $response): ResponseInterface { - $response->withContentType('text/html;charset=utf-8'); + $response->withContentType(ContentType::HTML)->withCharset('utf-8'); if ($exception->getCode() == 404) { return $response->withBody(new Stream($exception->getMessage())) ->withStatus(404); diff --git a/http-server/ServerCommand.php b/http-server/ServerCommand.php index 2c57a7d0..43490da8 100644 --- a/http-server/ServerCommand.php +++ b/http-server/ServerCommand.php @@ -13,8 +13,8 @@ use Server\Events\OnBeforeWorkerStart; use Server\Events\OnTaskerStart; use Server\Events\OnWorkerStart; use Server\Worker\OnServerWorker; -use Server\Worker\OnWorkerStart as WorkerDispatch; -use Server\Worker\OnTaskerStart as TaskerDispatch; +use Server\Abstracts\OnWorkerStart as WorkerDispatch; +use Server\Abstracts\OnTaskerStart as TaskerDispatch; use Swoole\Coroutine; use Swoole\Runtime; use Symfony\Component\Console\Command\Command; diff --git a/http-server/Service/Http.php b/http-server/Service/Http.php index f0562569..5d17d27c 100644 --- a/http-server/Service/Http.php +++ b/http-server/Service/Http.php @@ -9,6 +9,7 @@ use Http\Handler\Context; use Http\Handler\Abstracts\HandlerManager; use Http\Handler\Dispatcher; use Http\Handler\Handler; +use Http\Message\ContentType; use Http\Message\ServerRequest; use Http\Message\Stream; use Http\Handler\Abstracts\MiddlewareManager; @@ -58,9 +59,7 @@ class Http extends \Server\Abstracts\Http implements OnClose, OnConnect $PsrResponse = $this->handler($handler, $PsrRequest); } } catch (\Throwable $throwable) { - $PsrResponse = $this->response->withStatus($throwable->getCode()) - ->withContentType(\Http\Message\Response::CONTENT_TYPE_HTML) - ->withBody(new Stream(jTraceEx($throwable, null, true))); + $PsrResponse= $this->exceptionHandler->emit($throwable, $this->response); } finally { $this->responseEmitter->sender($response, $PsrResponse); } diff --git a/http-server/Worker/OnServerWorker.php b/http-server/Worker/OnServerWorker.php index 50aad95e..2c9aefd7 100644 --- a/http-server/Worker/OnServerWorker.php +++ b/http-server/Worker/OnServerWorker.php @@ -7,7 +7,6 @@ use Exception; use Kiri\Abstracts\Config; use Kiri\Core\Help; use Kiri\Events\EventDispatch; -use Kiri\Kiri; use Kiri\Runtime; use Server\Events\OnAfterWorkerStart; use Server\Events\OnBeforeWorkerStart;