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