加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
php_swoole_library.h 229.57 KB
一键复制 编辑 原始数据 按行查看 历史
韩天峰 提交于 2020-06-20 21:18 . Add Co\Socket event barrier (#3409)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621
/**
* Generated by build-library.php, Please DO NOT modify!
*/
/* $Id: 7891ead72d2b43bb6ded221fca5a8d6764ff82ac */
static const char* swoole_library_source_constants =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"define('SWOOLE_LIBRARY', true);\n";
static const char* swoole_library_source_std_exec =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"function swoole_exec(string $command, &$output = null, &$returnVar = null)\n"
"{\n"
" $result = Swoole\\Coroutine::exec($command);\n"
" if ($result) {\n"
" $outputList = explode(PHP_EOL, $result['output']);\n"
" foreach ($outputList as &$value) {\n"
" $value = rtrim($value);\n"
" }\n"
" if (($endLine = end($outputList)) === '') {\n"
" array_pop($outputList);\n"
" $endLine = end($outputList);\n"
" }\n"
" if ($output) {\n"
" $output = array_merge($output, $outputList);\n"
" } else {\n"
" $output = $outputList;\n"
" }\n"
" $returnVar = $result['code'];\n"
" return $endLine;\n"
" }\n"
" return false;\n"
"}\n"
"\n"
"function swoole_shell_exec(string $cmd)\n"
"{\n"
" $result = Swoole\\Coroutine::exec($cmd);\n"
" if ($result && $result['output'] !== '') {\n"
" return $result['output'];\n"
" }\n"
" return null;\n"
"}\n";
static const char* swoole_library_source_core_constant =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole;\n"
"\n"
"class Constant\n"
"{\n"
" public const EVENT_RECEIVE = 'receive';\n"
"\n"
" public const EVENT_CONNECT = 'connect';\n"
"\n"
" public const EVENT_CLOSE = 'close';\n"
"\n"
" public const EVENT_PACKET = 'packet';\n"
"\n"
" public const EVENT_REQUEST = 'request';\n"
"\n"
" public const EVENT_MESSAGE = 'message';\n"
"\n"
" public const EVENT_OPEN = 'open';\n"
"\n"
" public const EVENT_HANDSHAKE = 'handshake';\n"
"\n"
" public const EVENT_TASK = 'task';\n"
"\n"
" public const EVENT_FINISH = 'finish';\n"
"\n"
" public const EVENT_START = 'start';\n"
"\n"
" public const EVENT_SHUTDOWN = 'shutdown';\n"
"\n"
" public const EVENT_WORKER_START = 'workerStart';\n"
"\n"
" public const EVENT_WORKER_EXIT = 'workerExit';\n"
"\n"
" public const EVENT_WORKER_ERROR = 'workerError';\n"
"\n"
" public const EVENT_WORKER_STOP = 'workerStop';\n"
"\n"
" public const EVENT_PIPE_MESSAGE = 'pipeMessage';\n"
"\n"
" public const EVENT_MANAGER_START = 'managerStart';\n"
"\n"
" public const EVENT_MANAGER_STOP = 'managerStop';\n"
"\n"
" public const EVENT_ERROR = 'error';\n"
"\n"
" /* {{{ OPTION */\n"
" public const OPTION_DEBUG_MODE = 'debug_mode';\n"
"\n"
" public const OPTION_TRACE_FLAGS = 'trace_flags';\n"
"\n"
" public const OPTION_LOG_FILE = 'log_file';\n"
"\n"
" public const OPTION_LOG_LEVEL = 'log_level';\n"
"\n"
" public const OPTION_LOG_DATE_FORMAT = 'log_date_format';\n"
"\n"
" public const OPTION_LOG_DATE_WITH_MICROSECONDS = 'log_date_with_microseconds';\n"
"\n"
" public const OPTION_LOG_ROTATION = 'log_rotation';\n"
"\n"
" public const OPTION_DISPLAY_ERRORS = 'display_errors';\n"
"\n"
" public const OPTION_DNS_SERVER = 'dns_server';\n"
"\n"
" public const OPTION_SOCKET_SEND_TIMEOUT = 'socket_send_timeout';\n"
"\n"
" public const OPTION_ENABLE_SIGNALFD = 'enable_signalfd';\n"
"\n"
" public const OPTION_WAIT_SIGNAL = 'wait_signal';\n"
"\n"
" public const OPTION_DNS_CACHE_REFRESH_TIME = 'dns_cache_refresh_time';\n"
"\n"
" public const OPTION_SOCKET_BUFFER_SIZE = 'socket_buffer_size';\n"
"\n"
" public const OPTION_THREAD_NUM = 'thread_num';\n"
"\n"
" public const OPTION_MIN_THREAD_NUM = 'min_thread_num';\n"
"\n"
" public const OPTION_MAX_THREAD_NUM = 'max_thread_num';\n"
"\n"
" public const OPTION_SOCKET_DONTWAIT = 'socket_dontwait';\n"
"\n"
" public const OPTION_DNS_LOOKUP_RANDOM = 'dns_lookup_random';\n"
"\n"
" public const OPTION_USE_ASYNC_RESOLVER = 'use_async_resolver';\n"
"\n"
" public const OPTION_ENABLE_COROUTINE = 'enable_coroutine';\n"
"\n"
" public const OPTION_SSL_METHOD = 'ssl_method';\n"
"\n"
" public const OPTION_SSL_PROTOCOLS = 'ssl_protocols';\n"
"\n"
" public const OPTION_SSL_COMPRESS = 'ssl_compress';\n"
"\n"
" public const OPTION_SSL_CERT_FILE = 'ssl_cert_file';\n"
"\n"
" public const OPTION_SSL_KEY_FILE = 'ssl_key_file';\n"
"\n"
" public const OPTION_SSL_PASSPHRASE = 'ssl_passphrase';\n"
"\n"
" public const OPTION_SSL_HOST_NAME = 'ssl_host_name';\n"
"\n"
" public const OPTION_SSL_VERIFY_PEER = 'ssl_verify_peer';\n"
"\n"
" public const OPTION_SSL_ALLOW_SELF_SIGNED = 'ssl_allow_self_signed';\n"
"\n"
" public const OPTION_SSL_CAFILE = 'ssl_cafile';\n"
"\n"
" public const OPTION_SSL_CAPATH = 'ssl_capath';\n"
"\n"
" public const OPTION_SSL_VERIFY_DEPTH = 'ssl_verify_depth';\n"
"\n"
" public const OPTION_OPEN_EOF_CHECK = 'open_eof_check';\n"
"\n"
" public const OPTION_OPEN_EOF_SPLIT = 'open_eof_split';\n"
"\n"
" public const OPTION_PACKAGE_EOF = 'package_eof';\n"
"\n"
" public const OPTION_OPEN_MQTT_PROTOCOL = 'open_mqtt_protocol';\n"
"\n"
" public const OPTION_OPEN_LENGTH_CHECK = 'open_length_check';\n"
"\n"
" public const OPTION_PACKAGE_LENGTH_TYPE = 'package_length_type';\n"
"\n"
" public const OPTION_PACKAGE_LENGTH_OFFSET = 'package_length_offset';\n"
"\n"
" public const OPTION_PACKAGE_BODY_OFFSET = 'package_body_offset';\n"
"\n"
" public const OPTION_PACKAGE_LENGTH_FUNC = 'package_length_func';\n"
"\n"
" public const OPTION_PACKAGE_MAX_LENGTH = 'package_max_length';\n"
"\n"
" public const OPTION_BUFFER_HIGH_WATERMARK = 'buffer_high_watermark';\n"
"\n"
" public const OPTION_BUFFER_LOW_WATERMARK = 'buffer_low_watermark';\n"
"\n"
" public const OPTION_BIND_PORT = 'bind_port';\n"
"\n"
" public const OPTION_BIND_ADDRESS = 'bind_address';\n"
"\n"
" public const OPTION_OPEN_TCP_NODELAY = 'open_tcp_nodelay';\n"
"\n"
" public const OPTION_SOCKS5_HOST = 'socks5_host';\n"
"\n"
" public const OPTION_SOCKS5_PORT = 'socks5_port';\n"
"\n"
" public const OPTION_SOCKS5_USERNAME = 'socks5_username';\n"
"\n"
" public const OPTION_SOCKS5_PASSWORD = 'socks5_password';\n"
"\n"
" public const OPTION_HTTP_PROXY_HOST = 'http_proxy_host';\n"
"\n"
" public const OPTION_HTTP_PROXY_PORT = 'http_proxy_port';\n"
"\n"
" public const OPTION_HTTP_PROXY_USERNAME = 'http_proxy_username';\n"
"\n"
" public const OPTION_HTTP_PROXY_USER = 'http_proxy_user';\n"
"\n"
" public const OPTION_HTTP_PROXY_PASSWORD = 'http_proxy_password';\n"
"\n"
" public const OPTION_TIMEOUT = 'timeout';\n"
"\n"
" public const OPTION_CONNECT_TIMEOUT = 'connect_timeout';\n"
"\n"
" public const OPTION_READ_TIMEOUT = 'read_timeout';\n"
"\n"
" public const OPTION_WRITE_TIMEOUT = 'write_timeout';\n"
"\n"
" public const OPTION_SSL_DISABLE_COMPRESSION = 'ssl_disable_compression';\n"
"\n"
" public const OPTION_MAX_COROUTINE = 'max_coroutine';\n"
"\n"
" public const OPTION_HOOK_FLAGS = 'hook_flags';\n"
"\n"
" public const OPTION_ENABLE_PREEMPTIVE_SCHEDULER = 'enable_preemptive_scheduler';\n"
"\n"
" public const OPTION_C_STACK_SIZE = 'c_stack_size';\n"
"\n"
" public const OPTION_STACK_SIZE = 'stack_size';\n"
"\n"
" public const OPTION_SOCKET_DNS_TIMEOUT = 'socket_dns_timeout';\n"
"\n"
" public const OPTION_SOCKET_CONNECT_TIMEOUT = 'socket_connect_timeout';\n"
"\n"
" public const OPTION_SOCKET_TIMEOUT = 'socket_timeout';\n"
"\n"
" public const OPTION_SOCKET_READ_TIMEOUT = 'socket_read_timeout';\n"
"\n"
" public const OPTION_SOCKET_WRITE_TIMEOUT = 'socket_write_timeout';\n"
"\n"
" public const OPTION_DNS_CACHE_EXPIRE = 'dns_cache_expire';\n"
"\n"
" public const OPTION_DNS_CACHE_CAPACITY = 'dns_cache_capacity';\n"
"\n"
" public const OPTION_AIO_CORE_WORKER_NUM = 'aio_core_worker_num';\n"
"\n"
" public const OPTION_AIO_WORKER_NUM = 'aio_worker_num';\n"
"\n"
" public const OPTION_AIO_MAX_WAIT_TIME = 'aio_max_wait_time';\n"
"\n"
" public const OPTION_AIO_MAX_IDLE_TIME = 'aio_max_idle_time';\n"
"\n"
" public const OPTION_RECONNECT = 'reconnect';\n"
"\n"
" public const OPTION_DEFER = 'defer';\n"
"\n"
" public const OPTION_KEEP_ALIVE = 'keep_alive';\n"
"\n"
" public const OPTION_WEBSOCKET_MASK = 'websocket_mask';\n"
"\n"
" public const OPTION_WEBSOCKET_COMPRESSION = 'websocket_compression';\n"
"\n"
" public const OPTION_HTTP_PARSE_COOKIE = 'http_parse_cookie';\n"
"\n"
" public const OPTION_HTTP_PARSE_POST = 'http_parse_post';\n"
"\n"
" public const OPTION_HTTP_PARSE_FILES = 'http_parse_files';\n"
"\n"
" public const OPTION_HTTP_COMPRESSION = 'http_compression';\n"
"\n"
" public const OPTION_HTTP_COMPRESSION_LEVEL = 'http_compression_level';\n"
"\n"
" public const OPTION_HTTP_GZIP_LEVEL = 'http_gzip_level';\n"
"\n"
" public const OPTION_UPLOAD_TMP_DIR = 'upload_tmp_dir';\n"
"\n"
" public const OPTION_HOST = 'host';\n"
"\n"
" public const OPTION_PORT = 'port';\n"
"\n"
" public const OPTION_SSL = 'ssl';\n"
"\n"
" public const OPTION_USER = 'user';\n"
"\n"
" public const OPTION_PASSWORD = 'password';\n"
"\n"
" public const OPTION_DATABASE = 'database';\n"
"\n"
" public const OPTION_CHARSET = 'charset';\n"
"\n"
" public const OPTION_STRICT_TYPE = 'strict_type';\n"
"\n"
" public const OPTION_FETCH_MODE = 'fetch_mode';\n"
"\n"
" public const OPTION_SERIALIZE = 'serialize';\n"
"\n"
" public const OPTION_COMPATIBILITY_MODE = 'compatibility_mode';\n"
"\n"
" public const OPTION_CHROOT = 'chroot';\n"
"\n"
" public const OPTION_GROUP = 'group';\n"
"\n"
" public const OPTION_DAEMONIZE = 'daemonize';\n"
"\n"
" public const OPTION_PID_FILE = 'pid_file';\n"
"\n"
" public const OPTION_REACTOR_NUM = 'reactor_num';\n"
"\n"
" public const OPTION_SINGLE_THREAD = 'single_thread';\n"
"\n"
" public const OPTION_WORKER_NUM = 'worker_num';\n"
"\n"
" public const OPTION_MAX_WAIT_TIME = 'max_wait_time';\n"
"\n"
" public const OPTION_MAX_QUEUED_BYTES = 'max_queued_bytes';\n"
"\n"
" public const OPTION_MAX_CORO_NUM = 'max_coro_num';\n"
"\n"
" public const OPTION_SEND_TIMEOUT = 'send_timeout';\n"
"\n"
" public const OPTION_DISPATCH_MODE = 'dispatch_mode';\n"
"\n"
" public const OPTION_SEND_YIELD = 'send_yield';\n"
"\n"
" public const OPTION_DISPATCH_FUNC = 'dispatch_func';\n"
"\n"
" public const OPTION_DISCARD_TIMEOUT_REQUEST = 'discard_timeout_request';\n"
"\n"
" public const OPTION_ENABLE_UNSAFE_EVENT = 'enable_unsafe_event';\n"
"\n"
" public const OPTION_ENABLE_DELAY_RECEIVE = 'enable_delay_receive';\n"
"\n"
" public const OPTION_ENABLE_REUSE_PORT = 'enable_reuse_port';\n"
"\n"
" public const OPTION_TASK_USE_OBJECT = 'task_use_object';\n"
"\n"
" public const OPTION_TASK_ENABLE_COROUTINE = 'task_enable_coroutine';\n"
"\n"
" public const OPTION_TASK_WORKER_NUM = 'task_worker_num';\n"
"\n"
" public const OPTION_TASK_IPC_MODE = 'task_ipc_mode';\n"
"\n"
" public const OPTION_TASK_TMPDIR = 'task_tmpdir';\n"
"\n"
" public const OPTION_TASK_MAX_REQUEST = 'task_max_request';\n"
"\n"
" public const OPTION_TASK_MAX_REQUEST_GRACE = 'task_max_request_grace';\n"
"\n"
" public const OPTION_MAX_CONNECTION = 'max_connection';\n"
"\n"
" public const OPTION_MAX_CONN = 'max_conn';\n"
"\n"
" public const OPTION_HEARTBEAT_CHECK_INTERVAL = 'heartbeat_check_interval';\n"
"\n"
" public const OPTION_HEARTBEAT_IDLE_TIME = 'heartbeat_idle_time';\n"
"\n"
" public const OPTION_MAX_REQUEST = 'max_request';\n"
"\n"
" public const OPTION_MAX_REQUEST_GRACE = 'max_request_grace';\n"
"\n"
" public const OPTION_RELOAD_ASYNC = 'reload_async';\n"
"\n"
" public const OPTION_OPEN_CPU_AFFINITY = 'open_cpu_affinity';\n"
"\n"
" public const OPTION_CPU_AFFINITY_IGNORE = 'cpu_affinity_ignore';\n"
"\n"
" public const OPTION_ENABLE_STATIC_HANDLER = 'enable_static_handler';\n"
"\n"
" public const OPTION_DOCUMENT_ROOT = 'document_root';\n"
"\n"
" public const OPTION_HTTP_AUTOINDEX = 'http_autoindex';\n"
"\n"
" public const OPTION_HTTP_INDEX_FILES = 'http_index_files';\n"
"\n"
" public const OPTION_STATIC_HANDLER_LOCATIONS = 'static_handler_locations';\n"
"\n"
" public const OPTION_INPUT_BUFFER_SIZE = 'input_buffer_size';\n"
"\n"
" public const OPTION_BUFFER_INPUT_SIZE = 'buffer_input_size';\n"
"\n"
" public const OPTION_OUTPUT_BUFFER_SIZE = 'output_buffer_size';\n"
"\n"
" public const OPTION_BUFFER_OUTPUT_SIZE = 'buffer_output_size';\n"
"\n"
" public const OPTION_MESSAGE_QUEUE_KEY = 'message_queue_key';\n"
"\n"
" public const OPTION_BACKLOG = 'backlog';\n"
"\n"
" public const OPTION_KERNEL_SOCKET_RECV_BUFFER_SIZE = 'kernel_socket_recv_buffer_size';\n"
"\n"
" public const OPTION_KERNEL_SOCKET_SEND_BUFFER_SIZE = 'kernel_socket_send_buffer_size';\n"
"\n"
" public const OPTION_TCP_DEFER_ACCEPT = 'tcp_defer_accept';\n"
"\n"
" public const OPTION_OPEN_TCP_KEEPALIVE = 'open_tcp_keepalive';\n"
"\n"
" public const OPTION_OPEN_HTTP_PROTOCOL = 'open_http_protocol';\n"
"\n"
" public const OPTION_OPEN_WEBSOCKET_PROTOCOL = 'open_websocket_protocol';\n"
"\n"
" public const OPTION_WEBSOCKET_SUBPROTOCOL = 'websocket_subprotocol';\n"
"\n"
" public const OPTION_OPEN_WEBSOCKET_CLOSE_FRAME = 'open_websocket_close_frame';\n"
"\n"
" public const OPTION_OPEN_HTTP2_PROTOCOL = 'open_http2_protocol';\n"
"\n"
" public const OPTION_OPEN_REDIS_PROTOCOL = 'open_redis_protocol';\n"
"\n"
" public const OPTION_TCP_KEEPIDLE = 'tcp_keepidle';\n"
"\n"
" public const OPTION_TCP_KEEPINTERVAL = 'tcp_keepinterval';\n"
"\n"
" public const OPTION_TCP_KEEPCOUNT = 'tcp_keepcount';\n"
"\n"
" public const OPTION_TCP_FASTOPEN = 'tcp_fastopen';\n"
"\n"
" public const OPTION_PACKAGE_BODY_START = 'package_body_start';\n"
"\n"
" public const OPTION_SSL_CLIENT_CERT_FILE = 'ssl_client_cert_file';\n"
"\n"
" public const OPTION_SSL_PREFER_SERVER_CIPHERS = 'ssl_prefer_server_ciphers';\n"
"\n"
" public const OPTION_SSL_CIPHERS = 'ssl_ciphers';\n"
"\n"
" public const OPTION_SSL_ECDH_CURVE = 'ssl_ecdh_curve';\n"
"\n"
" public const OPTION_SSL_DHPARAM = 'ssl_dhparam';\n"
"\n"
" public const OPTION_OPEN_SSL = 'open_ssl';\n"
"\n"
" public const OPTION_OPEN_FASTCGI_PROTOCOL = 'open_fastcgi_protocol';\n"
"\n"
" /* }}} OPTION */\n"
"}\n";
static const char* swoole_library_source_core_string_object =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole;\n"
"\n"
"class StringObject\n"
"{\n"
" /**\n"
" * @var string\n"
" */\n"
" protected $string;\n"
"\n"
" /**\n"
" * StringObject constructor.\n"
" */\n"
" public function __construct(string $string = '')\n"
" {\n"
" $this->string = $string;\n"
" }\n"
"\n"
" public function __toString(): string\n"
" {\n"
" return $this->string;\n"
" }\n"
"\n"
" public function length(): int\n"
" {\n"
" return strlen($this->string);\n"
" }\n"
"\n"
" /**\n"
" * @return false|int\n"
" */\n"
" public function indexOf(string $needle, int $offset = 0)\n"
" {\n"
" return strpos($this->string, ...func_get_args());\n"
" }\n"
"\n"
" /**\n"
" * @return false|int\n"
" */\n"
" public function lastIndexOf(string $needle, int $offset = 0)\n"
" {\n"
" return strrpos($this->string, ...func_get_args());\n"
" }\n"
"\n"
" /**\n"
" * @return false|int\n"
" */\n"
" public function pos(string $needle, int $offset = 0)\n"
" {\n"
" return strpos($this->string, ...func_get_args());\n"
" }\n"
"\n"
" /**\n"
" * @return false|int\n"
" */\n"
" public function rpos(string $needle, int $offset = 0)\n"
" {\n"
" return strrpos($this->string, ...func_get_args());\n"
" }\n"
"\n"
" /**\n"
" * @return false|int\n"
" */\n"
" public function ipos(string $needle)\n"
" {\n"
" return stripos($this->string, $needle);\n"
" }\n"
"\n"
" /**\n"
" * @return static\n"
" */\n"
" public function lower(): self\n"
" {\n"
" return new static(strtolower($this->string));\n"
" }\n"
"\n"
" /**\n"
" * @return static\n"
" */\n"
" public function upper(): self\n"
" {\n"
" return new static(strtoupper($this->string));\n"
" }\n"
"\n"
" /**\n"
" * @return static\n"
" */\n"
" public function trim(): self\n"
" {\n"
" return new static(trim($this->string));\n"
" }\n"
"\n"
" /**\n"
" * @return static\n"
" */\n"
" public function ltrim(): self\n"
" {\n"
" return new static(ltrim($this->string));\n"
" }\n"
"\n"
" /**\n"
" * @return static\n"
" */\n"
" public function rtrim(): self\n"
" {\n"
" return new static(rtrim($this->string));\n"
" }\n"
"\n"
" /**\n"
" * @return static\n"
" */\n"
" public function substr(int $offset, ?int $length = null)\n"
" {\n"
" return new static(substr($this->string, ...func_get_args()));\n"
" }\n"
"\n"
" public function repeat(int $n): StringObject\n"
" {\n"
" return new static(str_repeat($this->string, $n));\n"
" }\n"
"\n"
" /**\n"
" * @param $str\n"
" */\n"
" public function append($str): StringObject\n"
" {\n"
" if (is_string($str)) {\n"
" $this->string .= $str;\n"
" } else {\n"
" $this->string .= strval($str);\n"
" }\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @param null|int $count\n"
" * @return static\n"
" */\n"
" public function replace(string $search, string $replace, &$count = null)\n"
" {\n"
" return new static(str_replace($search, $replace, $this->string, $count));\n"
" }\n"
"\n"
" public function startsWith(string $needle): bool\n"
" {\n"
" return strpos($this->string, $needle) === 0;\n"
" }\n"
"\n"
" public function contains(string $subString): bool\n"
" {\n"
" return strpos($this->string, $subString) !== false;\n"
" }\n"
"\n"
" public function endsWith(string $needle): bool\n"
" {\n"
" return strrpos($this->string, $needle) === (strlen($this->string) - strlen($needle));\n"
" }\n"
"\n"
" public function split(string $delimiter, int $limit = PHP_INT_MAX): ArrayObject\n"
" {\n"
" return static::detectArrayType(explode($delimiter, $this->string, $limit));\n"
" }\n"
"\n"
" public function char(int $index): string\n"
" {\n"
" if ($index > strlen($this->string)) {\n"
" return '';\n"
" }\n"
" return $this->string[$index];\n"
" }\n"
"\n"
" /**\n"
" * @return static\n"
" */\n"
" public function chunkSplit(int $chunkLength = 76, string $chunkEnd = '')\n"
" {\n"
" return new static(chunk_split($this->string, ...func_get_args()));\n"
" }\n"
"\n"
" public function chunk(int $splitLength = 1): ArrayObject\n"
" {\n"
" return static::detectArrayType(str_split($this->string, ...func_get_args()));\n"
" }\n"
"\n"
" public function toString(): string\n"
" {\n"
" return $this->string;\n"
" }\n"
"\n"
" protected static function detectArrayType(array $value): ArrayObject\n"
" {\n"
" return new ArrayObject($value);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_multibyte_string_object =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole;\n"
"\n"
"class MultibyteStringObject extends StringObject\n"
"{\n"
" public function length(): int\n"
" {\n"
" return mb_strlen($this->string);\n"
" }\n"
"\n"
" /**\n"
" * @return false|int\n"
" */\n"
" public function indexOf(string $needle, int $offset = 0, ?string $encoding = null)\n"
" {\n"
" return mb_strpos($this->string, ...func_get_args());\n"
" }\n"
"\n"
" /**\n"
" * @return false|int\n"
" */\n"
" public function lastIndexOf(string $needle, int $offset = 0, ?string $encoding = null)\n"
" {\n"
" return mb_strrpos($this->string, ...func_get_args());\n"
" }\n"
"\n"
" /**\n"
" * @return false|int\n"
" */\n"
" public function pos(string $needle, int $offset = 0, ?string $encoding = null)\n"
" {\n"
" return mb_strpos($this->string, ...func_get_args());\n"
" }\n"
"\n"
" /**\n"
" * @return false|int\n"
" */\n"
" public function rpos(string $needle, int $offset = 0, ?string $encoding = null)\n"
" {\n"
" return mb_strrpos($this->string, ...func_get_args());\n"
" }\n"
"\n"
" /**\n"
" * @return false|int\n"
" */\n"
" public function ipos(string $needle, ?string $encoding = null)\n"
" {\n"
" return mb_stripos($this->string, ...func_get_args());\n"
" }\n"
"\n"
" /**\n"
" * @return static\n"
" */\n"
" public function substr(int $offset, ?int $length = null, ?string $encoding = null)\n"
" {\n"
" return new static(mb_substr($this->string, ...func_get_args()));\n"
" }\n"
"\n"
" public function chunk(int $splitLength = 1, ?int $limit = null): ArrayObject\n"
" {\n"
" return static::detectArrayType(mb_split($this->string, ...func_get_args()));\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_array_object =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole;\n"
"\n"
"use ArrayAccess;\n"
"use Countable;\n"
"use Iterator;\n"
"use RuntimeException;\n"
"use Serializable;\n"
"\n"
"class ArrayObject implements ArrayAccess, Serializable, Countable, Iterator\n"
"{\n"
" /**\n"
" * @var array\n"
" */\n"
" protected $array;\n"
"\n"
" /**\n"
" * ArrayObject constructor.\n"
" */\n"
" public function __construct(array $array = [])\n"
" {\n"
" $this->array = $array;\n"
" }\n"
"\n"
" public function __toArray(): array\n"
" {\n"
" return $this->array;\n"
" }\n"
"\n"
" public function toArray(): array\n"
" {\n"
" return $this->array;\n"
" }\n"
"\n"
" public function isEmpty(): bool\n"
" {\n"
" return empty($this->array);\n"
" }\n"
"\n"
" public function count(): int\n"
" {\n"
" return count($this->array);\n"
" }\n"
"\n"
" /**\n"
" * @return mixed\n"
" */\n"
" public function current()\n"
" {\n"
" return current($this->array);\n"
" }\n"
"\n"
" /**\n"
" * @return mixed\n"
" */\n"
" public function key()\n"
" {\n"
" return key($this->array);\n"
" }\n"
"\n"
" public function valid(): bool\n"
" {\n"
" return array_key_exists($this->key(), $this->array);\n"
" }\n"
"\n"
" /**\n"
" * @return mixed\n"
" */\n"
" public function rewind()\n"
" {\n"
" return reset($this->array);\n"
" }\n"
"\n"
" /**\n"
" * @return mixed\n"
" */\n"
" public function next()\n"
" {\n"
" return next($this->array);\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $key\n"
" * @return ArrayObject|StringObject\n"
" */\n"
" public function get($key)\n"
" {\n"
" return static::detectType($this->array[$key]);\n"
" }\n"
"\n"
" /**\n"
" * @return mixed\n"
" */\n"
" public function last()\n"
" {\n"
" $key = array_key_last($this->array);\n"
" if ($key === null) {\n"
" return null;\n"
" }\n"
" return $this->get($key);\n"
" }\n"
"\n"
" /**\n"
" * @return mixed\n"
" */\n"
" public function first()\n"
" {\n"
" $key = array_key_first($this->array);\n"
" if ($key === null) {\n"
" return null;\n"
" }\n"
" return $this->get($key);\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $key\n"
" * @param mixed $value\n"
" * @return $this\n"
" */\n"
" public function set($key, $value): self\n"
" {\n"
" $this->array[$key] = $value;\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $key\n"
" * @return $this\n"
" */\n"
" public function delete($key): self\n"
" {\n"
" unset($this->array[$key]);\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $value\n"
" * @return $this\n"
" */\n"
" public function remove($value, bool $strict = true, bool $loop = false): self\n"
" {\n"
" do {\n"
" $key = $this->search($value, $strict);\n"
" if ($key === false) {\n"
" break;\n"
" }\n"
" unset($this->array[$key]);\n"
" } while ($loop);\n"
"\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @return $this\n"
" */\n"
" public function clear(): self\n"
" {\n"
" $this->array = [];\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $key\n"
" * @return null|mixed\n"
" */\n"
" public function offsetGet($key)\n"
" {\n"
" if (!array_key_exists($key, $this->array)) {\n"
" return null;\n"
" }\n"
" return $this->array[$key];\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $key\n"
" * @param mixed $value\n"
" */\n"
" public function offsetSet($key, $value): void\n"
" {\n"
" $this->array[$key] = $value;\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $key\n"
" */\n"
" public function offsetUnset($key): void\n"
" {\n"
" unset($this->array[$key]);\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $key\n"
" * @return bool\n"
" */\n"
" public function offsetExists($key)\n"
" {\n"
" return isset($this->array[$key]);\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $key\n"
" */\n"
" public function exists($key): bool\n"
" {\n"
" return array_key_exists($key, $this->array);\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $value\n"
" */\n"
" public function contains($value, bool $strict = true): bool\n"
" {\n"
" return in_array($value, $this->array, $strict);\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $value\n"
" * @return mixed\n"
" */\n"
" public function indexOf($value, bool $strict = true)\n"
" {\n"
" return $this->search($value, $strict);\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $value\n"
" * @return mixed\n"
" */\n"
" public function lastIndexOf($value, bool $strict = true)\n"
" {\n"
" $array = $this->array;\n"
" for (end($array); ($currentKey = key($array)) !== null; prev($array)) {\n"
" $currentValue = current($array);\n"
" if ($currentValue == $value) {\n"
" if ($strict && $currentValue !== $value) {\n"
" continue;\n"
" }\n"
" break;\n"
" }\n"
" }\n"
" return $currentKey;\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $needle\n"
" * @return mixed\n"
" */\n"
" public function search($needle, bool $strict = true)\n"
" {\n"
" return array_search($needle, $this->array, $strict);\n"
" }\n"
"\n"
" public function join(string $glue = ''): StringObject\n"
" {\n"
" return static::detectStringType(implode($glue, $this->array));\n"
" }\n"
"\n"
" public function serialize(): StringObject\n"
" {\n"
" return static::detectStringType(serialize($this->array));\n"
" }\n"
"\n"
" /**\n"
" * @param string $string\n"
" * @return $this\n"
" */\n"
" public function unserialize($string): self\n"
" {\n"
" $this->array = (array) unserialize((string) $string);\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @return float|int\n"
" */\n"
" public function sum()\n"
" {\n"
" return array_sum($this->array);\n"
" }\n"
"\n"
" /**\n"
" * @return float|int\n"
" */\n"
" public function product()\n"
" {\n"
" return array_product($this->array);\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $value\n"
" * @return int\n"
" */\n"
" public function push($value)\n"
" {\n"
" return $this->pushBack($value);\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $value\n"
" * @return int\n"
" */\n"
" public function pushFront($value)\n"
" {\n"
" return array_unshift($this->array, $value);\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $value\n"
" * @return int\n"
" */\n"
" public function pushBack($value)\n"
" {\n"
" return array_push($this->array, $value);\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $value\n"
" * @return $this\n"
" */\n"
" public function insert(int $offset, $value): self\n"
" {\n"
" if (is_array($value) || is_object($value) || is_null($value)) {\n"
" $value = [$value];\n"
" }\n"
" array_splice($this->array, $offset, 0, $value);\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @return mixed\n"
" */\n"
" public function pop()\n"
" {\n"
" return $this->popBack();\n"
" }\n"
"\n"
" /**\n"
" * @return mixed\n"
" */\n"
" public function popFront()\n"
" {\n"
" return array_shift($this->array);\n"
" }\n"
"\n"
" /**\n"
" * @return mixed\n"
" */\n"
" public function popBack()\n"
" {\n"
" return array_pop($this->array);\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $offset\n"
" * @param int $length\n"
" * @return static\n"
" */\n"
" public function slice($offset, int $length = null, bool $preserve_keys = false): self\n"
" {\n"
" return new static(array_slice($this->array, ...func_get_args()));\n"
" }\n"
"\n"
" /**\n"
" * @return ArrayObject|mixed|StringObject\n"
" */\n"
" public function randomGet()\n"
" {\n"
" return static::detectType($this->array[array_rand($this->array, 1)]);\n"
" }\n"
"\n"
" /**\n"
" * @return $this\n"
" */\n"
" public function each(callable $fn): self\n"
" {\n"
" if (array_walk($this->array, $fn) === false) {\n"
" throw new RuntimeException('array_walk() failed');\n"
" }\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @param array $args\n"
" * @return static\n"
" */\n"
" public function map(callable $fn, ...$args): self\n"
" {\n"
" return new static(array_map($fn, $this->array, ...$args));\n"
" }\n"
"\n"
" /**\n"
" * @param null $initial\n"
" * @return mixed\n"
" */\n"
" public function reduce(callable $fn, $initial = null)\n"
" {\n"
" return array_reduce($this->array, $fn, $initial);\n"
" }\n"
"\n"
" /**\n"
" * @param array $args\n"
" * @return static\n"
" */\n"
" public function keys(...$args): self\n"
" {\n"
" return new static(array_keys($this->array, ...$args));\n"
" }\n"
"\n"
" /**\n"
" * @return static\n"
" */\n"
" public function values(): self\n"
" {\n"
" return new static(array_values($this->array));\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $column_key\n"
" * @param mixed $index\n"
" * @return static\n"
" */\n"
" public function column($column_key, $index = null): self\n"
" {\n"
" return new static(array_column($this->array, $column_key, $index));\n"
" }\n"
"\n"
" /**\n"
" * @return static\n"
" */\n"
" public function unique(int $sort_flags = SORT_STRING): self\n"
" {\n"
" return new static(array_unique($this->array, $sort_flags));\n"
" }\n"
"\n"
" /**\n"
" * @return static\n"
" */\n"
" public function reverse(bool $preserve_keys = false): self\n"
" {\n"
" return new static(array_reverse($this->array, $preserve_keys));\n"
" }\n"
"\n"
" /**\n"
" * @return static\n"
" */\n"
" public function chunk(int $size, bool $preserve_keys = false): self\n"
" {\n"
" return new static(array_chunk($this->array, $size, $preserve_keys));\n"
" }\n"
"\n"
" /**\n"
" * Swap keys and values in an array.\n"
" * @return static\n"
" */\n"
" public function flip(): self\n"
" {\n"
" return new static(array_flip($this->array));\n"
" }\n"
"\n"
" /**\n"
" * @return static\n"
" */\n"
" public function filter(callable $fn, int $flag = 0): self\n"
" {\n"
" return new static(array_filter($this->array, $fn, $flag));\n"
" }\n"
"\n"
" /**\n"
" * | Function name | Sorts by | Maintains key association | Order of sort | Related functions |\n"
" * | :---------------- | :------- | :-------------------------- | :-------------------------- | :---------------- |\n"
" * | array_multisort() | value | associative yes, numeric no | first array or sort options | array_walk() |\n"
" * | asort() | value | yes | low to high | arsort() |\n"
" * | arsort() | value | yes | high to low | asort() |\n"
" * | krsort() | key | yes | high to low | ksort() |\n"
" * | ksort() | key | yes | low to high | asort() |\n"
" * | natcasesort() | value | yes | natural, case insensitive | natsort() |\n"
" * | natsort() | value | yes | natural | natcasesort() |\n"
" * | rsort() | value | no | high to low | sort() |\n"
" * | shuffle() | value | no | random | array_rand() |\n"
" * | sort() | value | no | low to high | rsort() |\n"
" * | uasort() | value | yes | user defined | uksort() |\n"
" * | uksort() | key | yes | user defined | uasort() |\n"
" * | usort() | value | no | user defined | uasort() |\n"
" */\n"
"\n"
" /**\n"
" * @return $this\n"
" */\n"
" public function asort(int $sort_flags = SORT_REGULAR): self\n"
" {\n"
" if (asort($this->array, $sort_flags) !== true) {\n"
" throw new RuntimeException('asort() failed');\n"
" }\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @return $this\n"
" */\n"
" public function arsort(int $sort_flags = SORT_REGULAR): self\n"
" {\n"
" if (arsort($this->array, $sort_flags) !== true) {\n"
" throw new RuntimeException('arsort() failed');\n"
" }\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @return $this\n"
" */\n"
" public function krsort(int $sort_flags = SORT_REGULAR): self\n"
" {\n"
" if (krsort($this->array, $sort_flags) !== true) {\n"
" throw new RuntimeException('krsort() failed');\n"
" }\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @return $this\n"
" */\n"
" public function ksort(int $sort_flags = SORT_REGULAR): self\n"
" {\n"
" if (ksort($this->array, $sort_flags) !== true) {\n"
" throw new RuntimeException('ksort() failed');\n"
" }\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @return $this\n"
" */\n"
" public function natcasesort(): self\n"
" {\n"
" if (natcasesort($this->array) !== true) {\n"
" throw new RuntimeException('natcasesort() failed');\n"
" }\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @return $this\n"
" */\n"
" public function natsort(): self\n"
" {\n"
" if (natsort($this->array) !== true) {\n"
" throw new RuntimeException('natsort() failed');\n"
" }\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @return $this\n"
" */\n"
" public function rsort(int $sort_flags = SORT_REGULAR): self\n"
" {\n"
" if (rsort($this->array, $sort_flags) !== true) {\n"
" throw new RuntimeException('rsort() failed');\n"
" }\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @return $this\n"
" */\n"
" public function shuffle(): self\n"
" {\n"
" if (shuffle($this->array) !== true) {\n"
" throw new RuntimeException('shuffle() failed');\n"
" }\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @return $this\n"
" */\n"
" public function sort(int $sort_flags = SORT_REGULAR): self\n"
" {\n"
" if (sort($this->array, $sort_flags) !== true) {\n"
" throw new RuntimeException('sort() failed');\n"
" }\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @return $this\n"
" */\n"
" public function uasort(callable $value_compare_func): self\n"
" {\n"
" if (uasort($this->array, $value_compare_func) !== true) {\n"
" throw new RuntimeException('uasort() failed');\n"
" }\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @return $this\n"
" */\n"
" public function uksort(callable $value_compare_func): self\n"
" {\n"
" if (uksort($this->array, $value_compare_func) !== true) {\n"
" throw new RuntimeException('uksort() failed');\n"
" }\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @return $this\n"
" */\n"
" public function usort(callable $value_compare_func): self\n"
" {\n"
" if (usort($this->array, $value_compare_func) !== true) {\n"
" throw new RuntimeException('usort() failed');\n"
" }\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $value\n"
" * @return ArrayObject|mixed|StringObject\n"
" */\n"
" protected static function detectType($value)\n"
" {\n"
" if (is_string($value)) {\n"
" return static::detectStringType($value);\n"
" }\n"
" if (is_array($value)) {\n"
" return static::detectArrayType($value);\n"
" }\n"
" return $value;\n"
" }\n"
"\n"
" protected static function detectStringType(string $value): StringObject\n"
" {\n"
" return new StringObject($value);\n"
" }\n"
"\n"
" /**\n"
" * @return static\n"
" */\n"
" protected static function detectArrayType(array $value): self\n"
" {\n"
" return new static($value);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_object_proxy =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole;\n"
"\n"
"use TypeError;\n"
"\n"
"class ObjectProxy\n"
"{\n"
" /** @var object */\n"
" protected $__object;\n"
"\n"
" public function __construct($object)\n"
" {\n"
" if (!is_object($object)) {\n"
" throw new TypeError('Non-object given');\n"
" }\n"
" $this->__object = $object;\n"
" }\n"
"\n"
" public function __getObject()\n"
" {\n"
" return $this->__object;\n"
" }\n"
"\n"
" public function __get(string $name)\n"
" {\n"
" return $this->__object->{$name};\n"
" }\n"
"\n"
" public function __set(string $name, $value): void\n"
" {\n"
" $this->__object->{$name} = $value;\n"
" }\n"
"\n"
" public function __isset($name)\n"
" {\n"
" return isset($this->__object->{$name});\n"
" }\n"
"\n"
" public function __unset(string $name): void\n"
" {\n"
" unset($this->__object->{$name});\n"
" }\n"
"\n"
" public function __call(string $name, array $arguments)\n"
" {\n"
" return $this->__object->{$name}(...$arguments);\n"
" }\n"
"\n"
" public function __invoke(...$arguments)\n"
" {\n"
" /** @var mixed $object */\n"
" $object = $this->__object;\n"
" return $object(...$arguments);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_coroutine_wait_group =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Coroutine;\n"
"\n"
"use BadMethodCallException;\n"
"use InvalidArgumentException;\n"
"\n"
"class WaitGroup\n"
"{\n"
" protected $chan;\n"
"\n"
" protected $count = 0;\n"
"\n"
" protected $waiting = false;\n"
"\n"
" public function __construct()\n"
" {\n"
" $this->chan = new Channel(1);\n"
" }\n"
"\n"
" public function add(int $delta = 1): void\n"
" {\n"
" if ($this->waiting) {\n"
" throw new BadMethodCallException('WaitGroup misuse: add called concurrently with wait');\n"
" }\n"
" $count = $this->count + $delta;\n"
" if ($count < 0) {\n"
" throw new InvalidArgumentException('WaitGroup misuse: negative counter');\n"
" }\n"
" $this->count = $count;\n"
" }\n"
"\n"
" public function done(): void\n"
" {\n"
" $count = $this->count - 1;\n"
" if ($count < 0) {\n"
" throw new BadMethodCallException('WaitGroup misuse: negative counter');\n"
" }\n"
" $this->count = $count;\n"
" if ($count === 0 && $this->waiting) {\n"
" $this->chan->push(true);\n"
" }\n"
" }\n"
"\n"
" public function wait(float $timeout = -1): bool\n"
" {\n"
" if ($this->waiting) {\n"
" throw new BadMethodCallException('WaitGroup misuse: reused before previous wait has returned');\n"
" }\n"
" if ($this->count > 0) {\n"
" $this->waiting = true;\n"
" $done = $this->chan->pop($timeout);\n"
" $this->waiting = false;\n"
" return $done;\n"
" }\n"
" return true;\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_coroutine_server =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Coroutine;\n"
"\n"
"use Swoole\\Coroutine;\n"
"use Swoole\\Coroutine\\Server\\Connection;\n"
"use Swoole\\Exception;\n"
"\n"
"/* compatibility constant */\n"
"define('SWOOLE_COROUTINE_SOCKET_HAVE_SSL_HANDSHAKE', method_exists(Socket::class, 'sslHandshake'));\n"
"\n"
"class Server\n"
"{\n"
" /** @var string */\n"
" public $host = '';\n"
"\n"
" /** @var int */\n"
" public $port = 0;\n"
"\n"
" /** @var int */\n"
" public $type = AF_INET;\n"
"\n"
" /** @var int */\n"
" public $fd = -1;\n"
"\n"
" /** @var int */\n"
" public $errCode = 0;\n"
"\n"
" /** @var array */\n"
" public $setting = [];\n"
"\n"
" /** @var bool */\n"
" protected $running = false;\n"
"\n"
" /** @var null|callable */\n"
" protected $fn;\n"
"\n"
" /** @var Socket */\n"
" protected $socket;\n"
"\n"
" /**\n"
" * Server constructor.\n"
" * @throws Exception\n"
" */\n"
" public function __construct(string $host, int $port = 0, bool $ssl = false, bool $reuse_port = false)\n"
" {\n"
" $_host = swoole_string($host);\n"
" if ($_host->contains('::')) {\n"
" $this->type = AF_INET6;\n"
" } elseif ($_host->startsWith('unix:/')) {\n"
" $host = $_host->substr(5)->__toString();\n"
" $this->type = AF_UNIX;\n"
" } else {\n"
" $this->type = AF_INET;\n"
" }\n"
" $this->host = $host;\n"
"\n"
" $socket = new Socket($this->type, SOCK_STREAM, 0);\n"
" if ($reuse_port and defined('SO_REUSEPORT')) {\n"
" $socket->setOption(SOL_SOCKET, SO_REUSEPORT, true);\n"
" }\n"
" if (!$socket->bind($this->host, $port)) {\n"
" throw new Exception(\"bind({$this->host}:{$port}) failed\", $socket->errCode);\n"
" }\n"
" if (!$socket->listen()) {\n"
" throw new Exception('listen() failed', $socket->errCode);\n"
" }\n"
" $this->port = $socket->getsockname()['port'] ?? 0;\n"
" $this->fd = $socket->fd;\n"
" $this->socket = $socket;\n"
" $this->setting['open_ssl'] = $ssl;\n"
" }\n"
"\n"
" public function set(array $setting): void\n"
" {\n"
" $this->setting = array_merge($this->setting, $setting);\n"
" }\n"
"\n"
" public function handle(callable $fn): void\n"
" {\n"
" $this->fn = $fn;\n"
" }\n"
"\n"
" public function shutdown(): bool\n"
" {\n"
" $this->running = false;\n"
" return $this->socket->cancel();\n"
" }\n"
"\n"
" public function start(): bool\n"
" {\n"
" $this->running = true;\n"
" if ($this->fn === null) {\n"
" $this->errCode = SOCKET_EINVAL;\n"
" return false;\n"
" }\n"
" $socket = $this->socket;\n"
" if (!$socket->setProtocol($this->setting)) {\n"
" $this->errCode = SOCKET_EINVAL;\n"
" return false;\n"
" }\n"
"\n"
" while ($this->running) {\n"
" /** @var Socket $conn */\n"
" $conn = null;\n"
" $conn = $socket->accept();\n"
" if ($conn) {\n"
" $conn->setProtocol($this->setting);\n"
" if (SWOOLE_COROUTINE_SOCKET_HAVE_SSL_HANDSHAKE && $this->setting['open_ssl'] ?? false) {\n"
" $fn = static function ($fn, $connection) {\n"
" /* @var $connection Connection */\n"
" if (!$connection->exportSocket()->sslHandshake()) {\n"
" return;\n"
" }\n"
" $fn($connection);\n"
" };\n"
" $arguments = [$this->fn, new Connection($conn)];\n"
" } else {\n"
" $fn = $this->fn;\n"
" $arguments = [new Connection($conn)];\n"
" }\n"
" if (Coroutine::create($fn, ...$arguments) < 0) {\n"
" goto _wait;\n"
" }\n"
" } else {\n"
" if ($socket->errCode == SOCKET_EMFILE or $socket->errCode == SOCKET_ENFILE) {\n"
" _wait:\n"
" Coroutine::sleep(1);\n"
" continue;\n"
" }\n"
" if ($socket->errCode == SOCKET_ETIMEDOUT) {\n"
" continue;\n"
" }\n"
" if ($socket->errCode == SOCKET_ECANCELED) {\n"
" break;\n"
" }\n"
" trigger_error(\"accept failed, Error: {$socket->errMsg}[{$socket->errCode}]\", E_USER_WARNING);\n"
" break;\n"
" }\n"
" }\n"
"\n"
" return true;\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_coroutine_server_connection =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Coroutine\\Server;\n"
"\n"
"use Swoole\\Coroutine\\Socket;\n"
"\n"
"class Connection\n"
"{\n"
" protected $socket;\n"
"\n"
" public function __construct(Socket $conn)\n"
" {\n"
" $this->socket = $conn;\n"
" }\n"
"\n"
" public function recv(float $timeout = 0)\n"
" {\n"
" return $this->socket->recvPacket($timeout);\n"
" }\n"
"\n"
" public function send(string $data)\n"
" {\n"
" return $this->socket->sendAll($data);\n"
" }\n"
"\n"
" public function close(): bool\n"
" {\n"
" return $this->socket->close();\n"
" }\n"
"\n"
" public function exportSocket(): Socket\n"
" {\n"
" return $this->socket;\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_connection_pool =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole;\n"
"\n"
"use RuntimeException;\n"
"use Swoole\\Coroutine\\Channel;\n"
"use Throwable;\n"
"\n"
"class ConnectionPool\n"
"{\n"
" public const DEFAULT_SIZE = 64;\n"
"\n"
" /** @var Channel */\n"
" protected $pool;\n"
"\n"
" /** @var callable */\n"
" protected $constructor;\n"
"\n"
" /** @var int */\n"
" protected $size;\n"
"\n"
" /** @var int */\n"
" protected $num;\n"
"\n"
" /** @var null|string */\n"
" protected $proxy;\n"
"\n"
" public function __construct(callable $constructor, int $size = self::DEFAULT_SIZE, ?string $proxy = null)\n"
" {\n"
" $this->pool = new Channel($this->size = $size);\n"
" $this->constructor = $constructor;\n"
" $this->num = 0;\n"
" $this->proxy = $proxy;\n"
" }\n"
"\n"
" public function fill(): void\n"
" {\n"
" while ($this->size > $this->num) {\n"
" $this->make();\n"
" }\n"
" }\n"
"\n"
" public function get()\n"
" {\n"
" if ($this->pool === null) {\n"
" throw new RuntimeException('Pool has been closed');\n"
" }\n"
" if ($this->pool->isEmpty() && $this->num < $this->size) {\n"
" $this->make();\n"
" }\n"
" return $this->pool->pop();\n"
" }\n"
"\n"
" public function put($connection): void\n"
" {\n"
" if ($this->pool === null) {\n"
" return;\n"
" }\n"
" if ($connection !== null) {\n"
" $this->pool->push($connection);\n"
" } else {\n"
" /* connection broken */\n"
" $this->num -= 1;\n"
" $this->make();\n"
" }\n"
" }\n"
"\n"
" public function close(): void\n"
" {\n"
" $this->pool->close();\n"
" $this->pool = null;\n"
" $this->num = 0;\n"
" }\n"
"\n"
" protected function make(): void\n"
" {\n"
" $this->num++;\n"
" try {\n"
" if ($this->proxy) {\n"
" $connection = new $this->proxy($this->constructor);\n"
" } else {\n"
" $constructor = $this->constructor;\n"
" $connection = $constructor();\n"
" }\n"
" } catch (Throwable $throwable) {\n"
" $this->num--;\n"
" throw $throwable;\n"
" }\n"
" $this->put($connection);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_database_object_proxy =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Database;\n"
"\n"
"use Error;\n"
"\n"
"class ObjectProxy extends \\Swoole\\ObjectProxy\n"
"{\n"
" public function __clone()\n"
" {\n"
" throw new Error('Trying to clone an uncloneable database proxy object');\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_database_mysqli_config =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Database;\n"
"\n"
"class MysqliConfig\n"
"{\n"
" /** @var string */\n"
" protected $host = '127.0.0.1';\n"
"\n"
" /** @var int */\n"
" protected $port = 3306;\n"
"\n"
" /** @var null|string */\n"
" protected $unixSocket = '';\n"
"\n"
" /** @var string */\n"
" protected $dbname = 'test';\n"
"\n"
" /** @var string */\n"
" protected $charset = 'utf8mb4';\n"
"\n"
" /** @var string */\n"
" protected $username = 'root';\n"
"\n"
" /** @var string */\n"
" protected $password = 'root';\n"
"\n"
" /** @var array */\n"
" protected $options = [];\n"
"\n"
" public function getHost(): string\n"
" {\n"
" return $this->host;\n"
" }\n"
"\n"
" public function withHost($host): self\n"
" {\n"
" $this->host = $host;\n"
" return $this;\n"
" }\n"
"\n"
" public function getPort(): int\n"
" {\n"
" return $this->port;\n"
" }\n"
"\n"
" public function getUnixSocket(): string\n"
" {\n"
" return $this->unixSocket;\n"
" }\n"
"\n"
" public function withUnixSocket(?string $unixSocket): self\n"
" {\n"
" $this->unixSocket = $unixSocket;\n"
" return $this;\n"
" }\n"
"\n"
" public function withPort(int $port): self\n"
" {\n"
" $this->port = $port;\n"
" return $this;\n"
" }\n"
"\n"
" public function getDbname(): string\n"
" {\n"
" return $this->dbname;\n"
" }\n"
"\n"
" public function withDbname(string $dbname): self\n"
" {\n"
" $this->dbname = $dbname;\n"
" return $this;\n"
" }\n"
"\n"
" public function getCharset(): string\n"
" {\n"
" return $this->charset;\n"
" }\n"
"\n"
" public function withCharset(string $charset): self\n"
" {\n"
" $this->charset = $charset;\n"
" return $this;\n"
" }\n"
"\n"
" public function getUsername(): string\n"
" {\n"
" return $this->username;\n"
" }\n"
"\n"
" public function withUsername(string $username): self\n"
" {\n"
" $this->username = $username;\n"
" return $this;\n"
" }\n"
"\n"
" public function getPassword(): string\n"
" {\n"
" return $this->password;\n"
" }\n"
"\n"
" public function withPassword(string $password): self\n"
" {\n"
" $this->password = $password;\n"
" return $this;\n"
" }\n"
"\n"
" public function getOptions(): array\n"
" {\n"
" return $this->options;\n"
" }\n"
"\n"
" public function withOptions(array $options): self\n"
" {\n"
" $this->options = $options;\n"
" return $this;\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_database_mysqli_exception =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Database;\n"
"\n"
"use Exception;\n"
"\n"
"class MysqliException extends Exception\n"
"{\n"
"}\n";
static const char* swoole_library_source_core_database_mysqli_pool =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Database;\n"
"\n"
"use mysqli;\n"
"use Swoole\\ConnectionPool;\n"
"\n"
"/**\n"
" * @method mysqli|MysqliProxy get()\n"
" * @method void put(mysqli|MysqliProxy $connection)\n"
" */\n"
"class MysqliPool extends ConnectionPool\n"
"{\n"
" /** @var MysqliConfig */\n"
" protected $config;\n"
"\n"
" public function __construct(MysqliConfig $config, int $size = self::DEFAULT_SIZE)\n"
" {\n"
" $this->config = $config;\n"
" parent::__construct(function () {\n"
" $mysqli = new mysqli();\n"
" foreach ($this->config->getOptions() as $option => $value) {\n"
" $mysqli->set_opt($option, $value);\n"
" }\n"
" $mysqli->real_connect(\n"
" $this->config->getHost(),\n"
" $this->config->getUsername(),\n"
" $this->config->getPassword(),\n"
" $this->config->getDbname(),\n"
" $this->config->getPort(),\n"
" $this->config->getUnixSocket()\n"
" );\n"
" if ($mysqli->connect_errno) {\n"
" throw new MysqliException($mysqli->connect_errno, $mysqli->connect_errno);\n"
" }\n"
" return $mysqli;\n"
" }, $size, MysqliProxy::class);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_database_mysqli_proxy =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Database;\n"
"\n"
"use mysqli;\n"
"\n"
"class MysqliProxy extends ObjectProxy\n"
"{\n"
" public const IO_METHOD_REGEX = '/^autocommit|begin_transaction|change_user|close|commit|kill|multi_query|ping|prepare|query|real_connect|real_query|reap_async_query|refresh|release_savepoint|rollback|savepoint|select_db|send_query|set_charset|ssl_set$/i';\n"
"\n"
" public const IO_ERRORS = [\n"
" 2002, // MYSQLND_CR_CONNECTION_ERROR\n"
" 2006, // MYSQLND_CR_SERVER_GONE_ERROR\n"
" 2013, // MYSQLND_CR_SERVER_LOST\n"
" ];\n"
"\n"
" /** @var mysqli */\n"
" protected $__object;\n"
"\n"
" /** @var string */\n"
" protected $charsetContext;\n"
"\n"
" /** @var null|array */\n"
" protected $setOptContext;\n"
"\n"
" /** @var null|array */\n"
" protected $changeUserContext;\n"
"\n"
" /** @var callable */\n"
" protected $constructor;\n"
"\n"
" /** @var int */\n"
" protected $round = 0;\n"
"\n"
" public function __construct(callable $constructor)\n"
" {\n"
" parent::__construct($constructor());\n"
" $this->constructor = $constructor;\n"
" }\n"
"\n"
" public function __call(string $name, array $arguments)\n"
" {\n"
" for ($n = 3; $n--;) {\n"
" $ret = @$this->__object->{$name}(...$arguments);\n"
" if ($ret === false) {\n"
" /* non-IO method */\n"
" if (!preg_match(static::IO_METHOD_REGEX, $name)) {\n"
" break;\n"
" }\n"
" /* no more chances or non-IO failures */\n"
" if (\n"
" !in_array($this->__object->errno, static::IO_ERRORS, true) ||\n"
" $n === 0\n"
" ) {\n"
" throw new MysqliException($this->__object->error, $this->__object->errno);\n"
" }\n"
" $this->reconnect();\n"
" continue;\n"
" }\n"
" if (strcasecmp($name, 'prepare') === 0) {\n"
" $ret = new MysqliStatementProxy($ret, $arguments[0], $this);\n"
" } elseif (strcasecmp($name, 'stmt_init') === 0) {\n"
" $ret = new MysqliStatementProxy($ret, null, $this);\n"
" }\n"
" break;\n"
" }\n"
" /* @noinspection PhpUndefinedVariableInspection */\n"
" return $ret;\n"
" }\n"
"\n"
" public function getRound(): int\n"
" {\n"
" return $this->round;\n"
" }\n"
"\n"
" public function reconnect(): void\n"
" {\n"
" $constructor = $this->constructor;\n"
" parent::__construct($constructor());\n"
" $this->round++;\n"
" /* restore context */\n"
" if ($this->charsetContext) {\n"
" $this->__object->set_charset($this->charsetContext);\n"
" }\n"
" if ($this->setOptContext) {\n"
" foreach ($this->setOptContext as $opt => $val) {\n"
" $this->__object->set_opt($opt, $val);\n"
" }\n"
" }\n"
" if ($this->changeUserContext) {\n"
" $this->__object->change_user(...$this->changeUserContext);\n"
" }\n"
" }\n"
"\n"
" public function options(int $option, $value): bool\n"
" {\n"
" $this->setOptContext[$option] = $value;\n"
" return $this->__object->options($option, $value);\n"
" }\n"
"\n"
" public function set_opt(int $option, $value): bool\n"
" {\n"
" return $this->options($option, $value);\n"
" }\n"
"\n"
" public function set_charset(string $charset): bool\n"
" {\n"
" $this->charsetContext = $charset;\n"
" return $this->__object->set_charset($charset);\n"
" }\n"
"\n"
" public function change_user(string $user, string $password, string $database): bool\n"
" {\n"
" $this->changeUserContext = [$user, $password, $database];\n"
" return $this->__object->change_user($user, $password, $database);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_database_mysqli_statement_proxy =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Database;\n"
"\n"
"use mysqli;\n"
"use mysqli_stmt;\n"
"\n"
"class MysqliStatementProxy extends ObjectProxy\n"
"{\n"
" public const IO_METHOD_REGEX = '/^close|execute|fetch|prepare$/i';\n"
"\n"
" /** @var mysqli_stmt */\n"
" protected $__object;\n"
"\n"
" /** @var null|string */\n"
" protected $queryString;\n"
"\n"
" /** @var null|array */\n"
" protected $attrSetContext;\n"
"\n"
" /** @var null|array */\n"
" protected $bindParamContext;\n"
"\n"
" /** @var null|array */\n"
" protected $bindResultContext;\n"
"\n"
" /** @var Mysqli|MysqliProxy */\n"
" protected $parent;\n"
"\n"
" /** @var int */\n"
" protected $parentRound;\n"
"\n"
" public function __construct(mysqli_stmt $object, ?string $queryString, MysqliProxy $parent)\n"
" {\n"
" parent::__construct($object);\n"
" $this->queryString = $queryString;\n"
" $this->parent = $parent;\n"
" $this->parentRound = $parent->getRound();\n"
" }\n"
"\n"
" public function __call(string $name, array $arguments)\n"
" {\n"
" for ($n = 3; $n--;) {\n"
" $ret = @$this->__object->{$name}(...$arguments);\n"
" if ($ret === false) {\n"
" /* non-IO method */\n"
" if (!preg_match(static::IO_METHOD_REGEX, $name)) {\n"
" break;\n"
" }\n"
" /* no more chances or non-IO failures or in transaction */\n"
" if (\n"
" !in_array($this->__object->errno, $this->parent::IO_ERRORS, true) ||\n"
" $n === 0\n"
" ) {\n"
" throw new MysqliException($this->__object->error, $this->__object->errno);\n"
" }\n"
" if ($this->parent->getRound() === $this->parentRound) {\n"
" /* if not equal, parent has reconnected */\n"
" $this->parent->reconnect();\n"
" }\n"
" $parent = $this->parent->__getObject();\n"
" $this->__object = $this->queryString ? @$parent->prepare($this->queryString) : @$parent->stmt_init();\n"
" if ($this->__object === false) {\n"
" throw new MysqliException($parent->error, $parent->errno);\n"
" }\n"
" if ($this->bindParamContext) {\n"
" $this->__object->bind_param($this->bindParamContext[0], ...$this->bindParamContext[1]);\n"
" }\n"
" if ($this->bindResultContext) {\n"
" $this->__object->bind_result($this->bindResultContext);\n"
" }\n"
" if ($this->attrSetContext) {\n"
" foreach ($this->attrSetContext as $attr => $value) {\n"
" $this->__object->attr_set($attr, $value);\n"
" }\n"
" }\n"
" continue;\n"
" }\n"
" if (strcasecmp($name, 'prepare') === 0) {\n"
" $this->queryString = $arguments[0];\n"
" }\n"
" break;\n"
" }\n"
" /* @noinspection PhpUndefinedVariableInspection */\n"
" return $ret;\n"
" }\n"
"\n"
" public function attr_set($attr, $mode): bool\n"
" {\n"
" $this->attrSetContext[$attr] = $mode;\n"
" return $this->__object->attr_set($attr, $mode);\n"
" }\n"
"\n"
" public function bind_param($types, &...$arguments): bool\n"
" {\n"
" $this->bindParamContext = [$types, $arguments];\n"
" return $this->__object->bind_param($types, ...$arguments);\n"
" }\n"
"\n"
" public function bind_result(&...$arguments): bool\n"
" {\n"
" $this->bindResultContext = $arguments;\n"
" return $this->__object->bind_result(...$arguments);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_database_pdo_config =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Database;\n"
"\n"
"class PDOConfig\n"
"{\n"
" public const DRIVER_MYSQL = 'mysql';\n"
"\n"
" /** @var string */\n"
" protected $driver = self::DRIVER_MYSQL;\n"
"\n"
" /** @var string */\n"
" protected $host = '127.0.0.1';\n"
"\n"
" /** @var int */\n"
" protected $port = 3306;\n"
"\n"
" /** @var null|string */\n"
" protected $unixSocket;\n"
"\n"
" /** @var string */\n"
" protected $dbname = 'test';\n"
"\n"
" /** @var string */\n"
" protected $charset = 'utf8mb4';\n"
"\n"
" /** @var string */\n"
" protected $username = 'root';\n"
"\n"
" /** @var string */\n"
" protected $password = 'root';\n"
"\n"
" /** @var array */\n"
" protected $options = [];\n"
"\n"
" public function getDriver(): string\n"
" {\n"
" return $this->driver;\n"
" }\n"
"\n"
" public function withDriver(string $driver): self\n"
" {\n"
" $this->driver = $driver;\n"
" return $this;\n"
" }\n"
"\n"
" public function getHost(): string\n"
" {\n"
" return $this->host;\n"
" }\n"
"\n"
" public function withHost($host): self\n"
" {\n"
" $this->host = $host;\n"
" return $this;\n"
" }\n"
"\n"
" public function getPort(): int\n"
" {\n"
" return $this->port;\n"
" }\n"
"\n"
" public function hasUnixSocket(): bool\n"
" {\n"
" return isset($this->unixSocket);\n"
" }\n"
"\n"
" public function getUnixSocket(): string\n"
" {\n"
" return $this->unixSocket;\n"
" }\n"
"\n"
" public function withUnixSocket(?string $unixSocket): self\n"
" {\n"
" $this->unixSocket = $unixSocket;\n"
" return $this;\n"
" }\n"
"\n"
" public function withPort(int $port): self\n"
" {\n"
" $this->port = $port;\n"
" return $this;\n"
" }\n"
"\n"
" public function getDbname(): string\n"
" {\n"
" return $this->dbname;\n"
" }\n"
"\n"
" public function withDbname(string $dbname): self\n"
" {\n"
" $this->dbname = $dbname;\n"
" return $this;\n"
" }\n"
"\n"
" public function getCharset(): string\n"
" {\n"
" return $this->charset;\n"
" }\n"
"\n"
" public function withCharset(string $charset): self\n"
" {\n"
" $this->charset = $charset;\n"
" return $this;\n"
" }\n"
"\n"
" public function getUsername(): string\n"
" {\n"
" return $this->username;\n"
" }\n"
"\n"
" public function withUsername(string $username): self\n"
" {\n"
" $this->username = $username;\n"
" return $this;\n"
" }\n"
"\n"
" public function getPassword(): string\n"
" {\n"
" return $this->password;\n"
" }\n"
"\n"
" public function withPassword(string $password): self\n"
" {\n"
" $this->password = $password;\n"
" return $this;\n"
" }\n"
"\n"
" public function getOptions(): array\n"
" {\n"
" return $this->options;\n"
" }\n"
"\n"
" public function withOptions(array $options): self\n"
" {\n"
" $this->options = $options;\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * Returns the list of available drivers\n"
" *\n"
" * @return string[]\n"
" */\n"
" public static function getAvailableDrivers()\n"
" {\n"
" return [\n"
" self::DRIVER_MYSQL,\n"
" ];\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_database_pdo_pool =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Database;\n"
"\n"
"use PDO;\n"
"use Swoole\\ConnectionPool;\n"
"\n"
"/**\n"
" * @method PDO|PDOProxy get()\n"
" * @method void put(PDO|PDOProxy $connection)\n"
" */\n"
"class PDOPool extends ConnectionPool\n"
"{\n"
" /** @var int */\n"
" protected $size = 64;\n"
"\n"
" /** @var PDOConfig */\n"
" protected $config;\n"
"\n"
" public function __construct(PDOConfig $config, int $size = self::DEFAULT_SIZE)\n"
" {\n"
" $this->config = $config;\n"
" parent::__construct(function () {\n"
" return new PDO(\n"
" \"{$this->config->getDriver()}:\" .\n"
" (\n"
" $this->config->hasUnixSocket() ?\n"
" \"unix_socket={$this->config->getUnixSocket()};\" :\n"
" \"host={$this->config->getHost()};\" . \"port={$this->config->getPort()};\"\n"
" ) .\n"
" \"dbname={$this->config->getDbname()};\" .\n"
" \"charset={$this->config->getCharset()}\",\n"
" $this->config->getUsername(),\n"
" $this->config->getPassword(),\n"
" $this->config->getOptions()\n"
" );\n"
" }, $size, PDOProxy::class);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_database_pdo_proxy =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Database;\n"
"\n"
"use PDO;\n"
"use PDOException;\n"
"\n"
"class PDOProxy extends ObjectProxy\n"
"{\n"
" public const IO_METHOD_REGEX = '/^query|prepare|exec|beginTransaction|commit|rollback$/i';\n"
"\n"
" public const IO_ERRORS = [\n"
" 2002, // MYSQLND_CR_CONNECTION_ERROR\n"
" 2006, // MYSQLND_CR_SERVER_GONE_ERROR\n"
" 2013, // MYSQLND_CR_SERVER_LOST\n"
" ];\n"
"\n"
" /** @var PDO */\n"
" protected $__object;\n"
"\n"
" /** @var null|array */\n"
" protected $setAttributeContext;\n"
"\n"
" /** @var callable */\n"
" protected $constructor;\n"
"\n"
" /** @var int */\n"
" protected $round = 0;\n"
"\n"
" public function __construct(callable $constructor)\n"
" {\n"
" parent::__construct($constructor());\n"
" $this->__object->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);\n"
" $this->constructor = $constructor;\n"
" }\n"
"\n"
" public function __call(string $name, array $arguments)\n"
" {\n"
" for ($n = 3; $n--;) {\n"
" $ret = @$this->__object->{$name}(...$arguments);\n"
" if ($ret === false) {\n"
" /* non-IO method */\n"
" if (!preg_match(static::IO_METHOD_REGEX, $name)) {\n"
" break;\n"
" }\n"
" $errorInfo = $this->__object->errorInfo();\n"
" /* no more chances or non-IO failures */\n"
" if (\n"
" !in_array($errorInfo[1], static::IO_ERRORS, true) ||\n"
" $n === 0 ||\n"
" $this->__object->inTransaction()\n"
" ) {\n"
" $exception = new PDOException($errorInfo[2], $errorInfo[1]);\n"
" $exception->errorInfo = $errorInfo;\n"
" throw $exception;\n"
" }\n"
" $this->reconnect();\n"
" continue;\n"
" }\n"
" if (\n"
" strcasecmp($name, 'prepare') === 0 ||\n"
" strcasecmp($name, 'query') === 0\n"
" ) {\n"
" $ret = new PDOStatementProxy($ret, $this);\n"
" }\n"
" break;\n"
" }\n"
" /* @noinspection PhpUndefinedVariableInspection */\n"
" return $ret;\n"
" }\n"
"\n"
" public function getRound(): int\n"
" {\n"
" return $this->round;\n"
" }\n"
"\n"
" public function reconnect(): void\n"
" {\n"
" $constructor = $this->constructor;\n"
" parent::__construct($constructor());\n"
" $this->round++;\n"
" /* restore context */\n"
" if ($this->setAttributeContext) {\n"
" foreach ($this->setAttributeContext as $attribute => $value) {\n"
" $this->__object->setAttribute($attribute, $value);\n"
" }\n"
" }\n"
" }\n"
"\n"
" public function setAttribute(int $attribute, $value): bool\n"
" {\n"
" $this->setAttributeContext[$attribute] = $value;\n"
" return $this->__object->setAttribute($attribute, $value);\n"
" }\n"
"\n"
" public function inTransaction(): bool\n"
" {\n"
" return $this->__object->inTransaction();\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_database_pdo_statement_proxy =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Database;\n"
"\n"
"use PDO;\n"
"use PDOException;\n"
"use PDOStatement;\n"
"\n"
"class PDOStatementProxy extends ObjectProxy\n"
"{\n"
" /** @var PDOStatement */\n"
" protected $__object;\n"
"\n"
" /** @var null|array */\n"
" protected $setAttributeContext;\n"
"\n"
" /** @var null|array */\n"
" protected $setFetchModeContext;\n"
"\n"
" /** @var null|array */\n"
" protected $bindParamContext;\n"
"\n"
" /** @var null|array */\n"
" protected $bindColumnContext;\n"
"\n"
" /** @var null|array */\n"
" protected $bindValueContext;\n"
"\n"
" /** @var PDO|PDOProxy */\n"
" protected $parent;\n"
"\n"
" /** @var int */\n"
" protected $parentRound;\n"
"\n"
" public function __construct(PDOStatement $object, PDOProxy $parent)\n"
" {\n"
" parent::__construct($object);\n"
" $this->parent = $parent;\n"
" $this->parentRound = $parent->getRound();\n"
" }\n"
"\n"
" public function __call(string $name, array $arguments)\n"
" {\n"
" for ($n = 3; $n--;) {\n"
" $ret = @$this->__object->{$name}(...$arguments);\n"
" if ($ret === false) {\n"
" /* no IO */\n"
" if (strtolower($name) !== 'execute') {\n"
" break;\n"
" }\n"
" /* no more chances or non-IO failures or in transaction */\n"
" if (\n"
" !in_array($this->__object->errorInfo()[1], $this->parent::IO_ERRORS, true) ||\n"
" $n === 0 ||\n"
" $this->parent->inTransaction()\n"
" ) {\n"
" $errorInfo = $this->__object->errorInfo();\n"
"\n"
" // '00000' means “no error.”, as specified by ANSI SQL and ODBC.\n"
" if ($errorInfo[0] !== '00000') {\n"
" $exception = new PDOException($errorInfo[2], $errorInfo[1]);\n"
" $exception->errorInfo = $errorInfo;\n"
" throw $exception;\n"
" }\n"
" }\n"
" if ($this->parent->getRound() === $this->parentRound) {\n"
" /* if not equal, parent has reconnected */\n"
" $this->parent->reconnect();\n"
" }\n"
" $parent = $this->parent->__getObject();\n"
" $this->__object = $parent->prepare($this->__object->queryString);\n"
" if ($this->__object === false) {\n"
" $errorInfo = $parent->errorInfo();\n"
" $exception = new PDOException($errorInfo[2], $errorInfo[1]);\n"
" $exception->errorInfo = $errorInfo;\n"
" throw $exception;\n"
" }\n"
" if ($this->setAttributeContext) {\n"
" foreach ($this->setAttributeContext as $attribute => $value) {\n"
" $this->__object->setAttribute($attribute, $value);\n"
" }\n"
" }\n"
" if ($this->setFetchModeContext) {\n"
" $this->__object->setFetchMode(...$this->setFetchModeContext);\n"
" }\n"
" if ($this->bindParamContext) {\n"
" foreach ($this->bindParamContext as $param => $arguments) {\n"
" $this->__object->bindParam($param, ...$arguments);\n"
" }\n"
" }\n"
" if ($this->bindColumnContext) {\n"
" foreach ($this->bindColumnContext as $column => $arguments) {\n"
" $this->__object->bindColumn($column, ...$arguments);\n"
" }\n"
" }\n"
" if ($this->bindValueContext) {\n"
" foreach ($this->bindValueContext as $value => $arguments) {\n"
" $this->__object->bindParam($value, ...$arguments);\n"
" }\n"
" }\n"
" continue;\n"
" }\n"
" break;\n"
" }\n"
" /* @noinspection PhpUndefinedVariableInspection */\n"
" return $ret;\n"
" }\n"
"\n"
" public function setAttribute(int $attribute, $value): bool\n"
" {\n"
" $this->setAttributeContext[$attribute] = $value;\n"
" return $this->__object->setAttribute($attribute, $value);\n"
" }\n"
"\n"
" public function setFetchMode(int $mode, $classNameObject = null, array $ctorarfg = []): bool\n"
" {\n"
" $this->setFetchModeContext = [$mode, $classNameObject, $ctorarfg];\n"
" if (!isset($classNameObject)) {\n"
" return $this->__object->setFetchMode($mode);\n"
" }\n"
" return $this->__object->setFetchMode($mode, $classNameObject, $ctorarfg);\n"
" }\n"
"\n"
" public function bindParam($parameter, &$variable, $data_type = PDO::PARAM_STR, $length = null, $driver_options = null): bool\n"
" {\n"
" $this->bindParamContext[$parameter] = [$variable, $data_type, $length, $driver_options];\n"
" return $this->__object->bindParam($parameter, $variable, $data_type, $length, $driver_options);\n"
" }\n"
"\n"
" public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null): bool\n"
" {\n"
" $this->bindColumnContext[$column] = [$param, $type, $maxlen, $driverdata];\n"
" return $this->__object->bindColumn($column, $param, $type, $maxlen, $driverdata);\n"
" }\n"
"\n"
" public function bindValue($parameter, $value, $data_type = PDO::PARAM_STR): bool\n"
" {\n"
" $this->bindValueContext[$parameter] = [$value, $data_type];\n"
" return $this->__object->bindValue($parameter, $value, $data_type);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_database_redis_config =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Database;\n"
"\n"
"class RedisConfig\n"
"{\n"
" /** @var string */\n"
" protected $host = '127.0.0.1';\n"
"\n"
" /** @var int */\n"
" protected $port = 6379;\n"
"\n"
" /** @var float */\n"
" protected $timeout = 0.0;\n"
"\n"
" /** @var string */\n"
" protected $reserved = '';\n"
"\n"
" /** @var int */\n"
" protected $retry_interval = 0;\n"
"\n"
" /** @var float */\n"
" protected $read_timeout = 0.0;\n"
"\n"
" /** @var string */\n"
" protected $auth = '';\n"
"\n"
" /** @var int */\n"
" protected $dbIndex = 0;\n"
"\n"
" public function getHost()\n"
" {\n"
" return $this->host;\n"
" }\n"
"\n"
" public function withHost($host): self\n"
" {\n"
" $this->host = $host;\n"
" return $this;\n"
" }\n"
"\n"
" public function getPort(): int\n"
" {\n"
" return $this->port;\n"
" }\n"
"\n"
" public function withPort(int $port): self\n"
" {\n"
" $this->port = $port;\n"
" return $this;\n"
" }\n"
"\n"
" public function getTimeout(): float\n"
" {\n"
" return $this->timeout;\n"
" }\n"
"\n"
" public function withTimeout(float $timeout): self\n"
" {\n"
" $this->timeout = $timeout;\n"
" return $this;\n"
" }\n"
"\n"
" public function getReserved(): string\n"
" {\n"
" return $this->reserved;\n"
" }\n"
"\n"
" public function withReserved(string $reserved): self\n"
" {\n"
" $this->reserved = $reserved;\n"
" return $this;\n"
" }\n"
"\n"
" public function getRetryInterval(): int\n"
" {\n"
" return $this->retry_interval;\n"
" }\n"
"\n"
" public function withRetryInterval(int $retry_interval): self\n"
" {\n"
" $this->retry_interval = $retry_interval;\n"
" return $this;\n"
" }\n"
"\n"
" public function getReadTimeout(): float\n"
" {\n"
" return $this->read_timeout;\n"
" }\n"
"\n"
" public function withReadTimeout(float $read_timeout): self\n"
" {\n"
" $this->read_timeout = $read_timeout;\n"
" return $this;\n"
" }\n"
"\n"
" public function getAuth(): string\n"
" {\n"
" return $this->auth;\n"
" }\n"
"\n"
" public function withAuth(string $auth): self\n"
" {\n"
" $this->auth = $auth;\n"
" return $this;\n"
" }\n"
"\n"
" public function getDbIndex(): int\n"
" {\n"
" return $this->dbIndex;\n"
" }\n"
"\n"
" public function withDbIndex(int $dbIndex): self\n"
" {\n"
" $this->dbIndex = $dbIndex;\n"
" return $this;\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_database_redis_pool =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Database;\n"
"\n"
"use Redis;\n"
"use Swoole\\ConnectionPool;\n"
"\n"
"/**\n"
" * @method Redis get()\n"
" * @method void put(Redis $connection)\n"
" */\n"
"class RedisPool extends ConnectionPool\n"
"{\n"
" /** @var RedisConfig */\n"
" protected $config;\n"
"\n"
" public function __construct(RedisConfig $config, int $size = self::DEFAULT_SIZE)\n"
" {\n"
" $this->config = $config;\n"
" parent::__construct(function () {\n"
" $redis = new Redis();\n"
" /* Compatible with different versions of Redis extension as much as possible */\n"
" $arguments = [\n"
" $this->config->getHost(),\n"
" $this->config->getPort(),\n"
" $this->config->getTimeout(),\n"
" $this->config->getReserved(),\n"
" $this->config->getRetryInterval(),\n"
" $this->config->getReadTimeout(),\n"
" ];\n"
" $arguments = array_filter($arguments);\n"
" $redis->connect(...$arguments);\n"
" if ($this->config->getAuth()) {\n"
" $redis->auth($this->config->getAuth());\n"
" }\n"
" if ($this->config->getDbIndex() !== 0) {\n"
" $redis->select($this->config->getDbIndex());\n"
" }\n"
" return $redis;\n"
" }, $size);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_http_status =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Http;\n"
"\n"
"abstract class Status\n"
"{\n"
" public const CONTINUE = 100;\n"
"\n"
" public const SWITCHING_PROTOCOLS = 101;\n"
"\n"
" public const PROCESSING = 102;\n"
"\n"
" public const OK = 200;\n"
"\n"
" public const CREATED = 201;\n"
"\n"
" public const ACCEPTED = 202;\n"
"\n"
" public const NON_AUTHORITATIVE_INFORMATION = 203;\n"
"\n"
" public const NO_CONTENT = 204;\n"
"\n"
" public const RESET_CONTENT = 205;\n"
"\n"
" public const PARTIAL_CONTENT = 206;\n"
"\n"
" public const MULTI_STATUS = 207;\n"
"\n"
" public const ALREADY_REPORTED = 208;\n"
"\n"
" public const IM_USED = 226;\n"
"\n"
" public const MULTIPLE_CHOICES = 300;\n"
"\n"
" public const MOVED_PERMANENTLY = 301;\n"
"\n"
" public const FOUND = 302;\n"
"\n"
" public const SEE_OTHER = 303;\n"
"\n"
" public const NOT_MODIFIED = 304;\n"
"\n"
" public const USE_PROXY = 305;\n"
"\n"
" public const SWITCH_PROXY = 306;\n"
"\n"
" public const TEMPORARY_REDIRECT = 307;\n"
"\n"
" public const PERMANENT_REDIRECT = 308;\n"
"\n"
" public const BAD_REQUEST = 400;\n"
"\n"
" public const UNAUTHORIZED = 401;\n"
"\n"
" public const PAYMENT_REQUIRED = 402;\n"
"\n"
" public const FORBIDDEN = 403;\n"
"\n"
" public const NOT_FOUND = 404;\n"
"\n"
" public const METHOD_NOT_ALLOWED = 405;\n"
"\n"
" public const NOT_ACCEPTABLE = 406;\n"
"\n"
" public const PROXY_AUTHENTICATION_REQUIRED = 407;\n"
"\n"
" public const REQUEST_TIME_OUT = 408;\n"
"\n"
" public const CONFLICT = 409;\n"
"\n"
" public const GONE = 410;\n"
"\n"
" public const LENGTH_REQUIRED = 411;\n"
"\n"
" public const PRECONDITION_FAILED = 412;\n"
"\n"
" public const REQUEST_ENTITY_TOO_LARGE = 413;\n"
"\n"
" public const REQUEST_URI_TOO_LARGE = 414;\n"
"\n"
" public const UNSUPPORTED_MEDIA_TYPE = 415;\n"
"\n"
" public const REQUESTED_RANGE_NOT_SATISFIABLE = 416;\n"
"\n"
" public const EXPECTATION_FAILED = 417;\n"
"\n"
" public const MISDIRECTED_REQUEST = 421;\n"
"\n"
" public const UNPROCESSABLE_ENTITY = 422;\n"
"\n"
" public const LOCKED = 423;\n"
"\n"
" public const FAILED_DEPENDENCY = 424;\n"
"\n"
" public const UNORDERED_COLLECTION = 425;\n"
"\n"
" public const UPGRADE_REQUIRED = 426;\n"
"\n"
" public const PRECONDITION_REQUIRED = 428;\n"
"\n"
" public const TOO_MANY_REQUESTS = 429;\n"
"\n"
" public const REQUEST_HEADER_FIELDS_TOO_LARGE = 431;\n"
"\n"
" public const UNAVAILABLE_FOR_LEGAL_REASONS = 451;\n"
"\n"
" public const INTERNAL_SERVER_ERROR = 500;\n"
"\n"
" public const NOT_IMPLEMENTED = 501;\n"
"\n"
" public const BAD_GATEWAY = 502;\n"
"\n"
" public const SERVICE_UNAVAILABLE = 503;\n"
"\n"
" public const GATEWAY_TIME_OUT = 504;\n"
"\n"
" public const HTTP_VERSION_NOT_SUPPORTED = 505;\n"
"\n"
" public const VARIANT_ALSO_NEGOTIATES = 506;\n"
"\n"
" public const INSUFFICIENT_STORAGE = 507;\n"
"\n"
" public const LOOP_DETECTED = 508;\n"
"\n"
" public const NOT_EXTENDED = 510;\n"
"\n"
" public const NETWORK_AUTHENTICATION_REQUIRED = 511;\n"
"\n"
" protected static $reasonPhrases = [\n"
" self::CONTINUE => 'Continue',\n"
" self::SWITCHING_PROTOCOLS => 'Switching Protocols',\n"
" self::PROCESSING => 'Processing',\n"
" self::OK => 'OK',\n"
" self::CREATED => 'Created',\n"
" self::ACCEPTED => 'Accepted',\n"
" self::NON_AUTHORITATIVE_INFORMATION => 'Non-Authoritative Information',\n"
" self::NO_CONTENT => 'No Content',\n"
" self::RESET_CONTENT => 'Reset Content',\n"
" self::PARTIAL_CONTENT => 'Partial Content',\n"
" self::MULTI_STATUS => 'Multi-status',\n"
" self::ALREADY_REPORTED => 'Already Reported',\n"
" self::IM_USED => 'IM Used',\n"
" self::MULTIPLE_CHOICES => 'Multiple Choices',\n"
" self::MOVED_PERMANENTLY => 'Moved Permanently',\n"
" self::FOUND => 'Found',\n"
" self::SEE_OTHER => 'See Other',\n"
" self::NOT_MODIFIED => 'Not Modified',\n"
" self::USE_PROXY => 'Use Proxy',\n"
" self::SWITCH_PROXY => 'Switch Proxy',\n"
" self::TEMPORARY_REDIRECT => 'Temporary Redirect',\n"
" self::PERMANENT_REDIRECT => 'Permanent Redirect',\n"
" self::BAD_REQUEST => 'Bad Request',\n"
" self::UNAUTHORIZED => 'Unauthorized',\n"
" self::PAYMENT_REQUIRED => 'Payment Required',\n"
" self::FORBIDDEN => 'Forbidden',\n"
" self::NOT_FOUND => 'Not Found',\n"
" self::METHOD_NOT_ALLOWED => 'Method Not Allowed',\n"
" self::NOT_ACCEPTABLE => 'Not Acceptable',\n"
" self::PROXY_AUTHENTICATION_REQUIRED => 'Proxy Authentication Required',\n"
" self::REQUEST_TIME_OUT => 'Request Time-out',\n"
" self::CONFLICT => 'Conflict',\n"
" self::GONE => 'Gone',\n"
" self::LENGTH_REQUIRED => 'Length Required',\n"
" self::PRECONDITION_FAILED => 'Precondition Failed',\n"
" self::REQUEST_ENTITY_TOO_LARGE => 'Request Entity Too Large',\n"
" self::REQUEST_URI_TOO_LARGE => 'Request-URI Too Large',\n"
" self::UNSUPPORTED_MEDIA_TYPE => 'Unsupported Media Type',\n"
" self::REQUESTED_RANGE_NOT_SATISFIABLE => 'Requested range not satisfiable',\n"
" self::EXPECTATION_FAILED => 'Expectation Failed',\n"
" self::MISDIRECTED_REQUEST => 'Unprocessable Entity',\n"
" self::UNPROCESSABLE_ENTITY => 'Unprocessable Entity',\n"
" self::LOCKED => 'Locked',\n"
" self::FAILED_DEPENDENCY => 'Failed Dependency',\n"
" self::UNORDERED_COLLECTION => 'Unordered Collection',\n"
" self::UPGRADE_REQUIRED => 'Upgrade Required',\n"
" self::PRECONDITION_REQUIRED => 'Precondition Required',\n"
" self::TOO_MANY_REQUESTS => 'Too Many Requests',\n"
" self::REQUEST_HEADER_FIELDS_TOO_LARGE => 'Request Header Fields Too Large',\n"
" self::UNAVAILABLE_FOR_LEGAL_REASONS => 'Unavailable For Legal Reasons',\n"
" self::INTERNAL_SERVER_ERROR => 'Internal Server Error',\n"
" self::NOT_IMPLEMENTED => 'Not Implemented',\n"
" self::BAD_GATEWAY => 'Bad Gateway',\n"
" self::SERVICE_UNAVAILABLE => 'Service Unavailable',\n"
" self::GATEWAY_TIME_OUT => 'Gateway Time-out',\n"
" self::HTTP_VERSION_NOT_SUPPORTED => 'HTTP Version not supported',\n"
" self::VARIANT_ALSO_NEGOTIATES => 'Variant Also Negotiates',\n"
" self::INSUFFICIENT_STORAGE => 'Insufficient Storage',\n"
" self::LOOP_DETECTED => 'Loop Detected',\n"
" self::NOT_EXTENDED => 'Not Extended',\n"
" self::NETWORK_AUTHENTICATION_REQUIRED => 'Network Authentication Required',\n"
" ];\n"
"\n"
" public static function getReasonPhrases(): array\n"
" {\n"
" return static::$reasonPhrases;\n"
" }\n"
"\n"
" public static function getReasonPhrase(int $value): string\n"
" {\n"
" return static::$reasonPhrases[$value] ?? 'Unknown';\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_curl_exception =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Curl;\n"
"\n"
"use Swoole;\n"
"\n"
"class Exception extends Swoole\\Exception\n"
"{\n"
"}\n";
static const char* swoole_library_source_core_curl_handler =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"/* @noinspection PhpComposerExtensionStubsInspection, PhpDuplicateSwitchCaseBodyInspection, PhpInconsistentReturnPointsInspection */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Curl;\n"
"\n"
"use CURLFile;\n"
"use ReflectionClass;\n"
"use Swoole;\n"
"use Swoole\\Constant;\n"
"use Swoole\\Coroutine\\Http\\Client;\n"
"use Swoole\\Curl\\Exception as CurlException;\n"
"use Swoole\\Http\\Status;\n"
"\n"
"final class Handler\n"
"{\n"
" /**\n"
" * @var Client\n"
" */\n"
" private $client;\n"
"\n"
" private $info = [\n"
" 'url' => '',\n"
" 'content_type' => '',\n"
" 'http_code' => 0,\n"
" 'header_size' => 0,\n"
" 'request_size' => 0,\n"
" 'filetime' => -1,\n"
" 'ssl_verify_result' => 0,\n"
" 'redirect_count' => 0,\n"
" 'total_time' => 5.3E-5,\n"
" 'namelookup_time' => 0.0,\n"
" 'connect_time' => 0.0,\n"
" 'pretransfer_time' => 0.0,\n"
" 'size_upload' => 0.0,\n"
" 'size_download' => 0.0,\n"
" 'speed_download' => 0.0,\n"
" 'speed_upload' => 0.0,\n"
" 'download_content_length' => -1.0,\n"
" 'upload_content_length' => -1.0,\n"
" 'starttransfer_time' => 0.0,\n"
" 'redirect_time' => 0.0,\n"
" 'redirect_url' => '',\n"
" 'primary_ip' => '',\n"
" 'certinfo' => [],\n"
" 'primary_port' => 0,\n"
" 'local_ip' => '',\n"
" 'local_port' => 0,\n"
" 'http_version' => 0,\n"
" 'protocol' => 0,\n"
" 'ssl_verifyresult' => 0,\n"
" 'scheme' => '',\n"
" ];\n"
"\n"
" private $withHeaderOut = false;\n"
"\n"
" private $withFileTime = false;\n"
"\n"
" private $urlInfo;\n"
"\n"
" private $postData;\n"
"\n"
" private $infile;\n"
"\n"
" private $infileSize = PHP_INT_MAX;\n"
"\n"
" private $outputStream;\n"
"\n"
" private $proxyType;\n"
"\n"
" private $proxy;\n"
"\n"
" private $proxyPort = 1080;\n"
"\n"
" private $proxyUsername;\n"
"\n"
" private $proxyPassword;\n"
"\n"
" private $clientOptions = [];\n"
"\n"
" private $followLocation = false;\n"
"\n"
" private $autoReferer = false;\n"
"\n"
" private $maxRedirects;\n"
"\n"
" private $withHeader = false;\n"
"\n"
" private $nobody = false;\n"
"\n"
" /** @var callable */\n"
" private $headerFunction;\n"
"\n"
" /** @var callable */\n"
" private $readFunction;\n"
"\n"
" /** @var callable */\n"
" private $writeFunction;\n"
"\n"
" /** @var callable */\n"
" private $progressFunction;\n"
"\n"
" private $returnTransfer = false;\n"
"\n"
" private $method = '';\n"
"\n"
" private $headers = [];\n"
"\n"
" private $transfer;\n"
"\n"
" private $errCode = 0;\n"
"\n"
" private $errMsg = '';\n"
"\n"
" private $failOnError = false;\n"
"\n"
" private $closed = false;\n"
"\n"
" public function __construct(string $url = '')\n"
" {\n"
" if ($url) {\n"
" $this->setUrl($url);\n"
" }\n"
" }\n"
"\n"
" public function __toString()\n"
" {\n"
" if (PHP_VERSION_ID < 70200) {\n"
" $id = spl_object_hash($this);\n"
" } else {\n"
" $id = spl_object_id($this);\n"
" }\n"
" return \"Object({$id}) of type (curl)\";\n"
" }\n"
"\n"
" /* ====== Public APIs ====== */\n"
"\n"
" public function isAvailable(): bool\n"
" {\n"
" if ($this->closed) {\n"
" trigger_error('supplied resource is not a valid cURL handle resource', E_USER_WARNING);\n"
" return false;\n"
" }\n"
" return true;\n"
" }\n"
"\n"
" public function setOpt(int $opt, $value): bool\n"
" {\n"
" return $this->isAvailable() and $this->setOption($opt, $value);\n"
" }\n"
"\n"
" public function exec()\n"
" {\n"
" if (!$this->isAvailable()) {\n"
" return false;\n"
" }\n"
" return $this->execute();\n"
" }\n"
"\n"
" public function getInfo()\n"
" {\n"
" return $this->isAvailable() ? $this->info : false;\n"
" }\n"
"\n"
" public function errno()\n"
" {\n"
" return $this->isAvailable() ? $this->errCode : false;\n"
" }\n"
"\n"
" public function error()\n"
" {\n"
" return $this->isAvailable() ? $this->errMsg : false;\n"
" }\n"
"\n"
" public function reset()\n"
" {\n"
" if (!$this->isAvailable()) {\n"
" return false;\n"
" }\n"
" foreach ((new ReflectionClass(static::class))->getDefaultProperties() as $name => $value) {\n"
" $this->{$name} = $value;\n"
" }\n"
" }\n"
"\n"
" public function getContent()\n"
" {\n"
" if (!$this->isAvailable()) {\n"
" return false;\n"
" }\n"
" return $this->transfer;\n"
" }\n"
"\n"
" public function close()\n"
" {\n"
" if (!$this->isAvailable()) {\n"
" return false;\n"
" }\n"
" foreach ($this as &$property) {\n"
" $property = null;\n"
" }\n"
" $this->closed = true;\n"
" }\n"
"\n"
" private function create(?array $urlInfo = null): void\n"
" {\n"
" if ($urlInfo === null) {\n"
" $urlInfo = $this->urlInfo;\n"
" }\n"
" $this->client = new Client($urlInfo['host'], $urlInfo['port'], $urlInfo['scheme'] === 'https');\n"
" }\n"
"\n"
" private function getUrl(): string\n"
" {\n"
" if (empty($this->urlInfo['path'])) {\n"
" $url = '/';\n"
" } else {\n"
" $url = $this->urlInfo['path'];\n"
" }\n"
" if (!empty($this->urlInfo['query'])) {\n"
" $url .= '?' . $this->urlInfo['query'];\n"
" }\n"
" if (!empty($this->urlInfo['fragment'])) {\n"
" $url .= '#' . $this->urlInfo['fragment'];\n"
" }\n"
" return $url;\n"
" }\n"
"\n"
" private function setUrl(string $url, bool $setInfo = true): bool\n"
" {\n"
" if (strlen($url) === 0) {\n"
" $this->setError(CURLE_URL_MALFORMAT, 'No URL set!');\n"
" return false;\n"
" }\n"
" if (strpos($url, '://') === false) {\n"
" $url = 'http://' . $url;\n"
" }\n"
" if ($setInfo) {\n"
" $urlInfo = parse_url($url);\n"
" if (!is_array($urlInfo)) {\n"
" $this->setError(CURLE_URL_MALFORMAT, \"URL[{$url}] using bad/illegal format\");\n"
" return false;\n"
" }\n"
" if (!$this->setUrlInfo($urlInfo)) {\n"
" return false;\n"
" }\n"
" }\n"
" $this->info['url'] = $url;\n"
" return true;\n"
" }\n"
"\n"
" private function setUrlInfo(array $urlInfo): bool\n"
" {\n"
" if (empty($urlInfo['scheme'])) {\n"
" $urlInfo['scheme'] = 'http';\n"
" }\n"
" $scheme = $urlInfo['scheme'];\n"
" if ($scheme !== 'http' and $scheme !== 'https') {\n"
" $this->setError(CURLE_UNSUPPORTED_PROTOCOL, \"Protocol \\\"{$scheme}\\\" not supported or disabled in libcurl\");\n"
" return false;\n"
" }\n"
" $host = $urlInfo['host'];\n"
" if ($this->info['primary_port'] !== 0) {\n"
" /* keep same with cURL, primary_port has the highest priority */\n"
" $urlInfo['port'] = $this->info['primary_port'];\n"
" } elseif (empty($urlInfo['port'])) {\n"
" $urlInfo['port'] = $scheme === 'https' ? 443 : 80;\n"
" } else {\n"
" $urlInfo['port'] = intval($urlInfo['port']);\n"
" }\n"
" $port = $urlInfo['port'];\n"
" if ($this->client) {\n"
" $oldUrlInfo = $this->urlInfo;\n"
" if (\n"
" $host !== $oldUrlInfo['host'] or\n"
" $port !== $oldUrlInfo['port'] or\n"
" $scheme !== $oldUrlInfo['scheme']\n"
" ) {\n"
" /* target changed */\n"
" $this->create($urlInfo);\n"
" }\n"
" }\n"
" $this->urlInfo = $urlInfo;\n"
" return true;\n"
" }\n"
"\n"
" private function setPort(int $port): void\n"
" {\n"
" $this->info['primary_port'] = $port;\n"
" if ($this->urlInfo['port'] !== $port) {\n"
" $this->urlInfo['port'] = $port;\n"
" if ($this->client) {\n"
" /* target changed */\n"
" $this->create();\n"
" }\n"
" }\n"
" }\n"
"\n"
" private function setError($code, $msg = ''): void\n"
" {\n"
" $this->errCode = $code;\n"
" $this->errMsg = $msg ? $msg : curl_strerror($code);\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $value\n"
" * @throws Swoole\\Curl\\Exception\n"
" */\n"
" private function setOption(int $opt, $value): bool\n"
" {\n"
" switch ($opt) {\n"
" // case CURLOPT_STDERR:\n"
" // case CURLOPT_WRITEHEADER:\n"
" case CURLOPT_FILE:\n"
" case CURLOPT_INFILE:\n"
" if (!is_resource($value)) {\n"
" trigger_error(E_USER_WARNING, 'swoole_curl_setopt(): supplied argument is not a valid File-Handle resource');\n"
" return false;\n"
" }\n"
" break;\n"
" }\n"
"\n"
" switch ($opt) {\n"
" /*\n"
" * Basic\n"
" */\n"
" case CURLOPT_URL:\n"
" return $this->setUrl((string) $value);\n"
" case CURLOPT_PORT:\n"
" $this->setPort((int) $value);\n"
" break;\n"
" case CURLOPT_FORBID_REUSE:\n"
" $this->clientOptions[Constant::OPTION_KEEP_ALIVE] = !$value;\n"
" break;\n"
" case CURLOPT_RETURNTRANSFER:\n"
" $this->returnTransfer = $value;\n"
" $this->transfer = '';\n"
" break;\n"
" case CURLOPT_ENCODING:\n"
" if (empty($value)) {\n"
" if (defined('SWOOLE_HAVE_ZLIB')) {\n"
" $value = 'gzip, deflate';\n"
" }\n"
" if (defined('SWOOLE_HAVE_BROTLI')) {\n"
" if (!empty($value)) {\n"
" $value = 'br, ' . $value;\n"
" } else {\n"
" $value = 'br';\n"
" }\n"
" }\n"
" if (empty($value)) {\n"
" break;\n"
" }\n"
" }\n"
" $this->headers['Accept-Encoding'] = $value;\n"
" break;\n"
" case CURLOPT_PROXYTYPE:\n"
" if ($value !== CURLPROXY_HTTP and $value !== CURLPROXY_SOCKS5) {\n"
" throw new Swoole\\Curl\\Exception(\n"
" 'swoole_curl_setopt(): Only support following CURLOPT_PROXYTYPE values: CURLPROXY_HTTP, CURLPROXY_SOCKS5'\n"
" );\n"
" }\n"
" $this->proxyType = $value;\n"
" break;\n"
" case CURLOPT_PROXY:\n"
" $this->proxy = $value;\n"
" break;\n"
" case CURLOPT_PROXYPORT:\n"
" $this->proxyPort = $value;\n"
" break;\n"
" case CURLOPT_PROXYUSERNAME:\n"
" $this->proxyUsername = $value;\n"
" break;\n"
" case CURLOPT_PROXYPASSWORD:\n"
" $this->proxyPassword = $value;\n"
" break;\n"
" case CURLOPT_PROXYUSERPWD:\n"
" $usernamePassword = explode(':', $value);\n"
" $this->proxyUsername = urldecode($usernamePassword[0]);\n"
" $this->proxyPassword = urldecode($usernamePassword[1] ?? null);\n"
" break;\n"
" case CURLOPT_PROXYAUTH:\n"
" /* ignored temporarily */\n"
" break;\n"
" case CURLOPT_NOBODY:\n"
" $this->nobody = boolval($value);\n"
" $this->method = 'HEAD';\n"
" break;\n"
" case CURLOPT_IPRESOLVE:\n"
" if ($value !== CURL_IPRESOLVE_WHATEVER and $value !== CURL_IPRESOLVE_V4) {\n"
" throw new Swoole\\Curl\\Exception(\n"
" 'swoole_curl_setopt(): Only support following CURLOPT_IPRESOLVE values: CURL_IPRESOLVE_WHATEVER, CURL_IPRESOLVE_V4'\n"
" );\n"
" }\n"
" break;\n"
" /*\n"
" * Ignore options\n"
" */\n"
" case CURLOPT_VERBOSE:\n"
" // trigger_error(E_USER_WARNING, 'swoole_curl_setopt(): CURLOPT_VERBOSE is not supported');\n"
" case CURLOPT_SSLVERSION:\n"
" case CURLOPT_NOSIGNAL:\n"
" case CURLOPT_FRESH_CONNECT:\n"
" /*\n"
" * From PHP 5.1.3, this option has no effect: the raw output will always be returned when CURLOPT_RETURNTRANSFER is used.\n"
" */\n"
" case CURLOPT_BINARYTRANSFER: /* TODO */\n"
" case CURLOPT_DNS_USE_GLOBAL_CACHE:\n"
" case CURLOPT_DNS_CACHE_TIMEOUT:\n"
" case CURLOPT_STDERR:\n"
" case CURLOPT_WRITEHEADER:\n"
" case CURLOPT_BUFFERSIZE:\n"
" case CURLOPT_SSLCERTTYPE:\n"
" case CURLOPT_SSLKEYTYPE:\n"
" break;\n"
" /*\n"
" * SSL\n"
" */\n"
" case CURLOPT_SSL_VERIFYHOST:\n"
" break;\n"
" case CURLOPT_SSL_VERIFYPEER:\n"
" $this->clientOptions[Constant::OPTION_SSL_VERIFY_PEER] = $value;\n"
" break;\n"
" case CURLOPT_SSLCERT:\n"
" $this->clientOptions[Constant::OPTION_SSL_CERT_FILE] = $value;\n"
" break;\n"
" case CURLOPT_SSLKEY:\n"
" $this->clientOptions[Constant::OPTION_SSL_KEY_FILE] = $value;\n"
" break;\n"
" case CURLOPT_CAINFO:\n"
" $this->clientOptions[Constant::OPTION_SSL_CAFILE] = $value;\n"
" break;\n"
" case CURLOPT_CAPATH:\n"
" $this->clientOptions[Constant::OPTION_SSL_CAPATH] = $value;\n"
" break;\n"
" /*\n"
" * Http POST\n"
" */\n"
" case CURLOPT_POST:\n"
" $this->method = 'POST';\n"
" break;\n"
" case CURLOPT_POSTFIELDS:\n"
" $this->postData = $value;\n"
" if (!$this->method) {\n"
" $this->method = 'POST';\n"
" }\n"
" break;\n"
" /*\n"
" * Upload\n"
" */\n"
" case CURLOPT_SAFE_UPLOAD:\n"
" if (!$value) {\n"
" trigger_error('swoole_curl_setopt(): Disabling safe uploads is no longer supported', E_USER_WARNING);\n"
" return false;\n"
" }\n"
" break;\n"
" /*\n"
" * Http Header\n"
" */\n"
" case CURLOPT_HTTPHEADER:\n"
" if (!is_array($value) and !is_iterable($value)) {\n"
" trigger_error('swoole_curl_setopt(): You must pass either an object or an array with the CURLOPT_HTTPHEADER argument', E_USER_WARNING);\n"
" return false;\n"
" }\n"
" foreach ($value as $header) {\n"
" $header = explode(':', $header, 2);\n"
" $headerName = $header[0];\n"
" $headerValue = trim($header[1] ?? '');\n"
" if (strlen($headerValue) === 0) {\n"
" continue;\n"
" }\n"
" $this->headers[$headerName] = $headerValue;\n"
" }\n"
" break;\n"
" case CURLOPT_REFERER:\n"
" $this->headers['Referer'] = $value;\n"
" break;\n"
" case CURLINFO_HEADER_OUT:\n"
" $this->withHeaderOut = boolval($value);\n"
" break;\n"
" case CURLOPT_FILETIME:\n"
" $this->withFileTime = boolval($value);\n"
" break;\n"
" case CURLOPT_USERAGENT:\n"
" $this->headers['User-Agent'] = $value;\n"
" break;\n"
" case CURLOPT_CUSTOMREQUEST:\n"
" $this->method = (string) $value;\n"
" break;\n"
" case CURLOPT_PROTOCOLS:\n"
" if ($value > 3) {\n"
" throw new CurlException(\"swoole_curl_setopt(): CURLOPT_PROTOCOLS[{$value}] is not supported\");\n"
" }\n"
" break;\n"
" case CURLOPT_HTTP_VERSION:\n"
" if ($value != CURL_HTTP_VERSION_1_1) {\n"
" trigger_error(\"swoole_curl_setopt(): CURLOPT_HTTP_VERSION[{$value}] is not supported\", E_USER_WARNING);\n"
" return false;\n"
" }\n"
" break;\n"
" case CURLOPT_FAILONERROR:\n"
" $this->failOnError = $value;\n"
" break;\n"
" /*\n"
" * Http Cookie\n"
" */\n"
" case CURLOPT_COOKIE:\n"
" $this->headers['Cookie'] = $value;\n"
" break;\n"
" case CURLOPT_CONNECTTIMEOUT:\n"
" $this->clientOptions[Constant::OPTION_CONNECT_TIMEOUT] = $value;\n"
" break;\n"
" case CURLOPT_CONNECTTIMEOUT_MS:\n"
" $this->clientOptions[Constant::OPTION_CONNECT_TIMEOUT] = $value / 1000;\n"
" break;\n"
" case CURLOPT_TIMEOUT:\n"
" $this->clientOptions[Constant::OPTION_TIMEOUT] = $value;\n"
" break;\n"
" case CURLOPT_TIMEOUT_MS:\n"
" $this->clientOptions[Constant::OPTION_TIMEOUT] = $value / 1000;\n"
" break;\n"
" case CURLOPT_FILE:\n"
" $this->outputStream = $value;\n"
" break;\n"
" case CURLOPT_HEADER:\n"
" $this->withHeader = $value;\n"
" break;\n"
" case CURLOPT_HEADERFUNCTION:\n"
" $this->headerFunction = $value;\n"
" break;\n"
" case CURLOPT_READFUNCTION:\n"
" $this->readFunction = $value;\n"
" break;\n"
" case CURLOPT_WRITEFUNCTION:\n"
" $this->writeFunction = $value;\n"
" break;\n"
" case CURLOPT_PROGRESSFUNCTION:\n"
" $this->progressFunction = $value;\n"
" break;\n"
" case CURLOPT_HTTPAUTH:\n"
" if (!($value & CURLAUTH_BASIC)) {\n"
" trigger_error(\"swoole_curl_setopt(): CURLOPT_HTTPAUTH[{$value}] is not supported\", E_USER_WARNING);\n"
" return false;\n"
" }\n"
" break;\n"
" case CURLOPT_USERPWD:\n"
" $this->headers['Authorization'] = 'Basic ' . base64_encode($value);\n"
" break;\n"
" case CURLOPT_FOLLOWLOCATION:\n"
" $this->followLocation = $value;\n"
" break;\n"
" case CURLOPT_AUTOREFERER:\n"
" $this->autoReferer = $value;\n"
" break;\n"
" case CURLOPT_MAXREDIRS:\n"
" $this->maxRedirects = $value;\n"
" break;\n"
" case CURLOPT_PUT:\n"
" case CURLOPT_UPLOAD:\n"
" /* after libcurl 7.12, CURLOPT_PUT is replaced by CURLOPT_UPLOAD */\n"
" $this->method = 'PUT';\n"
" break;\n"
" case CURLOPT_INFILE:\n"
" $this->infile = $value;\n"
" break;\n"
" case CURLOPT_INFILESIZE:\n"
" $this->infileSize = $value;\n"
" break;\n"
" case CURLOPT_HTTPGET:\n"
" /* Since GET is the default, this is only necessary if the request method has been changed. */\n"
" $this->method = 'GET';\n"
" break;\n"
" default:\n"
" throw new Swoole\\Curl\\Exception(\"swoole_curl_setopt(): option[{$opt}] is not supported\");\n"
" }\n"
" return true;\n"
" }\n"
"\n"
" private function execute()\n"
" {\n"
" $this->info['redirect_count'] = $this->info['starttransfer_time'] = 0;\n"
" $this->info['redirect_url'] = '';\n"
" $timeBegin = microtime(true);\n"
" /*\n"
" * Socket\n"
" */\n"
" if (!$this->urlInfo) {\n"
" $this->setError(CURLE_URL_MALFORMAT, 'No URL set or URL using bad/illegal format');\n"
" return false;\n"
" }\n"
" if (!$this->client) {\n"
" $this->create();\n"
" }\n"
" do {\n"
" $client = $this->client;\n"
" /*\n"
" * Http Proxy\n"
" */\n"
" if ($this->proxy) {\n"
" $proxy = explode(':', $this->proxy);\n"
" $proxyPort = $proxy[1] ?? $this->proxyPort;\n"
" $proxy = $proxy[0];\n"
" if (!filter_var($proxy, FILTER_VALIDATE_IP)) {\n"
" $ip = Swoole\\Coroutine::gethostbyname($proxy, AF_INET, $this->clientOptions['connect_timeout'] ?? -1);\n"
" if (!$ip) {\n"
" $this->setError(CURLE_COULDNT_RESOLVE_PROXY, 'Could not resolve proxy: ' . $proxy);\n"
" return false;\n"
" }\n"
" $this->proxy = $proxy = $ip;\n"
" }\n"
" switch ($this->proxyType) {\n"
" case CURLPROXY_HTTP:\n"
" $proxyOptions = [\n"
" 'http_proxy_host' => $proxy,\n"
" 'http_proxy_port' => $proxyPort,\n"
" 'http_proxy_username' => $this->proxyUsername,\n"
" 'http_proxy_password' => $this->proxyPassword,\n"
" ];\n"
" break;\n"
" case CURLPROXY_SOCKS5:\n"
" $proxyOptions = [\n"
" 'socks5_host' => $proxy,\n"
" 'socks5_port' => $proxyPort,\n"
" 'socks5_username' => $this->proxyUsername,\n"
" 'socks5_password' => $this->proxyPassword,\n"
" ];\n"
" break;\n"
" default:\n"
" throw new CurlException(\"Unexpected proxy type [{$this->proxyType}]\");\n"
" }\n"
" }\n"
" /*\n"
" * Client Options\n"
" */\n"
" $client->set(\n"
" $this->clientOptions +\n"
" ($proxyOptions ?? [])\n"
" );\n"
" /*\n"
" * Method\n"
" */\n"
" if ($this->method) {\n"
" $client->setMethod($this->method);\n"
" }\n"
" /*\n"
" * Data\n"
" */\n"
" if ($this->infile) {\n"
" // Infile\n"
" // Notice: we make its priority higher than postData but raw cURL will send both of them\n"
" $data = '';\n"
" while (true) {\n"
" $nLength = $this->infileSize - strlen($data);\n"
" if ($nLength === 0) {\n"
" break;\n"
" }\n"
" if (feof($this->infile)) {\n"
" break;\n"
" }\n"
" $data .= fread($this->infile, $nLength);\n"
" }\n"
" $client->setData($data);\n"
" // Notice: although we reset it, raw cURL never do this\n"
" $this->infile = null;\n"
" $this->infileSize = PHP_INT_MAX;\n"
" } else {\n"
" // POST data\n"
" if ($this->postData) {\n"
" if (is_string($this->postData)) {\n"
" if (empty($this->headers['Content-Type'])) {\n"
" $this->headers['Content-Type'] = 'application/x-www-form-urlencoded';\n"
" }\n"
" } elseif (is_array($this->postData)) {\n"
" foreach ($this->postData as $k => $v) {\n"
" if ($v instanceof CURLFile) {\n"
" $client->addFile($v->getFilename(), $k, $v->getMimeType() ?: 'application/octet-stream', $v->getPostFilename());\n"
" unset($this->postData[$k]);\n"
" }\n"
" }\n"
" }\n"
" }\n"
" $client->setData($this->postData);\n"
" }\n"
" /*\n"
" * Headers\n"
" */\n"
" // Notice: setHeaders must be placed last, because headers may be changed by other parts\n"
" // As much as possible to ensure that Host is the first header.\n"
" // See: http://tools.ietf.org/html/rfc7230#section-5.4\n"
" foreach ($this->headers as $headerName => $headerValue) {\n"
" if ($headerValue === '') {\n"
" // remove empty headers (keep same with raw cURL)\n"
" unset($this->headers[$headerName]);\n"
" }\n"
" }\n"
" $client->setHeaders($this->headers);\n"
" /**\n"
" * Execute.\n"
" */\n"
" $executeResult = $client->execute($this->getUrl());\n"
" if (!$executeResult) {\n"
" $errCode = $client->errCode;\n"
" if ($errCode == SWOOLE_ERROR_DNSLOOKUP_RESOLVE_FAILED or $errCode == SWOOLE_ERROR_DNSLOOKUP_RESOLVE_TIMEOUT) {\n"
" $this->setError(CURLE_COULDNT_RESOLVE_HOST, 'Could not resolve host: ' . $client->host);\n"
" }\n"
" $this->info['total_time'] = microtime(true) - $timeBegin;\n"
" return false;\n"
" }\n"
" if ($client->statusCode >= 300 and $client->statusCode < 400 and isset($client->headers['location'])) {\n"
" $redirectParsedUrl = $this->getRedirectUrl($client->headers['location']);\n"
" $redirectUrl = static::unparseUrl($redirectParsedUrl);\n"
" if ($this->followLocation and ($this->maxRedirects === null or $this->info['redirect_count'] < $this->maxRedirects)) {\n"
" if ($this->info['redirect_count'] === 0) {\n"
" $this->info['starttransfer_time'] = microtime(true) - $timeBegin;\n"
" $redirectBeginTime = microtime(true);\n"
" }\n"
" // force GET\n"
" if (in_array($client->statusCode, [Status::MOVED_PERMANENTLY, Status::FOUND, Status::SEE_OTHER])) {\n"
" $this->method = 'GET';\n"
" }\n"
" if ($this->autoReferer) {\n"
" $this->headers['Referer'] = $this->info['url'];\n"
" }\n"
" $this->setUrl($redirectUrl, false);\n"
" $this->setUrlInfo($redirectParsedUrl);\n"
" $this->info['redirect_count']++;\n"
" } else {\n"
" $this->info['redirect_url'] = $redirectUrl;\n"
" break;\n"
" }\n"
" } elseif ($this->failOnError && $client->statusCode >= 400) {\n"
" $this->setError(CURLE_HTTP_RETURNED_ERROR, \"The requested URL returned error: {$client->statusCode} \" . Status::getReasonPhrase($client->statusCode));\n"
" return false;\n"
" } else {\n"
" break;\n"
" }\n"
" } while (true);\n"
" $this->info['total_time'] = microtime(true) - $timeBegin;\n"
" $this->info['http_code'] = $client->statusCode;\n"
" $this->info['content_type'] = $client->headers['content-type'] ?? '';\n"
" $this->info['size_download'] = $this->info['download_content_length'] = strlen($client->body);\n"
" $this->info['speed_download'] = 1 / $this->info['total_time'] * $this->info['size_download'];\n"
" if (isset($redirectBeginTime)) {\n"
" $this->info['redirect_time'] = microtime(true) - $redirectBeginTime;\n"
" }\n"
"\n"
" $headerContent = '';\n"
" if ($client->headers) {\n"
" $cb = $this->headerFunction;\n"
" if ($client->statusCode > 0) {\n"
" $row = \"HTTP/1.1 {$client->statusCode} \" . Status::getReasonPhrase($client->statusCode) . \"\\r\\n\";\n"
" if ($cb) {\n"
" $cb($this, $row);\n"
" }\n"
" $headerContent .= $row;\n"
" }\n"
" foreach ($client->headers as $k => $v) {\n"
" $row = \"{$k}: {$v}\\r\\n\";\n"
" if ($cb) {\n"
" $cb($this, $row);\n"
" }\n"
" $headerContent .= $row;\n"
" }\n"
" $headerContent .= \"\\r\\n\";\n"
" $this->info['header_size'] = strlen($headerContent);\n"
" if ($cb) {\n"
" $cb($this, '');\n"
" }\n"
" } else {\n"
" $this->info['header_size'] = 0;\n"
" }\n"
"\n"
" if ($client->body and $this->readFunction) {\n"
" $cb = $this->readFunction;\n"
" $cb($this, $this->outputStream, strlen($client->body));\n"
" }\n"
"\n"
" if ($this->withHeader) {\n"
" $transfer = $headerContent . $client->body;\n"
" } else {\n"
" $transfer = $client->body;\n"
" }\n"
"\n"
" if ($this->withHeaderOut) {\n"
" $headerOutContent = $client->getHeaderOut();\n"
" $this->info['request_header'] = $headerOutContent ? $headerOutContent . \"\\r\\n\\r\\n\" : '';\n"
" }\n"
" if ($this->withFileTime) {\n"
" if (isset($client->headers['last-modified'])) {\n"
" $this->info['filetime'] = strtotime($client->headers['last-modified']);\n"
" } else {\n"
" $this->info['filetime'] = -1;\n"
" }\n"
" }\n"
"\n"
" if ($this->returnTransfer) {\n"
" return $this->transfer = $transfer;\n"
" }\n"
" if ($this->outputStream) {\n"
" return fwrite($this->outputStream, $transfer) === strlen($transfer);\n"
" }\n"
" echo $transfer;\n"
"\n"
" return true;\n"
" }\n"
"\n"
" /* ====== Redirect helper ====== */\n"
"\n"
" private static function unparseUrl(array $parsedUrl): string\n"
" {\n"
" $scheme = ($parsedUrl['scheme'] ?? 'http') . '://';\n"
" $host = $parsedUrl['host'] ?? '';\n"
" $port = isset($parsedUrl['port']) ? ':' . $parsedUrl['port'] : '';\n"
" $user = $parsedUrl['user'] ?? '';\n"
" $pass = isset($parsedUrl['pass']) ? ':' . $parsedUrl['pass'] : '';\n"
" $pass = ($user or $pass) ? \"{$pass}@\" : '';\n"
" $path = $parsedUrl['path'] ?? '';\n"
" $query = (isset($parsedUrl['query']) and $parsedUrl['query'] !== '') ? '?' . $parsedUrl['query'] : '';\n"
" $fragment = isset($parsedUrl['fragment']) ? '#' . $parsedUrl['fragment'] : '';\n"
" return $scheme . $user . $pass . $host . $port . $path . $query . $fragment;\n"
" }\n"
"\n"
" private function getRedirectUrl(string $location): array\n"
" {\n"
" $uri = parse_url($location);\n"
" if (isset($uri['host'])) {\n"
" $redirectUri = $uri;\n"
" } else {\n"
" if (!isset($location[0])) {\n"
" return [];\n"
" }\n"
" $redirectUri = $this->urlInfo;\n"
" $redirectUri['query'] = '';\n"
" if ($location[0] === '/') {\n"
" $redirectUri['path'] = $location;\n"
" } else {\n"
" $path = dirname($redirectUri['path'] ?? '');\n"
" if ($path === '.') {\n"
" $path = '/';\n"
" }\n"
" if (isset($location[1]) and substr($location, 0, 2) === './') {\n"
" $location = substr($location, 2);\n"
" }\n"
" $redirectUri['path'] = $path . $location;\n"
" }\n"
" foreach ($uri as $k => $v) {\n"
" if (!in_array($k, ['path', 'query'])) {\n"
" $redirectUri[$k] = $v;\n"
" }\n"
" }\n"
" }\n"
" return $redirectUri;\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole;\n"
"\n"
"/**\n"
" * FastCGI constants.\n"
" */\n"
"class FastCGI\n"
"{\n"
" /**\n"
" * Number of bytes in a FCGI_Header. Future versions of the protocol\n"
" * will not reduce this number.\n"
" */\n"
" public const HEADER_LEN = 8;\n"
"\n"
" /**\n"
" * Format of FCGI_HEADER for unpacking in PHP\n"
" */\n"
" public const HEADER_FORMAT = 'Cversion/Ctype/nrequestId/ncontentLength/CpaddingLength/Creserved';\n"
"\n"
" /**\n"
" * Max content length of a record\n"
" */\n"
" public const MAX_CONTENT_LENGTH = 65535;\n"
"\n"
" /**\n"
" * Value for version component of FCGI_Header\n"
" */\n"
" public const VERSION_1 = 1;\n"
"\n"
" /**\n"
" * Values for type component of FCGI_Header\n"
" */\n"
" public const BEGIN_REQUEST = 1;\n"
"\n"
" public const ABORT_REQUEST = 2;\n"
"\n"
" public const END_REQUEST = 3;\n"
"\n"
" public const PARAMS = 4;\n"
"\n"
" public const STDIN = 5;\n"
"\n"
" public const STDOUT = 6;\n"
"\n"
" public const STDERR = 7;\n"
"\n"
" public const DATA = 8;\n"
"\n"
" public const GET_VALUES = 9;\n"
"\n"
" public const GET_VALUES_RESULT = 10;\n"
"\n"
" public const UNKNOWN_TYPE = 11;\n"
"\n"
" /**\n"
" * Value for requestId component of FCGI_Header\n"
" */\n"
" public const DEFAULT_REQUEST_ID = 1;\n"
"\n"
" /**\n"
" * Mask for flags component of FCGI_BeginRequestBody\n"
" */\n"
" public const KEEP_CONN = 1;\n"
"\n"
" /**\n"
" * Values for role component of FCGI_BeginRequestBody\n"
" */\n"
" public const RESPONDER = 1;\n"
"\n"
" public const AUTHORIZER = 2;\n"
"\n"
" public const FILTER = 3;\n"
"\n"
" /**\n"
" * Values for protocolStatus component of FCGI_EndRequestBody\n"
" */\n"
" public const REQUEST_COMPLETE = 0;\n"
"\n"
" public const CANT_MPX_CONN = 1;\n"
"\n"
" public const OVERLOADED = 2;\n"
"\n"
" public const UNKNOWN_ROLE = 3;\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_record =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI;\n"
"\n"
"use Swoole\\FastCGI;\n"
"\n"
"/**\n"
" * FastCGI record.\n"
" */\n"
"class Record\n"
"{\n"
" /**\n"
" * Identifies the FastCGI protocol version.\n"
" *\n"
" * @var int\n"
" */\n"
" protected $version = FastCGI::VERSION_1;\n"
"\n"
" /**\n"
" * Identifies the FastCGI record type, i.e. the general function that the record performs.\n"
" *\n"
" * @var int\n"
" */\n"
" protected $type = FastCGI::UNKNOWN_TYPE;\n"
"\n"
" /**\n"
" * Identifies the FastCGI request to which the record belongs.\n"
" *\n"
" * @var int\n"
" */\n"
" protected $requestId = FastCGI::DEFAULT_REQUEST_ID;\n"
"\n"
" /**\n"
" * Reserved byte for future proposes\n"
" *\n"
" * @var int\n"
" */\n"
" protected $reserved = 0;\n"
"\n"
" /**\n"
" * The number of bytes in the contentData component of the record.\n"
" *\n"
" * @var int\n"
" */\n"
" private $contentLength = 0;\n"
"\n"
" /**\n"
" * The number of bytes in the paddingData component of the record.\n"
" *\n"
" * @var int\n"
" */\n"
" private $paddingLength = 0;\n"
"\n"
" /**\n"
" * Binary data, between 0 and 65535 bytes of data, interpreted according to the record type.\n"
" *\n"
" * @var string\n"
" */\n"
" private $contentData = '';\n"
"\n"
" /**\n"
" * Padding data, between 0 and 255 bytes of data, which are ignored.\n"
" *\n"
" * @var string\n"
" */\n"
" private $paddingData = '';\n"
"\n"
" /**\n"
" * Returns the binary message representation of record\n"
" */\n"
" final public function __toString(): string\n"
" {\n"
" $headerPacket = pack(\n"
" 'CCnnCC',\n"
" $this->version,\n"
" $this->type,\n"
" $this->requestId,\n"
" $this->contentLength,\n"
" $this->paddingLength,\n"
" $this->reserved\n"
" );\n"
"\n"
" $payloadPacket = $this->packPayload();\n"
" $paddingPacket = pack(\"a{$this->paddingLength}\", $this->paddingData);\n"
"\n"
" return $headerPacket . $payloadPacket . $paddingPacket;\n"
" }\n"
"\n"
" /**\n"
" * Unpacks the message from the binary data buffer\n"
" *\n"
" * @param string $data Binary buffer with raw data\n"
" *\n"
" * @return static\n"
" */\n"
" final public static function unpack(string $data): self\n"
" {\n"
" $self = new static();\n"
" [\n"
" $self->version,\n"
" $self->type,\n"
" $self->requestId,\n"
" $self->contentLength,\n"
" $self->paddingLength,\n"
" $self->reserved\n"
" ] = array_values(unpack(FastCGI::HEADER_FORMAT, $data));\n"
"\n"
" $payload = substr($data, FastCGI::HEADER_LEN);\n"
" self::unpackPayload($self, $payload);\n"
" if (get_called_class() !== __CLASS__ && $self->contentLength > 0) {\n"
" static::unpackPayload($self, $payload);\n"
" }\n"
"\n"
" return $self;\n"
" }\n"
"\n"
" /**\n"
" * Sets the content data and adjusts the length fields\n"
" *\n"
" * @return static\n"
" */\n"
" public function setContentData(string $data): self\n"
" {\n"
" $this->contentLength = strlen($data);\n"
" if ($this->contentLength > FastCGI::MAX_CONTENT_LENGTH) {\n"
" $this->contentLength = FastCGI::MAX_CONTENT_LENGTH;\n"
" $this->contentData = substr($data, 0, FastCGI::MAX_CONTENT_LENGTH);\n"
" } else {\n"
" $this->contentData = $data;\n"
" }\n"
" $extraLength = $this->contentLength % 8;\n"
" $this->paddingLength = $extraLength ? (8 - $extraLength) : 0;\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * Returns the context data from the record\n"
" */\n"
" public function getContentData(): string\n"
" {\n"
" return $this->contentData;\n"
" }\n"
"\n"
" /**\n"
" * Returns the version of record\n"
" */\n"
" public function getVersion(): int\n"
" {\n"
" return $this->version;\n"
" }\n"
"\n"
" /**\n"
" * Returns record type\n"
" */\n"
" public function getType(): int\n"
" {\n"
" return $this->type;\n"
" }\n"
"\n"
" /**\n"
" * Returns request ID\n"
" */\n"
" public function getRequestId(): int\n"
" {\n"
" return $this->requestId;\n"
" }\n"
"\n"
" /**\n"
" * Sets request ID\n"
" *\n"
" * There should be only one unique ID for all active requests,\n"
" * use random number or preferably resetting auto-increment.\n"
" *\n"
" * @return static\n"
" */\n"
" public function setRequestId(int $requestId): self\n"
" {\n"
" $this->requestId = $requestId;\n"
" return $this;\n"
" }\n"
"\n"
" /**\n"
" * Returns the size of content length\n"
" */\n"
" final public function getContentLength(): int\n"
" {\n"
" return $this->contentLength;\n"
" }\n"
"\n"
" /**\n"
" * Returns the size of padding length\n"
" */\n"
" final public function getPaddingLength(): int\n"
" {\n"
" return $this->paddingLength;\n"
" }\n"
"\n"
" /**\n"
" * Method to unpack the payload for the record.\n"
" *\n"
" * NB: Default implementation will be always called\n"
" *\n"
" * @param static $self Instance of current frame\n"
" * @param string $data Binary data\n"
" */\n"
" protected static function unpackPayload($self, string $data): void\n"
" {\n"
" [\n"
" $self->contentData,\n"
" $self->paddingData\n"
" ] = array_values(\n"
" unpack(\"a{$self->contentLength}contentData/a{$self->paddingLength}paddingData\", $data)\n"
" );\n"
" }\n"
"\n"
" /**\n"
" * Implementation of packing the payload\n"
" */\n"
" protected function packPayload(): string\n"
" {\n"
" return pack(\"a{$this->contentLength}\", $this->contentData);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_record_params =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI\\Record;\n"
"\n"
"use Swoole\\FastCGI;\n"
"use Swoole\\FastCGI\\Record;\n"
"\n"
"/**\n"
" * Params request record\n"
" */\n"
"class Params extends Record\n"
"{\n"
" /**\n"
" * List of params\n"
" *\n"
" * @var array\n"
" */\n"
" protected $values = [];\n"
"\n"
" /**\n"
" * Constructs a param request\n"
" */\n"
" public function __construct(array $values = [])\n"
" {\n"
" $this->type = FastCGI::PARAMS;\n"
" $this->values = $values;\n"
" $this->setContentData($this->packPayload());\n"
" }\n"
"\n"
" /**\n"
" * Returns an associative list of parameters\n"
" */\n"
" public function getValues(): array\n"
" {\n"
" return $this->values;\n"
" }\n"
"\n"
" /**\n"
" * {@inheritdoc}\n"
" * @param static $self\n"
" */\n"
" protected static function unpackPayload($self, string $data): void\n"
" {\n"
" $currentOffset = 0;\n"
" do {\n"
" [$nameLengthHigh] = array_values(unpack('CnameLengthHigh', $data));\n"
" $isLongName = ($nameLengthHigh >> 7 == 1);\n"
" $valueOffset = $isLongName ? 4 : 1;\n"
"\n"
" [$valueLengthHigh] = array_values(unpack('CvalueLengthHigh', substr($data, $valueOffset)));\n"
" $isLongValue = ($valueLengthHigh >> 7 == 1);\n"
" $dataOffset = $valueOffset + ($isLongValue ? 4 : 1);\n"
"\n"
" $formatParts = [\n"
" $isLongName ? 'NnameLength' : 'CnameLength',\n"
" $isLongValue ? 'NvalueLength' : 'CvalueLength',\n"
" ];\n"
" $format = join('/', $formatParts);\n"
" [$nameLength, $valueLength] = array_values(unpack($format, $data));\n"
"\n"
" // Clear top bit for long record\n"
" $nameLength &= ($isLongName ? 0x7fffffff : 0x7f);\n"
" $valueLength &= ($isLongValue ? 0x7fffffff : 0x7f);\n"
"\n"
" [$nameData, $valueData] = array_values(\n"
" unpack(\n"
" \"a{$nameLength}nameData/a{$valueLength}valueData\",\n"
" substr($data, $dataOffset)\n"
" )\n"
" );\n"
"\n"
" $self->values[$nameData] = $valueData;\n"
"\n"
" $keyValueLength = $dataOffset + $nameLength + $valueLength;\n"
" $data = substr($data, $keyValueLength);\n"
" $currentOffset += $keyValueLength;\n"
" } while ($currentOffset < $self->getContentLength());\n"
" }\n"
"\n"
" /** {@inheritdoc} */\n"
" protected function packPayload(): string\n"
" {\n"
" $payload = '';\n"
" foreach ($this->values as $nameData => $valueData) {\n"
" if ($valueData === null) {\n"
" continue;\n"
" }\n"
" $nameLength = strlen($nameData);\n"
" $valueLength = strlen((string) $valueData);\n"
" $isLongName = $nameLength > 127;\n"
" $isLongValue = $valueLength > 127;\n"
" $formatParts = [\n"
" $isLongName ? 'N' : 'C',\n"
" $isLongValue ? 'N' : 'C',\n"
" \"a{$nameLength}\",\n"
" \"a{$valueLength}\",\n"
" ];\n"
" $format = join('', $formatParts);\n"
"\n"
" $payload .= pack(\n"
" $format,\n"
" $isLongName ? ($nameLength | 0x80000000) : $nameLength,\n"
" $isLongValue ? ($valueLength | 0x80000000) : $valueLength,\n"
" $nameData,\n"
" $valueData\n"
" );\n"
" }\n"
"\n"
" return $payload;\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_record_abort_request =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI\\Record;\n"
"\n"
"use Swoole\\FastCGI;\n"
"use Swoole\\FastCGI\\Record;\n"
"\n"
"/**\n"
" * The Web server sends a FCGI_ABORT_REQUEST record to abort a request\n"
" */\n"
"class AbortRequest extends Record\n"
"{\n"
" public function __construct(int $requestId = 0)\n"
" {\n"
" $this->type = FastCGI::ABORT_REQUEST;\n"
" $this->setRequestId($requestId);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_record_begin_request =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI\\Record;\n"
"\n"
"use Swoole\\FastCGI;\n"
"use Swoole\\FastCGI\\Record;\n"
"\n"
"/**\n"
" * The Web server sends a FCGI_BEGIN_REQUEST record to start a request.\n"
" */\n"
"class BeginRequest extends Record\n"
"{\n"
" /**\n"
" * The role component sets the role the Web server expects the application to play.\n"
" * The currently-defined roles are:\n"
" * FCGI_RESPONDER\n"
" * FCGI_AUTHORIZER\n"
" * FCGI_FILTER\n"
" *\n"
" * @var int\n"
" */\n"
" protected $role = FastCGI::UNKNOWN_ROLE;\n"
"\n"
" /**\n"
" * The flags component contains a bit that controls connection shutdown.\n"
" *\n"
" * flags & FCGI_KEEP_CONN:\n"
" * If zero, the application closes the connection after responding to this request.\n"
" * If not zero, the application does not close the connection after responding to this request;\n"
" * the Web server retains responsibility for the connection.\n"
" *\n"
" * @var int\n"
" */\n"
" protected $flags;\n"
"\n"
" /**\n"
" * Reserved data, 5 bytes maximum\n"
" *\n"
" * @var string\n"
" */\n"
" protected $reserved1;\n"
"\n"
" public function __construct(int $role = FastCGI::UNKNOWN_ROLE, int $flags = 0, string $reserved = '')\n"
" {\n"
" $this->type = FastCGI::BEGIN_REQUEST;\n"
" $this->role = $role;\n"
" $this->flags = $flags;\n"
" $this->reserved1 = $reserved;\n"
" $this->setContentData($this->packPayload());\n"
" }\n"
"\n"
" /**\n"
" * Returns the role\n"
" *\n"
" * The role component sets the role the Web server expects the application to play.\n"
" * The currently-defined roles are:\n"
" * FCGI_RESPONDER\n"
" * FCGI_AUTHORIZER\n"
" * FCGI_FILTER\n"
" */\n"
" public function getRole(): int\n"
" {\n"
" return $this->role;\n"
" }\n"
"\n"
" /**\n"
" * Returns the flags\n"
" *\n"
" * The flags component contains a bit that controls connection shutdown.\n"
" *\n"
" * flags & FCGI_KEEP_CONN:\n"
" * If zero, the application closes the connection after responding to this request.\n"
" * If not zero, the application does not close the connection after responding to this request;\n"
" * the Web server retains responsibility for the connection.\n"
" */\n"
" public function getFlags(): int\n"
" {\n"
" return $this->flags;\n"
" }\n"
"\n"
" /**\n"
" * {@inheritdoc}\n"
" * @param static $self\n"
" */\n"
" protected static function unpackPayload($self, string $data): void\n"
" {\n"
" [\n"
" $self->role,\n"
" $self->flags,\n"
" $self->reserved1\n"
" ] = array_values(unpack('nrole/Cflags/a5reserved', $data));\n"
" }\n"
"\n"
" /** {@inheritdoc} */\n"
" protected function packPayload(): string\n"
" {\n"
" return pack(\n"
" 'nCa5',\n"
" $this->role,\n"
" $this->flags,\n"
" $this->reserved1\n"
" );\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_record_data =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI\\Record;\n"
"\n"
"use Swoole\\FastCGI;\n"
"use Swoole\\FastCGI\\Record;\n"
"\n"
"/**\n"
" * Data binary stream\n"
" *\n"
" * FCGI_DATA is a second stream record type used to send additional data to the application.\n"
" */\n"
"class Data extends Record\n"
"{\n"
" public function __construct(string $contentData = '')\n"
" {\n"
" $this->type = FastCGI::DATA;\n"
" $this->setContentData($contentData);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_record_end_request =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI\\Record;\n"
"\n"
"use Swoole\\FastCGI;\n"
"use Swoole\\FastCGI\\Record;\n"
"\n"
"/**\n"
" * The application sends a FCGI_END_REQUEST record to terminate a request, either because the application\n"
" * has processed the request or because the application has rejected the request.\n"
" */\n"
"class EndRequest extends Record\n"
"{\n"
" /**\n"
" * The appStatus component is an application-level status code. Each role documents its usage of appStatus.\n"
" *\n"
" * @var int\n"
" */\n"
" protected $appStatus = 0;\n"
"\n"
" /**\n"
" * The protocolStatus component is a protocol-level status code.\n"
" *\n"
" * The possible protocolStatus values are:\n"
" * FCGI_REQUEST_COMPLETE: normal end of request.\n"
" * FCGI_CANT_MPX_CONN: rejecting a new request.\n"
" * This happens when a Web server sends concurrent requests over one connection to an application that is\n"
" * designed to process one request at a time per connection.\n"
" * FCGI_OVERLOADED: rejecting a new request.\n"
" * This happens when the application runs out of some resource, e.g. database connections.\n"
" * FCGI_UNKNOWN_ROLE: rejecting a new request.\n"
" * This happens when the Web server has specified a role that is unknown to the application.\n"
" *\n"
" * @var int\n"
" */\n"
" protected $protocolStatus = FastCGI::REQUEST_COMPLETE;\n"
"\n"
" /**\n"
" * Reserved data, 3 bytes maximum\n"
" *\n"
" * @var string\n"
" */\n"
" protected $reserved1;\n"
"\n"
" public function __construct(\n"
" int $protocolStatus = FastCGI::REQUEST_COMPLETE,\n"
" int $appStatus = 0,\n"
" string $reserved = ''\n"
" ) {\n"
" $this->type = FastCGI::END_REQUEST;\n"
" $this->protocolStatus = $protocolStatus;\n"
" $this->appStatus = $appStatus;\n"
" $this->reserved1 = $reserved;\n"
" $this->setContentData($this->packPayload());\n"
" }\n"
"\n"
" /**\n"
" * Returns app status\n"
" *\n"
" * The appStatus component is an application-level status code. Each role documents its usage of appStatus.\n"
" */\n"
" public function getAppStatus(): int\n"
" {\n"
" return $this->appStatus;\n"
" }\n"
"\n"
" /**\n"
" * Returns the protocol status\n"
" *\n"
" * The possible protocolStatus values are:\n"
" * FCGI_REQUEST_COMPLETE: normal end of request.\n"
" * FCGI_CANT_MPX_CONN: rejecting a new request.\n"
" * This happens when a Web server sends concurrent requests over one connection to an application that is\n"
" * designed to process one request at a time per connection.\n"
" * FCGI_OVERLOADED: rejecting a new request.\n"
" * This happens when the application runs out of some resource, e.g. database connections.\n"
" * FCGI_UNKNOWN_ROLE: rejecting a new request.\n"
" * This happens when the Web server has specified a role that is unknown to the application.\n"
" */\n"
" public function getProtocolStatus(): int\n"
" {\n"
" return $this->protocolStatus;\n"
" }\n"
"\n"
" /**\n"
" * {@inheritdoc}\n"
" * @param static $self\n"
" */\n"
" protected static function unpackPayload($self, string $data): void\n"
" {\n"
" [\n"
" $self->appStatus,\n"
" $self->protocolStatus,\n"
" $self->reserved1\n"
" ] = array_values(unpack('NappStatus/CprotocolStatus/a3reserved', $data));\n"
" }\n"
"\n"
" /** {@inheritdoc} */\n"
" protected function packPayload(): string\n"
" {\n"
" return pack(\n"
" 'NCa3',\n"
" $this->appStatus,\n"
" $this->protocolStatus,\n"
" $this->reserved1\n"
" );\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_record_get_values =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI\\Record;\n"
"\n"
"use Swoole\\FastCGI;\n"
"\n"
"/**\n"
" * GetValues API\n"
" *\n"
" * The Web server can query specific variables within the application.\n"
" * The server will typically perform a query on application startup in order to to automate certain aspects of\n"
" * system configuration.\n"
" *\n"
" * The application responds by sending a record {FCGI_GET_VALUES_RESULT, 0, ...} with the values supplied.\n"
" * If the application doesn't understand a variable name that was included in the query, it omits that name from\n"
" * the response.\n"
" *\n"
" * FCGI_GET_VALUES is designed to allow an open-ended set of variables.\n"
" *\n"
" * The initial set provides information to help the server perform application and connection management:\n"
" * FCGI_MAX_CONNS: The maximum number of concurrent transport connections this application will accept,\n"
" * e.g. \"1\" or \"10\".\n"
" * FCGI_MAX_REQS: The maximum number of concurrent requests this application will accept, e.g. \"1\" or \"50\".\n"
" * FCGI_MPXS_CONNS: \"0\" if this application does not multiplex connections (i.e. handle concurrent requests\n"
" * over each connection), \"1\" otherwise.\n"
" */\n"
"class GetValues extends Params\n"
"{\n"
" /**\n"
" * Constructs a request\n"
" *\n"
" * @param array $keys List of keys to receive\n"
" */\n"
" public function __construct(array $keys = [])\n"
" {\n"
" parent::__construct(array_fill_keys($keys, ''));\n"
" $this->type = FastCGI::GET_VALUES;\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_record_get_values_result =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI\\Record;\n"
"\n"
"use Swoole\\FastCGI;\n"
"\n"
"/**\n"
" * GetValues API\n"
" *\n"
" * The Web server can query specific variables within the application.\n"
" * The server will typically perform a query on application startup in order to to automate certain aspects of\n"
" * system configuration.\n"
" *\n"
" * The application responds by sending a record {FCGI_GET_VALUES_RESULT, 0, ...} with the values supplied.\n"
" * If the application doesn't understand a variable name that was included in the query, it omits that name from\n"
" * the response.\n"
" *\n"
" * FCGI_GET_VALUES is designed to allow an open-ended set of variables.\n"
" *\n"
" * The initial set provides information to help the server perform application and connection management:\n"
" * FCGI_MAX_CONNS: The maximum number of concurrent transport connections this application will accept,\n"
" * e.g. \"1\" or \"10\".\n"
" * FCGI_MAX_REQS: The maximum number of concurrent requests this application will accept, e.g. \"1\" or \"50\".\n"
" * FCGI_MPXS_CONNS: \"0\" if this application does not multiplex connections (i.e. handle concurrent requests\n"
" * over each connection), \"1\" otherwise.\n"
" */\n"
"class GetValuesResult extends Params\n"
"{\n"
" /**\n"
" * Constructs a param request\n"
" */\n"
" public function __construct(array $values = [])\n"
" {\n"
" parent::__construct($values);\n"
" $this->type = FastCGI::GET_VALUES_RESULT;\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_record_stdin =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI\\Record;\n"
"\n"
"use Swoole\\FastCGI;\n"
"use Swoole\\FastCGI\\Record;\n"
"\n"
"/**\n"
" * Stdin binary stream\n"
" *\n"
" * FCGI_STDIN is a stream record type used in sending arbitrary data from the Web server to the application\n"
" */\n"
"class Stdin extends Record\n"
"{\n"
" public function __construct(string $contentData = '')\n"
" {\n"
" $this->type = FastCGI::STDIN;\n"
" $this->setContentData($contentData);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_record_stdout =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI\\Record;\n"
"\n"
"use Swoole\\FastCGI;\n"
"use Swoole\\FastCGI\\Record;\n"
"\n"
"/**\n"
" * Stdout binary stream\n"
" *\n"
" * FCGI_STDOUT is a stream record for sending arbitrary data from the application to the Web server\n"
" */\n"
"class Stdout extends Record\n"
"{\n"
" public function __construct(string $contentData = '')\n"
" {\n"
" $this->type = FastCGI::STDOUT;\n"
" $this->setContentData($contentData);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_record_stderr =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI\\Record;\n"
"\n"
"use Swoole\\FastCGI;\n"
"use Swoole\\FastCGI\\Record;\n"
"\n"
"/**\n"
" * Stderr binary stream\n"
" *\n"
" * FCGI_STDERR is a stream record for sending arbitrary data from the application to the Web server\n"
" */\n"
"class Stderr extends Record\n"
"{\n"
" public function __construct(string $contentData = '')\n"
" {\n"
" $this->type = FastCGI::STDERR;\n"
" $this->setContentData($contentData);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_record_unknown_type =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI\\Record;\n"
"\n"
"use Swoole\\FastCGI;\n"
"use Swoole\\FastCGI\\Record;\n"
"\n"
"/**\n"
" * Record for unknown queries\n"
" *\n"
" * The set of management record types is likely to grow in future versions of this protocol.\n"
" * To provide for this evolution, the protocol includes the FCGI_UNKNOWN_TYPE management record.\n"
" * When an application receives a management record whose type T it does not understand, the application responds\n"
" * with {FCGI_UNKNOWN_TYPE, 0, {T}}.\n"
" */\n"
"class UnknownType extends Record\n"
"{\n"
" /**\n"
" * Type of the unrecognized management record.\n"
" *\n"
" * @var int\n"
" */\n"
" protected $type1;\n"
"\n"
" /**\n"
" * Reserved data, 7 bytes maximum\n"
" *\n"
" * @var string\n"
" */\n"
" protected $reserved1;\n"
"\n"
" public function __construct(int $type = 0, string $reserved = '')\n"
" {\n"
" $this->type = FastCGI::UNKNOWN_TYPE;\n"
" $this->type1 = $type;\n"
" $this->reserved1 = $reserved;\n"
" $this->setContentData($this->packPayload());\n"
" }\n"
"\n"
" /**\n"
" * Returns the unrecognized type\n"
" */\n"
" public function getUnrecognizedType(): int\n"
" {\n"
" return $this->type1;\n"
" }\n"
"\n"
" /**\n"
" * {@inheritdoc}\n"
" * @param static $self\n"
" */\n"
" public static function unpackPayload($self, string $data): void\n"
" {\n"
" [$self->type1, $self->reserved1] = array_values(unpack('Ctype/a7reserved', $data));\n"
" }\n"
"\n"
" /** {@inheritdoc} */\n"
" protected function packPayload(): string\n"
" {\n"
" return pack(\n"
" 'Ca7',\n"
" $this->type1,\n"
" $this->reserved1\n"
" );\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_frame_parser =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI;\n"
"\n"
"use DomainException;\n"
"use RuntimeException;\n"
"use Swoole\\FastCGI;\n"
"\n"
"/**\n"
" * Utility class to simplify parsing of FastCGI protocol data.\n"
" */\n"
"class FrameParser\n"
"{\n"
" /**\n"
" * Mapping of constants to the classes\n"
" *\n"
" * @var array\n"
" */\n"
" protected static $classMapping = [\n"
" FastCGI::BEGIN_REQUEST => FastCGI\\Record\\BeginRequest::class,\n"
" FastCGI::ABORT_REQUEST => FastCGI\\Record\\AbortRequest::class,\n"
" FastCGI::END_REQUEST => FastCGI\\Record\\EndRequest::class,\n"
" FastCGI::PARAMS => FastCGI\\Record\\Params::class,\n"
" FastCGI::STDIN => FastCGI\\Record\\Stdin::class,\n"
" FastCGI::STDOUT => FastCGI\\Record\\Stdout::class,\n"
" FastCGI::STDERR => FastCGI\\Record\\Stderr::class,\n"
" FastCGI::DATA => FastCGI\\Record\\Data::class,\n"
" FastCGI::GET_VALUES => FastCGI\\Record\\GetValues::class,\n"
" FastCGI::GET_VALUES_RESULT => FastCGI\\Record\\GetValuesResult::class,\n"
" FastCGI::UNKNOWN_TYPE => FastCGI\\Record\\UnknownType::class,\n"
" ];\n"
"\n"
" /**\n"
" * Checks if the buffer contains a valid frame to parse\n"
" *\n"
" * @param string $buffer Binary buffer\n"
" */\n"
" public static function hasFrame(string $buffer): bool\n"
" {\n"
" $bufferLength = strlen($buffer);\n"
" if ($bufferLength < FastCGI::HEADER_LEN) {\n"
" return false;\n"
" }\n"
"\n"
" $fastInfo = unpack(FastCGI::HEADER_FORMAT, $buffer);\n"
" if ($bufferLength < FastCGI::HEADER_LEN + $fastInfo['contentLength'] + $fastInfo['paddingLength']) {\n"
" return false;\n"
" }\n"
"\n"
" return true;\n"
" }\n"
"\n"
" /**\n"
" * Parses a frame from the binary buffer\n"
" *\n"
" * @param string $buffer Binary buffer\n"
" *\n"
" * @return Record One of the corresponding FastCGI record\n"
" */\n"
" public static function parseFrame(string &$buffer): Record\n"
" {\n"
" $bufferLength = strlen($buffer);\n"
" if ($bufferLength < FastCGI::HEADER_LEN) {\n"
" throw new RuntimeException('Not enough data in the buffer to parse');\n"
" }\n"
" $recordHeader = unpack(FastCGI::HEADER_FORMAT, $buffer);\n"
" $recordType = $recordHeader['type'];\n"
" if (!isset(self::$classMapping[$recordType])) {\n"
" throw new DomainException(\"Invalid FastCGI record type {$recordType} received\");\n"
" }\n"
"\n"
" /** @var Record $className */\n"
" $className = self::$classMapping[$recordType];\n"
" $record = $className::unpack($buffer);\n"
"\n"
" $offset = FastCGI::HEADER_LEN + $record->getContentLength() + $record->getPaddingLength();\n"
" $buffer = substr($buffer, $offset);\n"
"\n"
" return $record;\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_message =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI;\n"
"\n"
"class Message\n"
"{\n"
" /** @var array */\n"
" protected $params = [];\n"
"\n"
" /** @var string */\n"
" protected $body = '';\n"
"\n"
" /** @var string */\n"
" protected $error = '';\n"
"\n"
" public function getParam(string $name): ?string\n"
" {\n"
" return $this->params[$name] ?? null;\n"
" }\n"
"\n"
" public function withParam(string $name, string $value): self\n"
" {\n"
" $this->params[$name] = $value;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutParam(string $name): self\n"
" {\n"
" unset($this->params[$name]);\n"
" return $this;\n"
" }\n"
"\n"
" public function getParams(): array\n"
" {\n"
" return $this->params;\n"
" }\n"
"\n"
" public function withParams(array $params): self\n"
" {\n"
" $this->params = $params;\n"
" return $this;\n"
" }\n"
"\n"
" public function withAddedParams(array $params): self\n"
" {\n"
" $this->params = $params + $this->params;\n"
" return $this;\n"
" }\n"
"\n"
" public function getBody(): string\n"
" {\n"
" return $this->body;\n"
" }\n"
"\n"
" public function withBody($body): self\n"
" {\n"
" $this->body = (string) $body;\n"
" return $this;\n"
" }\n"
"\n"
" public function getError(): string\n"
" {\n"
" return $this->error;\n"
" }\n"
"\n"
" public function withError(string $error): self\n"
" {\n"
" $this->error = $error;\n"
" return $this;\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_request =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI;\n"
"\n"
"use Swoole\\FastCGI;\n"
"use Swoole\\FastCGI\\Record\\BeginRequest;\n"
"use Swoole\\FastCGI\\Record\\Params;\n"
"use Swoole\\FastCGI\\Record\\Stdin;\n"
"\n"
"class Request extends Message\n"
"{\n"
" protected $keepConn = false;\n"
"\n"
" public function __toString(): string\n"
" {\n"
" $body = $this->getBody();\n"
" $beginRequestFrame = new BeginRequest(FastCGI::RESPONDER, ($this->keepConn ? FastCGI::KEEP_CONN : 0));\n"
" $paramsFrame = new Params($this->getParams());\n"
" $paramsEofFrame = new Params();\n"
" if (empty($body)) {\n"
" $message = \"{$beginRequestFrame}{$paramsFrame}{$paramsEofFrame}}\";\n"
" } else {\n"
" $stdinList = [];\n"
" while (true) {\n"
" $stdinList[] = $stdin = new Stdin($body);\n"
" $stdinLength = $stdin->getContentLength();\n"
" if ($stdinLength === strlen($body)) {\n"
" break;\n"
" }\n"
" $body = substr($body, $stdinLength);\n"
" }\n"
" $stdinList[] = new Stdin();\n"
" $stdin = implode($stdinList);\n"
" $message = \"{$beginRequestFrame}{$paramsFrame}{$paramsEofFrame}{$stdin}}\";\n"
" }\n"
" return $message;\n"
" }\n"
"\n"
" public function getKeepConn(): bool\n"
" {\n"
" return $this->keepConn;\n"
" }\n"
"\n"
" public function withKeepConn(bool $keepConn): self\n"
" {\n"
" $this->keepConn = $keepConn;\n"
" return $this;\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_response =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI;\n"
"\n"
"use InvalidArgumentException;\n"
"use Swoole\\FastCGI\\Record\\EndRequest;\n"
"use Swoole\\FastCGI\\Record\\Stderr;\n"
"use Swoole\\FastCGI\\Record\\Stdout;\n"
"\n"
"class Response extends Message\n"
"{\n"
" public function __construct(array $records = [])\n"
" {\n"
" if (!static::verify($records)) {\n"
" throw new InvalidArgumentException('Bad records');\n"
" }\n"
" $body = '';\n"
" $error = '';\n"
" foreach ($records as $record) {\n"
" if ($record instanceof Stdout) {\n"
" if ($record->getContentLength() > 0) {\n"
" $body .= $record->getContentData();\n"
" }\n"
" } elseif ($record instanceof Stderr) {\n"
" if ($record->getContentLength() > 0) {\n"
" $error .= $record->getContentData();\n"
" }\n"
" }\n"
" }\n"
" $this->withBody($body)->withError($error);\n"
" }\n"
"\n"
" public static function verify(array $records): bool\n"
" {\n"
" return !empty($records) && $records[count($records) - 1] instanceof EndRequest;\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_http_request =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI;\n"
"\n"
"use InvalidArgumentException;\n"
"\n"
"class HttpRequest extends Request\n"
"{\n"
" protected $params = [\n"
" 'REQUEST_SCHEME' => 'http',\n"
" 'REQUEST_METHOD' => 'GET',\n"
" 'DOCUMENT_ROOT' => '',\n"
" 'SCRIPT_FILENAME' => '',\n"
" 'SCRIPT_NAME' => '',\n"
" 'DOCUMENT_URI' => '/',\n"
" 'REQUEST_URI' => '/',\n"
" 'QUERY_STRING' => '',\n"
" 'CONTENT_TYPE' => 'text/plain',\n"
" 'CONTENT_LENGTH' => '0',\n"
" 'GATEWAY_INTERFACE' => 'CGI/1.1',\n"
" 'SERVER_PROTOCOL' => 'HTTP/1.1',\n"
" 'SERVER_SOFTWARE' => 'swoole/' . SWOOLE_VERSION,\n"
" 'REMOTE_ADDR' => 'unknown',\n"
" 'REMOTE_PORT' => '0',\n"
" 'SERVER_ADDR' => 'unknown',\n"
" 'SERVER_PORT' => '0',\n"
" 'SERVER_NAME' => 'Swoole',\n"
" 'REDIRECT_STATUS' => '200',\n"
" ];\n"
"\n"
" public function getScheme(): ?string\n"
" {\n"
" return $this->params['REQUEST_SCHEME'] ?? null;\n"
" }\n"
"\n"
" public function withScheme(string $scheme): self\n"
" {\n"
" $this->params['REQUEST_SCHEME'] = $scheme;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutScheme(): void\n"
" {\n"
" unset($this->params['REQUEST_SCHEME']);\n"
" }\n"
"\n"
" public function getMethod(): ?string\n"
" {\n"
" return $this->params['REQUEST_METHOD'] ?? null;\n"
" }\n"
"\n"
" public function withMethod(string $method): self\n"
" {\n"
" $this->params['REQUEST_METHOD'] = $method;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutMethod(): void\n"
" {\n"
" unset($this->params['REQUEST_METHOD']);\n"
" }\n"
"\n"
" public function getDocumentRoot(): ?string\n"
" {\n"
" return $this->params['DOCUMENT_ROOT'] ?? null;\n"
" }\n"
"\n"
" public function withDocumentRoot(string $documentRoot): self\n"
" {\n"
" $this->params['DOCUMENT_ROOT'] = $documentRoot;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutDocumentRoot(): void\n"
" {\n"
" unset($this->params['DOCUMENT_ROOT']);\n"
" }\n"
"\n"
" public function getScriptFilename(): ?string\n"
" {\n"
" return $this->params['SCRIPT_FILENAME'] ?? null;\n"
" }\n"
"\n"
" public function withScriptFilename(string $scriptFilename): self\n"
" {\n"
" $this->params['SCRIPT_FILENAME'] = $scriptFilename;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutScriptFilename(): void\n"
" {\n"
" unset($this->params['SCRIPT_FILENAME']);\n"
" }\n"
"\n"
" public function getScriptName(): ?string\n"
" {\n"
" return $this->params['SCRIPT_NAME'] ?? null;\n"
" }\n"
"\n"
" public function withScriptName(string $scriptName): self\n"
" {\n"
" $this->params['SCRIPT_NAME'] = $scriptName;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutScriptName(): void\n"
" {\n"
" unset($this->params['SCRIPT_NAME']);\n"
" }\n"
"\n"
" public function withUri(string $uri): self\n"
" {\n"
" $info = parse_url($uri);\n"
" return $this->withRequestUri($uri)\n"
" ->withDocumentUri($info['path'] ?? '')\n"
" ->withQueryString($info['query'] ?? '');\n"
" }\n"
"\n"
" public function getDocumentUri(): ?string\n"
" {\n"
" return $this->params['DOCUMENT_URI'] ?? null;\n"
" }\n"
"\n"
" public function withDocumentUri(string $documentUri): self\n"
" {\n"
" $this->params['DOCUMENT_URI'] = $documentUri;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutDocumentUri(): void\n"
" {\n"
" unset($this->params['DOCUMENT_URI']);\n"
" }\n"
"\n"
" public function getRequestUri(): ?string\n"
" {\n"
" return $this->params['REQUEST_URI'] ?? null;\n"
" }\n"
"\n"
" public function withRequestUri(string $requestUri): self\n"
" {\n"
" $this->params['REQUEST_URI'] = $requestUri;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutRequestUri(): void\n"
" {\n"
" unset($this->params['REQUEST_URI']);\n"
" }\n"
"\n"
" public function withQuery($query): self\n"
" {\n"
" if (is_array($query)) {\n"
" $query = http_build_query($query);\n"
" }\n"
" return $this->withQueryString($query);\n"
" }\n"
"\n"
" public function getQueryString(): ?string\n"
" {\n"
" return $this->params['QUERY_STRING'] ?? null;\n"
" }\n"
"\n"
" public function withQueryString(string $queryString): self\n"
" {\n"
" $this->params['QUERY_STRING'] = $queryString;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutQueryString(): void\n"
" {\n"
" unset($this->params['QUERY_STRING']);\n"
" }\n"
"\n"
" public function getContentType(): ?string\n"
" {\n"
" return $this->params['CONTENT_TYPE'] ?? null;\n"
" }\n"
"\n"
" public function withContentType(string $contentType): self\n"
" {\n"
" $this->params['CONTENT_TYPE'] = $contentType;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutContentType(): void\n"
" {\n"
" unset($this->params['CONTENT_TYPE']);\n"
" }\n"
"\n"
" public function getContentLength(): ?int\n"
" {\n"
" return isset($this->params['CONTENT_LENGTH']) ? (int) $this->params['CONTENT_LENGTH'] : null;\n"
" }\n"
"\n"
" public function withContentLength(int $contentLength): self\n"
" {\n"
" $this->params['CONTENT_LENGTH'] = (string) $contentLength;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutContentLength(): void\n"
" {\n"
" unset($this->params['CONTENT_LENGTH']);\n"
" }\n"
"\n"
" public function getGatewayInterface(): ?string\n"
" {\n"
" return $this->params['GATEWAY_INTERFACE'] ?? null;\n"
" }\n"
"\n"
" public function withGatewayInterface(string $gatewayInterface): self\n"
" {\n"
" $this->params['GATEWAY_INTERFACE'] = $gatewayInterface;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutGatewayInterface(): void\n"
" {\n"
" unset($this->params['GATEWAY_INTERFACE']);\n"
" }\n"
"\n"
" public function getServerProtocol(): ?string\n"
" {\n"
" return $this->params['SERVER_PROTOCOL'] ?? null;\n"
" }\n"
"\n"
" public function withServerProtocol(string $serverProtocol): self\n"
" {\n"
" $this->params['SERVER_PROTOCOL'] = $serverProtocol;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutServerProtocol(): void\n"
" {\n"
" unset($this->params['SERVER_PROTOCOL']);\n"
" }\n"
"\n"
" public function withProtocolVersion(string $protocolVersion): self\n"
" {\n"
" if (!is_numeric($protocolVersion)) {\n"
" throw new InvalidArgumentException('Protocol version must be numeric');\n"
" }\n"
" $this->params['SERVER_PROTOCOL'] = \"HTTP/{$protocolVersion}\";\n"
" return $this;\n"
" }\n"
"\n"
" public function getServerSoftware(): ?string\n"
" {\n"
" return $this->params['SERVER_SOFTWARE'] ?? null;\n"
" }\n"
"\n"
" public function withServerSoftware(string $serverSoftware): self\n"
" {\n"
" $this->params['SERVER_SOFTWARE'] = $serverSoftware;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutServerSoftware(): void\n"
" {\n"
" unset($this->params['SERVER_SOFTWARE']);\n"
" }\n"
"\n"
" public function getRemoteAddr(): ?string\n"
" {\n"
" return $this->params['REMOTE_ADDR'] ?? null;\n"
" }\n"
"\n"
" public function withRemoteAddr(string $remoteAddr): self\n"
" {\n"
" $this->params['REMOTE_ADDR'] = $remoteAddr;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutRemoteAddr(): void\n"
" {\n"
" unset($this->params['REMOTE_ADDR']);\n"
" }\n"
"\n"
" public function getRemotePort(): ?int\n"
" {\n"
" return isset($this->params['REMOTE_PORT']) ? (int) $this->params['REMOTE_PORT'] : null;\n"
" }\n"
"\n"
" public function withRemotePort(int $remotePort): self\n"
" {\n"
" $this->params['REMOTE_PORT'] = (string) $remotePort;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutRemotePort(): void\n"
" {\n"
" unset($this->params['REMOTE_PORT']);\n"
" }\n"
"\n"
" public function getServerAddr(): ?string\n"
" {\n"
" return $this->params['SERVER_ADDR'] ?? null;\n"
" }\n"
"\n"
" public function withServerAddr(string $serverAddr): self\n"
" {\n"
" $this->params['SERVER_ADDR'] = $serverAddr;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutServerAddr(): void\n"
" {\n"
" unset($this->params['SERVER_ADDR']);\n"
" }\n"
"\n"
" public function getServerPort(): ?int\n"
" {\n"
" return isset($this->params['SERVER_PORT']) ? (int) $this->params['SERVER_PORT'] : null;\n"
" }\n"
"\n"
" public function withServerPort(int $serverPort): self\n"
" {\n"
" $this->params['SERVER_PORT'] = (string) $serverPort;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutServerPort(): void\n"
" {\n"
" unset($this->params['SERVER_PORT']);\n"
" }\n"
"\n"
" public function getServerName(): ?string\n"
" {\n"
" return $this->params['SERVER_NAME'] ?? null;\n"
" }\n"
"\n"
" public function withServerName(string $serverName): self\n"
" {\n"
" $this->params['SERVER_NAME'] = $serverName;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutServerName(): void\n"
" {\n"
" unset($this->params['SERVER_NAME']);\n"
" }\n"
"\n"
" public function getRedirectStatus(): ?string\n"
" {\n"
" return $this->params['REDIRECT_STATUS'] ?? null;\n"
" }\n"
"\n"
" public function withRedirectStatus(string $redirectStatus): self\n"
" {\n"
" $this->params['REDIRECT_STATUS'] = $redirectStatus;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutRedirectStatus(): void\n"
" {\n"
" unset($this->params['REDIRECT_STATUS']);\n"
" }\n"
"\n"
" public function getHeader(string $name): ?string\n"
" {\n"
" return $this->params[static::convertHeaderNameToParamName($name)] ?? null;\n"
" }\n"
"\n"
" public function withHeader(string $name, string $value): self\n"
" {\n"
" $this->params[static::convertHeaderNameToParamName($name)] = $value;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutHeader(string $name): void\n"
" {\n"
" unset($this->params[static::convertHeaderNameToParamName($name)]);\n"
" }\n"
"\n"
" public function getHeaders(): array\n"
" {\n"
" $headers = [];\n"
" foreach ($this->params as $name => $value) {\n"
" if (strpos($name, 'HTTP_') === 0) {\n"
" $headers[static::convertParamNameToHeaderName($name)] = $value;\n"
" }\n"
" }\n"
" return $headers;\n"
" }\n"
"\n"
" public function withHeaders(array $headers): self\n"
" {\n"
" foreach ($headers as $name => $value) {\n"
" $this->withHeader($name, $value);\n"
" }\n"
" return $this;\n"
" }\n"
"\n"
" /** @return $this */\n"
" public function withBody($body): Message\n"
" {\n"
" if (is_array($body)) {\n"
" $body = http_build_query($body);\n"
" $this->withContentType('application/x-www-form-urlencoded');\n"
" }\n"
" parent::withBody($body);\n"
" return $this->withContentLength(strlen($body));\n"
" }\n"
"\n"
" protected static function convertHeaderNameToParamName(string $name)\n"
" {\n"
" return 'HTTP_' . str_replace('-', '_', strtoupper($name));\n"
" }\n"
"\n"
" protected static function convertParamNameToHeaderName(string $name)\n"
" {\n"
" return ucwords(str_replace('_', '-', substr($name, strlen('HTTP_'))), '-');\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_fast_cgi_http_response =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\FastCGI;\n"
"\n"
"use Swoole\\Http\\Status;\n"
"\n"
"class HttpResponse extends Response\n"
"{\n"
" /** @var int */\n"
" protected $statusCode;\n"
"\n"
" /** @var string */\n"
" protected $reasonPhrase;\n"
"\n"
" /** @var array */\n"
" protected $headers = [];\n"
"\n"
" /** @var array */\n"
" protected $headersMap = [];\n"
"\n"
" /** @var array */\n"
" protected $setCookieHeaderLines = [];\n"
"\n"
" public function __construct(array $records = [])\n"
" {\n"
" parent::__construct($records);\n"
" $body = (string) $this->getBody();\n"
" if (strlen($body) === 0) {\n"
" return;\n"
" }\n"
" $array = explode(\"\\r\\n\\r\\n\", $body, 2); // An array that contains the HTTP headers and the body.\n"
" if (count($array) != 2) {\n"
" $this->withStatusCode(Status::BAD_GATEWAY)->withReasonPhrase('Invalid FastCGI Response')->withError($body);\n"
" return;\n"
" }\n"
" $headers = explode(\"\\r\\n\", $array[0]);\n"
" $body = $array[1];\n"
" foreach ($headers as $header) {\n"
" $array = explode(':', $header, 2); // An array that contains the name and the value of an HTTP header.\n"
" if (count($array) != 2) {\n"
" continue; // Invalid HTTP header? Ignore it!\n"
" }\n"
" $name = trim($array[0]);\n"
" $value = trim($array[1]);\n"
" if (strcasecmp($name, 'Status') === 0) {\n"
" $array = explode(' ', $value, 2); // An array that contains the status code (and the reason phrase).\n"
" $statusCode = $array[0];\n"
" $reasonPhrase = $array[1] ?? null;\n"
" } elseif (strcasecmp($name, 'Set-Cookie') === 0) {\n"
" $this->withSetCookieHeaderLine($value);\n"
" } else {\n"
" $this->withHeader($name, $value);\n"
" }\n"
" }\n"
" $statusCode = (int) ($statusCode ?? Status::OK);\n"
" $reasonPhrase = (string) ($reasonPhrase ?? Status::getReasonPhrase($statusCode));\n"
" $this->withStatusCode($statusCode)->withReasonPhrase($reasonPhrase);\n"
" $this->withBody($body);\n"
" }\n"
"\n"
" public function getStatusCode(): int\n"
" {\n"
" return $this->statusCode;\n"
" }\n"
"\n"
" public function withStatusCode(int $statusCode): self\n"
" {\n"
" $this->statusCode = $statusCode;\n"
" return $this;\n"
" }\n"
"\n"
" public function getReasonPhrase(): string\n"
" {\n"
" return $this->reasonPhrase;\n"
" }\n"
"\n"
" public function withReasonPhrase(string $reasonPhrase): self\n"
" {\n"
" $this->reasonPhrase = $reasonPhrase;\n"
" return $this;\n"
" }\n"
"\n"
" public function getHeader(string $name): ?string\n"
" {\n"
" $name = $this->headersMap[strtolower($name)] ?? null;\n"
" return $name ? $this->headers[$name] : null;\n"
" }\n"
"\n"
" public function getHeaders(): array\n"
" {\n"
" return $this->headers;\n"
" }\n"
"\n"
" public function withHeader(string $name, string $value): self\n"
" {\n"
" $this->headers[$name] = $value;\n"
" $this->headersMap[strtolower($name)] = $name;\n"
" return $this;\n"
" }\n"
"\n"
" public function withHeaders(array $headers): self\n"
" {\n"
" foreach ($headers as $name => $value) {\n"
" $this->withHeader($name, $value);\n"
" }\n"
" return $this;\n"
" }\n"
"\n"
" public function getSetCookieHeaderLines(): array\n"
" {\n"
" return $this->setCookieHeaderLines;\n"
" }\n"
"\n"
" public function withSetCookieHeaderLine(string $value): self\n"
" {\n"
" $this->setCookieHeaderLines[] = $value;\n"
" return $this;\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_coroutine_fast_cgi_client =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Coroutine\\FastCGI;\n"
"\n"
"use InvalidArgumentException;\n"
"use Swoole\\Coroutine\\FastCGI\\Client\\Exception;\n"
"use Swoole\\Coroutine\\Socket;\n"
"use Swoole\\FastCGI\\FrameParser;\n"
"use Swoole\\FastCGI\\HttpRequest;\n"
"use Swoole\\FastCGI\\HttpResponse;\n"
"use Swoole\\FastCGI\\Record\\EndRequest;\n"
"use Swoole\\FastCGI\\Request;\n"
"use Swoole\\FastCGI\\Response;\n"
"\n"
"class Client\n"
"{\n"
" /** @var int */\n"
" protected $af;\n"
"\n"
" /** @var string */\n"
" protected $host;\n"
"\n"
" /** @var int */\n"
" protected $port;\n"
"\n"
" /** @var bool */\n"
" protected $ssl;\n"
"\n"
" /** @var Socket */\n"
" protected $socket;\n"
"\n"
" public function __construct(string $host, int $port = 0, bool $ssl = false)\n"
" {\n"
" if (stripos($host, 'unix:/') === 0) {\n"
" $this->af = AF_UNIX;\n"
" $host = '/' . ltrim(substr($host, strlen('unix:/')), '/');\n"
" $port = 0;\n"
" } elseif (strpos($host, ':') !== false) {\n"
" $this->af = AF_INET6;\n"
" } else {\n"
" $this->af = AF_INET;\n"
" }\n"
" $this->host = $host;\n"
" $this->port = $port;\n"
" $this->ssl = $ssl;\n"
" }\n"
"\n"
" /**\n"
" * @throws Exception\n"
" * @return HttpResponse|Response\n"
" */\n"
" public function execute(Request $request, float $timeout = -1): Response\n"
" {\n"
" if (!$this->socket) {\n"
" $this->socket = $socket = new Socket($this->af, SOCK_STREAM, IPPROTO_IP);\n"
" $socket->setProtocol([\n"
" 'open_ssl' => $this->ssl,\n"
" 'open_fastcgi_protocol' => true,\n"
" ]);\n"
" if (!$socket->connect($this->host, $this->port, $timeout)) {\n"
" $this->ioException();\n"
" }\n"
" } else {\n"
" $socket = $this->socket;\n"
" }\n"
" $sendData = (string) $request;\n"
" if ($socket->sendAll($sendData) !== strlen($sendData)) {\n"
" $this->ioException();\n"
" }\n"
" $records = [];\n"
" while (true) {\n"
" if (SWOOLE_VERSION_ID < 40500) {\n"
" $recvData = '';\n"
" while (true) {\n"
" $tmp = $socket->recv(8192, $timeout);\n"
" if (!$tmp) {\n"
" if ($tmp === '') {\n"
" $this->ioException(SOCKET_ECONNRESET);\n"
" }\n"
" $this->ioException();\n"
" }\n"
" $recvData .= $tmp;\n"
" if (FrameParser::hasFrame($recvData)) {\n"
" break;\n"
" }\n"
" }\n"
" } else {\n"
" $recvData = $socket->recvPacket($timeout);\n"
" if (!$recvData) {\n"
" if ($recvData === '') {\n"
" $this->ioException(SOCKET_ECONNRESET);\n"
" }\n"
" $this->ioException();\n"
" }\n"
" if (!FrameParser::hasFrame($recvData)) {\n"
" $this->ioException(SOCKET_EPROTO);\n"
" }\n"
" }\n"
" do {\n"
" $records[] = $record = FrameParser::parseFrame($recvData);\n"
" } while (strlen($recvData) !== 0);\n"
" if ($record instanceof EndRequest) {\n"
" if (!$request->getKeepConn()) {\n"
" $this->socket->close();\n"
" $this->socket = null;\n"
" }\n"
" switch (true) {\n"
" case $request instanceof HttpRequest:\n"
" return new HttpResponse($records);\n"
" default:\n"
" return new Response($records);\n"
" }\n"
" }\n"
" }\n"
" /* never here */\n"
" exit(1);\n"
" }\n"
"\n"
" public static function parseUrl(string $url): array\n"
" {\n"
" $url = parse_url($url);\n"
" $host = $url['host'] ?? '';\n"
" $port = $url['port'] ?? 0;\n"
" if (empty($host)) {\n"
" $host = $url['path'] ?? '';\n"
" if (empty($host)) {\n"
" throw new InvalidArgumentException('Invalid url');\n"
" }\n"
" $host = \"unix:/{$host}\";\n"
" }\n"
" return [$host, $port];\n"
" }\n"
"\n"
" public static function call(string $url, string $path, $data = '', float $timeout = -1): string\n"
" {\n"
" $client = new Client(...static::parseUrl($url));\n"
" $pathInfo = parse_url($path);\n"
" $path = $pathInfo['path'] ?? '';\n"
" $root = dirname($path);\n"
" $scriptName = '/' . basename($path);\n"
" $documentUri = $scriptName;\n"
" $query = $pathInfo['query'] ?? '';\n"
" $requestUri = $query ? \"{$documentUri}?{$query}\" : $documentUri;\n"
" $request = new HttpRequest();\n"
" $request->withDocumentRoot($root)\n"
" ->withScriptFilename($path)\n"
" ->withScriptName($documentUri)\n"
" ->withDocumentUri($documentUri)\n"
" ->withRequestUri($requestUri)\n"
" ->withQueryString($query)\n"
" ->withBody($data)\n"
" ->withMethod($request->getContentLength() === 0 ? 'GET' : 'POST');\n"
" $response = $client->execute($request, $timeout);\n"
" return $response->getBody();\n"
" }\n"
"\n"
" protected function ioException(?int $errno = null): void\n"
" {\n"
" $socket = $this->socket;\n"
" if ($errno !== null) {\n"
" $socket->errCode = $errno;\n"
" $socket->errMsg = swoole_strerror($errno);\n"
" }\n"
" $socket->close();\n"
" $this->socket = null;\n"
" throw new Exception($socket->errMsg, $socket->errCode);\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_coroutine_fast_cgi_client_exception =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Coroutine\\FastCGI\\Client;\n"
"\n"
"class Exception extends \\Swoole\\Exception\n"
"{\n"
"}\n";
static const char* swoole_library_source_core_coroutine_fast_cgi_proxy =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Coroutine\\FastCGI;\n"
"\n"
"use InvalidArgumentException;\n"
"use Swoole\\FastCGI\\HttpRequest;\n"
"use Swoole\\FastCGI\\HttpResponse;\n"
"use Swoole\\Http;\n"
"\n"
"class Proxy\n"
"{\n"
" /* @var string */\n"
" protected $host;\n"
"\n"
" /* @var int */\n"
" protected $port;\n"
"\n"
" /* @var float */\n"
" protected $timeout = -1;\n"
"\n"
" /* @var string */\n"
" protected $documentRoot;\n"
"\n"
" /* @var bool */\n"
" protected $https = false;\n"
"\n"
" /* @var string */\n"
" protected $index = 'index.php';\n"
"\n"
" /* @var array */\n"
" protected $params = [];\n"
"\n"
" /* @var null|callable */\n"
" protected $staticFileFilter;\n"
"\n"
" public function __construct(string $url, string $documentRoot = '/')\n"
" {\n"
" [$this->host, $this->port] = Client::parseUrl($url);\n"
" $this->documentRoot = $documentRoot;\n"
" $this->staticFileFilter = [$this, 'staticFileFiltrate'];\n"
" }\n"
"\n"
" public function withTimeout(float $timeout): self\n"
" {\n"
" $this->timeout = $timeout;\n"
" return $this;\n"
" }\n"
"\n"
" public function withHttps(bool $https): self\n"
" {\n"
" $this->https = $https;\n"
" return $this;\n"
" }\n"
"\n"
" public function withIndex(string $index): self\n"
" {\n"
" $this->index = $index;\n"
" return $this;\n"
" }\n"
"\n"
" public function getParam(string $name): ?string\n"
" {\n"
" return $this->params[$name] ?? null;\n"
" }\n"
"\n"
" public function withParam(string $name, string $value): self\n"
" {\n"
" $this->params[$name] = $value;\n"
" return $this;\n"
" }\n"
"\n"
" public function withoutParam(string $name): self\n"
" {\n"
" unset($this->params[$name]);\n"
" return $this;\n"
" }\n"
"\n"
" public function getParams(): array\n"
" {\n"
" return $this->params;\n"
" }\n"
"\n"
" public function withParams(array $params): self\n"
" {\n"
" $this->params = $params;\n"
" return $this;\n"
" }\n"
"\n"
" public function withAddedParams(array $params): self\n"
" {\n"
" $this->params = $params + $this->params;\n"
" return $this;\n"
" }\n"
"\n"
" public function withStaticFileFilter(?callable $filter): self\n"
" {\n"
" $this->staticFileFilter = $filter;\n"
" return $this;\n"
" }\n"
"\n"
" public function translateRequest($userRequest): HttpRequest\n"
" {\n"
" $request = new HttpRequest();\n"
" if ($userRequest instanceof \\Swoole\\Http\\Request) {\n"
" $server = $userRequest->server;\n"
" $headers = $userRequest->header;\n"
" $pathInfo = $userRequest->server['path_info'];\n"
" $pathInfo = '/' . (ltrim($pathInfo, '/'));\n"
" if (strlen($this->index) !== 0) {\n"
" $extension = pathinfo($pathInfo, PATHINFO_EXTENSION);\n"
" if (empty($extension)) {\n"
" $pathInfo = rtrim($pathInfo, '/') . '/' . $this->index;\n"
" }\n"
" }\n"
" $requestUri = $scriptName = $documentUri = $server['request_uri'];\n"
" $queryString = $server['query_string'] ?? '';\n"
" if (strlen($queryString) !== 0) {\n"
" $requestUri .= \"?{$server['query_string']}\";\n"
" }\n"
" $request\n"
" ->withDocumentRoot($this->documentRoot)\n"
" ->withScriptFilename($this->documentRoot . $pathInfo)\n"
" ->withScriptName($scriptName)\n"
" ->withDocumentUri($documentUri)\n"
" ->withServerProtocol($server['server_protocol'])\n"
" ->withServerAddr('127.0.0.1')\n"
" ->withServerPort($server['server_port'])\n"
" ->withRemoteAddr($server['remote_addr'])\n"
" ->withRemotePort($server['remote_port'])\n"
" ->withMethod($server['request_method'])\n"
" ->withRequestUri($requestUri)\n"
" ->withQueryString($queryString)\n"
" ->withContentType($headers['content-type'] ?? '')\n"
" ->withContentLength((int) ($headers['content-length'] ?? 0))\n"
" ->withHeaders($headers)\n"
" ->withBody($userRequest->rawContent())\n"
" ->withAddedParams($this->params);\n"
" if ($this->https) {\n"
" $request->withParam('HTTPS', '1');\n"
" }\n"
" } else {\n"
" throw new InvalidArgumentException('Not supported on ' . get_class($userRequest));\n"
" }\n"
" return $request;\n"
" }\n"
"\n"
" public function translateResponse(HttpResponse $response, $userResponse): void\n"
" {\n"
" if ($userResponse instanceof \\Swoole\\Http\\Response) {\n"
" $userResponse->status($response->getStatusCode(), $response->getReasonPhrase());\n"
" $userResponse->header = $response->getHeaders();\n"
" $userResponse->cookie = $response->getSetCookieHeaderLines();\n"
" $userResponse->end($response->getBody());\n"
" } else {\n"
" throw new InvalidArgumentException('Not supported on ' . get_class($userResponse));\n"
" }\n"
" }\n"
"\n"
" public function pass($userRequest, $userResponse): void\n"
" {\n"
" if (!($userRequest instanceof HttpRequest)) {\n"
" $request = $this->translateRequest($userRequest);\n"
" } else {\n"
" $request = $userRequest;\n"
" }\n"
" unset($userRequest);\n"
" if ($this->staticFileFilter) {\n"
" $filter = $this->staticFileFilter;\n"
" if ($filter($request, $userResponse)) {\n"
" return;\n"
" }\n"
" }\n"
" $client = new Client($this->host, $this->port);\n"
" $response = $client->execute($request, $this->timeout);\n"
" $this->translateResponse($response, $userResponse);\n"
" }\n"
"\n"
" /* @return bool ['hit' => true, 'miss' => false] */\n"
" public function staticFileFiltrate(HttpRequest $request, $userResponse): bool\n"
" {\n"
" if ($userResponse instanceof \\Swoole\\Http\\Response) {\n"
" $extension = pathinfo($request->getScriptFilename(), PATHINFO_EXTENSION);\n"
" if ($extension !== 'php') {\n"
" $realPath = realpath($request->getScriptFilename());\n"
" if (!$realPath || strpos($realPath, $this->documentRoot) !== 0 || !is_file($realPath)) {\n"
" $userResponse->status(Http\\Status::NOT_FOUND);\n"
" } else {\n"
" $userResponse->sendfile($realPath);\n"
" }\n"
" return true;\n"
" }\n"
" return false;\n"
" }\n"
" throw new InvalidArgumentException('Not supported on ' . get_class($userResponse));\n"
" }\n"
"}\n";
static const char* swoole_library_source_core_coroutine_functions =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Coroutine;\n"
"\n"
"use Swoole\\Coroutine;\n"
"\n"
"function batch(array $tasks, float $timeout = -1): array\n"
"{\n"
" $wg = new WaitGroup();\n"
" $wg->add(count($tasks));\n"
" foreach ($tasks as $id => $task) {\n"
" Coroutine::create(function () use ($wg, &$tasks, $id, $task) {\n"
" $tasks[$id] = null;\n"
" $tasks[$id] = $task();\n"
" $wg->done();\n"
" });\n"
" }\n"
" $wg->wait($timeout);\n"
" return $tasks;\n"
"}\n";
static const char* swoole_library_source_ext_curl =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"/* @noinspection PhpComposerExtensionStubsInspection */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"function swoole_curl_init(string $url = ''): Swoole\\Curl\\Handler\n"
"{\n"
" return new Swoole\\Curl\\Handler($url);\n"
"}\n"
"\n"
"function swoole_curl_setopt(Swoole\\Curl\\Handler $obj, int $opt, $value): bool\n"
"{\n"
" return $obj->setOpt($opt, $value);\n"
"}\n"
"\n"
"function swoole_curl_setopt_array(Swoole\\Curl\\Handler $obj, $array): bool\n"
"{\n"
" foreach ($array as $k => $v) {\n"
" if ($obj->setOpt($k, $v) !== true) {\n"
" return false;\n"
" }\n"
" }\n"
" return true;\n"
"}\n"
"\n"
"function swoole_curl_exec(Swoole\\Curl\\Handler $obj)\n"
"{\n"
" return $obj->exec();\n"
"}\n"
"\n"
"function swoole_curl_getinfo(Swoole\\Curl\\Handler $obj, int $opt = 0)\n"
"{\n"
" $info = $obj->getInfo();\n"
" if (is_array($info) and $opt) {\n"
" switch ($opt) {\n"
" case CURLINFO_EFFECTIVE_URL:\n"
" return $info['url'];\n"
" case CURLINFO_HTTP_CODE:\n"
" return $info['http_code'];\n"
" case CURLINFO_CONTENT_TYPE:\n"
" return $info['content_type'];\n"
" case CURLINFO_REDIRECT_COUNT:\n"
" return $info['redirect_count'];\n"
" case CURLINFO_REDIRECT_URL:\n"
" return $info['redirect_url'];\n"
" case CURLINFO_TOTAL_TIME:\n"
" return $info['total_time'];\n"
" case CURLINFO_STARTTRANSFER_TIME:\n"
" return $info['starttransfer_time'];\n"
" case CURLINFO_SIZE_DOWNLOAD:\n"
" return $info['size_download'];\n"
" case CURLINFO_SPEED_DOWNLOAD:\n"
" return $info['speed_download'];\n"
" case CURLINFO_REDIRECT_TIME:\n"
" return $info['redirect_time'];\n"
" case CURLINFO_HEADER_SIZE:\n"
" return $info['header_size'];\n"
" default:\n"
" return null;\n"
" }\n"
" }\n"
" return $info;\n"
"}\n"
"\n"
"function swoole_curl_errno(Swoole\\Curl\\Handler $obj)\n"
"{\n"
" return $obj->errno();\n"
"}\n"
"\n"
"function swoole_curl_error(Swoole\\Curl\\Handler $obj)\n"
"{\n"
" return $obj->error();\n"
"}\n"
"\n"
"function swoole_curl_reset(Swoole\\Curl\\Handler $obj)\n"
"{\n"
" return $obj->reset();\n"
"}\n"
"\n"
"function swoole_curl_close(Swoole\\Curl\\Handler $obj)\n"
"{\n"
" return $obj->close();\n"
"}\n"
"\n"
"function swoole_curl_multi_getcontent(Swoole\\Curl\\Handler $obj)\n"
"{\n"
" return $obj->getContent();\n"
"}\n";
static const char* swoole_library_source_functions =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"if (SWOOLE_USE_SHORTNAME) {\n"
" function _string(string $string = ''): Swoole\\StringObject\n"
" {\n"
" return new Swoole\\StringObject($string);\n"
" }\n"
"\n"
" function _mbstring(string $string = ''): Swoole\\MultibyteStringObject\n"
" {\n"
" return new Swoole\\MultibyteStringObject($string);\n"
" }\n"
"\n"
" function _array(array $array = []): Swoole\\ArrayObject\n"
" {\n"
" return new Swoole\\ArrayObject($array);\n"
" }\n"
"}\n"
"\n"
"function swoole_string(string $string = ''): Swoole\\StringObject\n"
"{\n"
" return new Swoole\\StringObject($string);\n"
"}\n"
"\n"
"function swoole_mbstring(string $string = ''): Swoole\\MultibyteStringObject\n"
"{\n"
" return new Swoole\\MultibyteStringObject($string);\n"
"}\n"
"\n"
"function swoole_array(array $array = []): Swoole\\ArrayObject\n"
"{\n"
" return new Swoole\\ArrayObject($array);\n"
"}\n"
"\n"
"function swoole_array_list(...$arrray): Swoole\\ArrayObject\n"
"{\n"
" return new Swoole\\ArrayObject($arrray);\n"
"}\n"
"\n"
"function swoole_array_default_value(array $array, $key, $default_value = null)\n"
"{\n"
" return array_key_exists($key, $array) ? $array[$key] : $default_value;\n"
"}\n"
"\n"
"if (!function_exists('array_key_last')) {\n"
" function array_key_last(array $array)\n"
" {\n"
" return key(array_slice($array, -1));\n"
" }\n"
"}\n"
"\n"
"if (!function_exists('array_key_first')) {\n"
" function array_key_first(array $array)\n"
" {\n"
" foreach ($array as $key => $unused) {\n"
" return $key;\n"
" }\n"
" return null;\n"
" }\n"
"}\n";
static const char* swoole_library_source_alias =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"if (SWOOLE_USE_SHORTNAME) {\n"
" class_alias(Swoole\\Coroutine\\WaitGroup::class, Co\\WaitGroup::class, true);\n"
" class_alias(Swoole\\Coroutine\\Server::class, Co\\Server::class, true);\n"
" class_alias(Swoole\\Coroutine\\Server\\Connection::class, Co\\Server\\Connection::class, true);\n"
" class_alias(Swoole\\Coroutine\\FastCGI\\Client::class, Co\\FastCGI\\Client::class, true);\n"
" class_alias(Swoole\\Coroutine\\FastCGI\\Client\\Exception::class, Co\\FastCGI\\Client\\Exception::class, true);\n"
" class_alias(Swoole\\Coroutine\\FastCGI\\Proxy::class, Co\\FastCGI\\Proxy::class, true);\n"
"}\n";
static const char* swoole_library_source_alias_ns =
"\n"
"/**\n"
" * This file is part of Swoole.\n"
" *\n"
" * @link https://www.swoole.com\n"
" * @contact team@swoole.com\n"
" * @license https://github.com/swoole/library/blob/master/LICENSE\n"
" */\n"
"\n"
"declare(strict_types=1);\n"
"\n"
"namespace Swoole\\Coroutine {\n"
" function run(callable $fn, ...$args)\n"
" {\n"
" $s = new Scheduler();\n"
" $s->add($fn, ...$args);\n"
" return $s->start();\n"
" }\n"
"}\n"
"\n"
"namespace Co {\n"
" if (SWOOLE_USE_SHORTNAME) {\n"
" function run(callable $fn, ...$args)\n"
" {\n"
" return \\Swoole\\Coroutine\\Run($fn, ...$args);\n"
" }\n"
" }\n"
"}\n";
static void php_swoole_load_library()
{
zend::eval(swoole_library_source_constants, "@swoole-src/library/constants.php");
zend::eval(swoole_library_source_std_exec, "@swoole-src/library/std/exec.php");
zend::eval(swoole_library_source_core_constant, "@swoole-src/library/core/Constant.php");
zend::eval(swoole_library_source_core_string_object, "@swoole-src/library/core/StringObject.php");
zend::eval(swoole_library_source_core_multibyte_string_object, "@swoole-src/library/core/MultibyteStringObject.php");
zend::eval(swoole_library_source_core_array_object, "@swoole-src/library/core/ArrayObject.php");
zend::eval(swoole_library_source_core_object_proxy, "@swoole-src/library/core/ObjectProxy.php");
zend::eval(swoole_library_source_core_coroutine_wait_group, "@swoole-src/library/core/Coroutine/WaitGroup.php");
zend::eval(swoole_library_source_core_coroutine_server, "@swoole-src/library/core/Coroutine/Server.php");
zend::eval(swoole_library_source_core_coroutine_server_connection, "@swoole-src/library/core/Coroutine/Server/Connection.php");
zend::eval(swoole_library_source_core_connection_pool, "@swoole-src/library/core/ConnectionPool.php");
zend::eval(swoole_library_source_core_database_object_proxy, "@swoole-src/library/core/Database/ObjectProxy.php");
zend::eval(swoole_library_source_core_database_mysqli_config, "@swoole-src/library/core/Database/MysqliConfig.php");
zend::eval(swoole_library_source_core_database_mysqli_exception, "@swoole-src/library/core/Database/MysqliException.php");
zend::eval(swoole_library_source_core_database_mysqli_pool, "@swoole-src/library/core/Database/MysqliPool.php");
zend::eval(swoole_library_source_core_database_mysqli_proxy, "@swoole-src/library/core/Database/MysqliProxy.php");
zend::eval(swoole_library_source_core_database_mysqli_statement_proxy, "@swoole-src/library/core/Database/MysqliStatementProxy.php");
zend::eval(swoole_library_source_core_database_pdo_config, "@swoole-src/library/core/Database/PDOConfig.php");
zend::eval(swoole_library_source_core_database_pdo_pool, "@swoole-src/library/core/Database/PDOPool.php");
zend::eval(swoole_library_source_core_database_pdo_proxy, "@swoole-src/library/core/Database/PDOProxy.php");
zend::eval(swoole_library_source_core_database_pdo_statement_proxy, "@swoole-src/library/core/Database/PDOStatementProxy.php");
zend::eval(swoole_library_source_core_database_redis_config, "@swoole-src/library/core/Database/RedisConfig.php");
zend::eval(swoole_library_source_core_database_redis_pool, "@swoole-src/library/core/Database/RedisPool.php");
zend::eval(swoole_library_source_core_http_status, "@swoole-src/library/core/Http/Status.php");
zend::eval(swoole_library_source_core_curl_exception, "@swoole-src/library/core/Curl/Exception.php");
zend::eval(swoole_library_source_core_curl_handler, "@swoole-src/library/core/Curl/Handler.php");
zend::eval(swoole_library_source_core_fast_cgi, "@swoole-src/library/core/FastCGI.php");
zend::eval(swoole_library_source_core_fast_cgi_record, "@swoole-src/library/core/FastCGI/Record.php");
zend::eval(swoole_library_source_core_fast_cgi_record_params, "@swoole-src/library/core/FastCGI/Record/Params.php");
zend::eval(swoole_library_source_core_fast_cgi_record_abort_request, "@swoole-src/library/core/FastCGI/Record/AbortRequest.php");
zend::eval(swoole_library_source_core_fast_cgi_record_begin_request, "@swoole-src/library/core/FastCGI/Record/BeginRequest.php");
zend::eval(swoole_library_source_core_fast_cgi_record_data, "@swoole-src/library/core/FastCGI/Record/Data.php");
zend::eval(swoole_library_source_core_fast_cgi_record_end_request, "@swoole-src/library/core/FastCGI/Record/EndRequest.php");
zend::eval(swoole_library_source_core_fast_cgi_record_get_values, "@swoole-src/library/core/FastCGI/Record/GetValues.php");
zend::eval(swoole_library_source_core_fast_cgi_record_get_values_result, "@swoole-src/library/core/FastCGI/Record/GetValuesResult.php");
zend::eval(swoole_library_source_core_fast_cgi_record_stdin, "@swoole-src/library/core/FastCGI/Record/Stdin.php");
zend::eval(swoole_library_source_core_fast_cgi_record_stdout, "@swoole-src/library/core/FastCGI/Record/Stdout.php");
zend::eval(swoole_library_source_core_fast_cgi_record_stderr, "@swoole-src/library/core/FastCGI/Record/Stderr.php");
zend::eval(swoole_library_source_core_fast_cgi_record_unknown_type, "@swoole-src/library/core/FastCGI/Record/UnknownType.php");
zend::eval(swoole_library_source_core_fast_cgi_frame_parser, "@swoole-src/library/core/FastCGI/FrameParser.php");
zend::eval(swoole_library_source_core_fast_cgi_message, "@swoole-src/library/core/FastCGI/Message.php");
zend::eval(swoole_library_source_core_fast_cgi_request, "@swoole-src/library/core/FastCGI/Request.php");
zend::eval(swoole_library_source_core_fast_cgi_response, "@swoole-src/library/core/FastCGI/Response.php");
zend::eval(swoole_library_source_core_fast_cgi_http_request, "@swoole-src/library/core/FastCGI/HttpRequest.php");
zend::eval(swoole_library_source_core_fast_cgi_http_response, "@swoole-src/library/core/FastCGI/HttpResponse.php");
zend::eval(swoole_library_source_core_coroutine_fast_cgi_client, "@swoole-src/library/core/Coroutine/FastCGI/Client.php");
zend::eval(swoole_library_source_core_coroutine_fast_cgi_client_exception, "@swoole-src/library/core/Coroutine/FastCGI/Client/Exception.php");
zend::eval(swoole_library_source_core_coroutine_fast_cgi_proxy, "@swoole-src/library/core/Coroutine/FastCGI/Proxy.php");
zend::eval(swoole_library_source_core_coroutine_functions, "@swoole-src/library/core/Coroutine/functions.php");
zend::eval(swoole_library_source_ext_curl, "@swoole-src/library/ext/curl.php");
zend::eval(swoole_library_source_functions, "@swoole-src/library/functions.php");
zend::eval(swoole_library_source_alias, "@swoole-src/library/alias.php");
zend::eval(swoole_library_source_alias_ns, "@swoole-src/library/alias_ns.php");
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化