1 Star 0 Fork 0

exchange / swoole-src

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
php_swoole_library.h 227.67 KB
一键复制 编辑 原始数据 按行查看 历史
twosee 提交于 2020-05-28 16:52 . Update version for Swoole 4.5.2
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545
/**
* Generated by build-library.php, Please DO NOT modify!
*/
/* $Id: 612b7a470a7339ecd6913034386df573cbba8c70 */
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"
" * @param $string\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 lrim(): 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 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($needle) - 1);\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"
" return $this->string[$index];\n"
" }\n"
"\n"
" /**\n"
" * @return static\n"
" */\n"
" public function chunkSplit(int $chunkLength = 1, 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"
" /**\n"
" * @return string\n"
" */\n"
" public function toString()\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 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"
" * @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) {\n"
" unset($this->array[$key]);\n"
" } else {\n"
" break;\n"
" }\n"
" } while ($loop);\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 array_push($this->array, $value);\n"
" }\n"
"\n"
" /**\n"
" * @param mixed $value\n"
" * @return int\n"
" */\n"
" public function pushBack($value)\n"
" {\n"
" return array_unshift($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 array_pop($this->array);\n"
" }\n"
"\n"
" /**\n"
" * @return mixed\n"
" */\n"
" public function popFront()\n"
" {\n"
" return array_shift($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"
" * @return static\n"
" */\n"
" public function map(callable $fn): self\n"
" {\n"
" return new static(array_map($fn, $this->array));\n"
" }\n"
"\n"
" /**\n"
" * @return mixed\n"
" */\n"
" public function reduce(callable $fn)\n"
" {\n"
" return array_reduce($this->array, $fn);\n"
" }\n"
"\n"
" /**\n"
" * @param int $search_value\n"
" * @param bool $strict\n"
" * @return static\n"
" */\n"
" public function keys(int $search_value = null, $strict = false): self\n"
" {\n"
" return new static(array_keys($this->array, $search_value, $strict));\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): 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 multiSort(int $sort_order = SORT_ASC, int $sort_flags = SORT_REGULAR): self\n"
" {\n"
" if (array_multisort($this->array, $sort_order, $sort_flags) !== true) {\n"
" throw new RuntimeException('array_multisort() failed');\n"
" }\n"
" return $this;\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"
" public const DRIVER_PGSQL = 'pgsql';\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"
" self::DRIVER_PGSQL,\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 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"
" $this->headers['Host'] = $this->urlInfo['host'];\n"
" // remove empty headers (keep same with raw cURL)\n"
" foreach ($this->headers as $headerName => $headerValue) {\n"
" if ($headerValue === '') {\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_default_value(array $array, $key, $default_value = null)\n"
"{\n"
" return array_key_exists($key, $array) ? $array[$key] : $default_value;\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");
}
1
https://gitee.com/exchange_96/swoole-src.git
git@gitee.com:exchange_96/swoole-src.git
exchange_96
swoole-src
swoole-src
master

搜索帮助