-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.html
3072 lines (2950 loc) · 319 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>HTTP - ReactPHP</title>
<meta name="description" content="Event-driven, streaming HTTP client and server implementation for ReactPHP.">
<link rel="apple-touch-icon" sizes="180x180" href="https://reactphp.org/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="https://reactphp.org/favicon-32x32.png">
<link rel="manifest" href="https://reactphp.org/manifest.json">
<link rel="mask-icon" href="https://reactphp.org/safari-pinned-tab.svg" color="#4f5b93">
<meta name="apple-mobile-web-app-title" content="ReactPHP">
<meta name="application-name" content="ReactPHP">
<meta name="theme-color" content="#f4f3f1">
<meta name="msapplication-config" content="https://reactphp.org/browserconfig.xml" />
<meta property="og:image" content="https://reactphp.org/og-image.png">
<link rel="preload" href="../assets/sourcesanspro-regular.f84b2bd4.woff" as="font" type="font/woff" crossorigin>
<link rel="preload" href="../assets/sourcesanspro-bold.cb7d3610.woff" as="font" type="font/woff" crossorigin>
<script>window.__assets = '../assets/';</script>
<script>!function(){"use strict";var e,t,n,r,o,i={},u={};function a(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return i[e].call(n.exports,n,n.exports,a),n.exports}a.m=i,e=[],a.O=function(t,n,r,o){if(!n){var i=1/0;for(l=0;l<e.length;l++){n=e[l][0],r=e[l][1],o=e[l][2];for(var u=!0,f=0;f<n.length;f++)(!1&o||i>=o)&&Object.keys(a.O).every((function(e){return a.O[e](n[f])}))?n.splice(f--,1):(u=!1,o<i&&(i=o));if(u){e.splice(l--,1);var c=r();void 0!==c&&(t=c)}}return t}o=o||0;for(var l=e.length;l>0&&e[l-1][2]>o;l--)e[l]=e[l-1];e[l]=[n,r,o]},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,{a:t}),t},a.d=function(e,t){for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},a.f={},a.e=function(e){return Promise.all(Object.keys(a.f).reduce((function(t,n){return a.f[n](e,t),t}),[]))},a.u=function(e){return e+"."+{67:"ab055693",139:"820be3d5",261:"bd162b4a",553:"da065a6b"}[e]+".js"},a.miniCssF=function(e){return e+"."+{67:"4ae9feba",139:"3ced3f7b",553:"90d4e0e8"}[e]+".css"},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t={},n="reactphp-website:",a.l=function(e,r,o,i){if(t[e])t[e].push(r);else{var u,f;if(void 0!==o)for(var c=document.getElementsByTagName("script"),l=0;l<c.length;l++){var s=c[l];if(s.getAttribute("src")==e||s.getAttribute("data-webpack")==n+o){u=s;break}}u||(f=!0,(u=document.createElement("script")).charset="utf-8",u.timeout=120,a.nc&&u.setAttribute("nonce",a.nc),u.setAttribute("data-webpack",n+o),u.src=e),t[e]=[r];var d=function(n,r){u.onerror=u.onload=null,clearTimeout(p);var o=t[e];if(delete t[e],u.parentNode&&u.parentNode.removeChild(u),o&&o.forEach((function(e){return e(r)})),n)return n(r)},p=setTimeout(d.bind(null,void 0,{type:"timeout",target:u}),12e4);u.onerror=d.bind(null,u.onerror),u.onload=d.bind(null,u.onload),f&&document.head.appendChild(u)}},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.p="",r=function(e){return new Promise((function(t,n){var r=a.miniCssF(e),o=a.p+r;if(function(e,t){for(var n=document.getElementsByTagName("link"),r=0;r<n.length;r++){var o=(u=n[r]).getAttribute("data-href")||u.getAttribute("href");if("stylesheet"===u.rel&&(o===e||o===t))return u}var i=document.getElementsByTagName("style");for(r=0;r<i.length;r++){var u;if((o=(u=i[r]).getAttribute("data-href"))===e||o===t)return u}}(r,o))return t();!function(e,t,n,r){var o=document.createElement("link");o.rel="stylesheet",o.type="text/css",o.onerror=o.onload=function(i){if(o.onerror=o.onload=null,"load"===i.type)n();else{var u=i&&("load"===i.type?"missing":i.type),a=i&&i.target&&i.target.href||t,f=new Error("Loading CSS chunk "+e+" failed.\n("+a+")");f.code="CSS_CHUNK_LOAD_FAILED",f.type=u,f.request=a,o.parentNode.removeChild(o),r(f)}},o.href=t,document.head.appendChild(o)}(e,o,t,n)}))},o={666:0},a.f.miniCss=function(e,t){o[e]?t.push(o[e]):0!==o[e]&&{67:1,139:1,553:1}[e]&&t.push(o[e]=r(e).then((function(){o[e]=0}),(function(t){throw delete o[e],t})))},function(){var e={666:0};a.f.j=function(t,n){var r=a.o(e,t)?e[t]:void 0;if(0!==r)if(r)n.push(r[2]);else if(666!=t){var o=new Promise((function(n,o){r=e[t]=[n,o]}));n.push(r[2]=o);var i=a.p+a.u(t),u=new Error;a.l(i,(function(n){if(a.o(e,t)&&(0!==(r=e[t])&&(e[t]=void 0),r)){var o=n&&("load"===n.type?"missing":n.type),i=n&&n.target&&n.target.src;u.message="Loading chunk "+t+" failed.\n("+o+": "+i+")",u.name="ChunkLoadError",u.type=o,u.request=i,r[1](u)}}),"chunk-"+t,t)}else e[t]=0},a.O.j=function(t){return 0===e[t]};var t=function(t,n){var r,o,i=n[0],u=n[1],f=n[2],c=0;if(i.some((function(t){return 0!==e[t]}))){for(r in u)a.o(u,r)&&(a.m[r]=u[r]);if(f)var l=f(a)}for(t&&t(n);c<i.length;c++)o=i[c],a.o(e,o)&&e[o]&&e[o][0](),e[o]=0;return a.O(l)},n=self.webpackChunkreactphp_website=self.webpackChunkreactphp_website||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))}()}();</script>
<style>@font-face{font-display:swap;font-family:Source Sans Pro;font-style:normal;font-weight:400;src:local("Source Sans Pro Regular"),local("SourceSansPro-Regular"),url(../assets/sourcesanspro-regular.f84b2bd4.woff) format("woff")}@font-face{font-display:swap;font-family:Source Sans Pro;font-style:normal;font-weight:700;src:local("Source Sans Pro Bold"),local("SourceSansPro-Bold"),url(../assets/sourcesanspro-bold.cb7d3610.woff) format("woff")}@font-face{font-family:icons;font-style:normal;font-weight:400;src:url(../assets/icons.f41c5641.ttf?ae19fi) format("truetype"),url(../assets/icons.cf61dfff.woff?ae19fi) format("woff"),url(../assets/icons.b4abbede.svg?ae19fi#icons) format("svg")}[class*=" icon-"],[class^=icon-]{speak:none;-webkit-font-feature-settings:normal;font-feature-settings:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-family:icons!important;font-style:normal;font-variant:normal;font-weight:400;line-height:1;text-transform:none}.icon-hash:before{content:"\e900"}.icon-twitter:before{content:"\e901"}.icon-github:before{content:"\e902"}.icon-blog:before{content:"\e905"}.icon-earth:before{content:"\e903"}.icon-link:before{content:"\e906"}.icon-youtube:before{content:"\e904"}.icon-book:before{content:"\f007"}.icon-calendar:before{content:"\f068"}.icon-chevron-down:before{content:"\f0a3"}.icon-chevron-up:before{content:"\f0a2"}.icon-law:before{content:"\f0d8"}.icon-search:before{content:"\f02e"}.icon-x:before{content:"\f081"}.icon-feed:before{content:"\ea9b"}[class*=" icon-"],[class^=icon-]{vertical-align:-8%}html{-webkit-box-sizing:border-box;box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;font-size:16px;line-height:1.6}@media (max-width:768px){html{font-size:18px}}*,:after,:before{-webkit-box-sizing:inherit;box-sizing:inherit}body{background-color:#fff;color:#584b4f;color:var(--color-base);margin:0}a{color:#4f5b93;color:var(--color-key)}a:hover{color:#a2aacd;color:var(--color-key-light);text-decoration:underline}blockquote{background-color:#f4f3f1;background-color:var(--color-background-lighter);border-left:4px solid #4f5b93;border-left:4px solid var(--color-key);border-radius:4px;-webkit-box-shadow:0 1px 0 0 rgba(0,0,0,.1);box-shadow:0 1px 0 0 rgba(0,0,0,.1);-webkit-box-shadow:var(--box-shadow-lighter);box-shadow:var(--box-shadow-lighter);font-size:.875rem;padding:16px 16px 16px 24px;position:relative}blockquote:before{background:#4f5b93;background:var(--color-key);border-radius:50%;-webkit-box-sizing:border-box;box-sizing:border-box;color:#fff;content:"i";display:block;font-size:12px;font-weight:700;height:24px;left:-14px;line-height:24px;padding:0 4px;position:absolute;text-align:center;top:12px;width:24px}blockquote :last-child{margin-bottom:0}blockquote,fieldset,form,h1,h2,h3,h4,h5,h6,hr,ol,p,ul{margin:0 0 16px}ul ul{margin-bottom:0}hr{border:0;border-bottom:1px dashed #eae8e3;border-bottom:1px dashed var(--color-background-light);clear:both;height:0;padding:0}h1,h2,h3,h4,h5,h6{-webkit-font-smoothing:antialiased;color:#584b4f;color:var(--color-base);font-family:Source Sans Pro,Helvetica Neue,Arial,sans-serif;font-weight:700;line-height:1}h1 a,h1 a:hover,h2 a,h2 a:hover,h3 a,h3 a:hover,h4 a,h4 a:hover,h5 a,h5 a:hover,h6 a,h6 a:hover{text-decoration:none}h1{font-size:2.5rem;letter-spacing:-1px;margin-bottom:32px}h1,h1 a,h1 a:hover{color:#4f5b93;color:var(--color-key)}h1:not(:first-child){margin-top:32px}h2{font-size:2rem;margin-bottom:32px}h2,h2 a,h2 a:hover{color:#4f5b93;color:var(--color-key)}h2:not(:first-child){margin-top:32px}h3{font-size:1.5rem;margin-bottom:24px}h3,h3 a,h3 a:hover{color:#584b4f;color:var(--color-base)}h3:not(:first-child){margin-top:24px}h4{font-size:1.25rem}h4,h4 a,h4 a:hover{color:#4f5b93;color:var(--color-key)}h4:not(:first-child){margin-top:24px}@media (max-width:768px){h1{font-size:2rem}h2{font-size:1.75rem;margin-bottom:32px}}.container{padding:32px}@media (max-width:768px){.container{padding:16px}}.wrapper{margin:auto;max-width:1600px}.wrapper--medium{max-width:1280px}.wrapper--small{margin:auto;max-width:960px}.wrapper--narrow{max-width:640px}.main{width:calc(98% - 400px)}.main,.sidebar{margin-bottom:32px}.sidebar{width:calc(400px - 2%)}@media (max-width:1024px){.main,.sidebar{margin-top:16px;width:auto}}.visually-hidden{clip:rect(1px,1px,1px,1px);height:1px;overflow:hidden;position:absolute!important;width:1px}.grid{-ms-flex-pack:center;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;-ms-flex-wrap:wrap;flex-wrap:wrap;justify-content:center;margin-left:-2%;width:102%}.grid>*{margin-left:2%;max-width:100%}.grid--4cols>*{-ms-flex-preferred-size:23%;flex-basis:23%}.grid--3cols>*{-ms-flex-preferred-size:31.33%;flex-basis:31.33%}.grid--2cols>*{-ms-flex-preferred-size:48%;flex-basis:48%}@media (max-width:768px){.grid{-ms-flex-direction:column;flex-direction:column}.grid,.grid>*{margin-left:0;width:100%}.grid>*{-ms-flex:0 0 auto;flex:0 0 auto}}.center{text-align:center}.center h1,.center h2,.center h3,.center h4,.center h5,.center h6,.hamburger{display:inline-block}.hamburger{background-color:transparent;border:0;color:inherit;cursor:pointer;font:inherit;height:48px;margin:0;outline:none;overflow:visible;padding:14px 12px;text-transform:none}.hamburger__box{display:inline-block;height:16px;position:relative;width:24px}.hamburger__inner{display:block;margin-top:-2px;top:50%}.hamburger__inner,.hamburger__inner:after,.hamburger__inner:before{background-color:#584b4f;background-color:var(--color-base);border-radius:2px;height:3px;position:absolute;-webkit-transition-duration:.15s;-o-transition-duration:.15s;transition-duration:.15s;-webkit-transition-property:-webkit-transform;transition-property:-webkit-transform;-o-transition-property:transform;transition-property:transform;transition-property:transform,-webkit-transform;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease;width:24px}.hamburger__inner:after,.hamburger__inner:before{content:"";display:block}.hamburger__inner:before{top:-6px}.hamburger__inner:after{bottom:-6px}.header{background:#fefefe;-webkit-box-shadow:0 1px 0 0 rgba(0,0,0,.08);box-shadow:0 1px 0 0 rgba(0,0,0,.08);-webkit-box-shadow:var(--box-shadow-lightest);box-shadow:var(--box-shadow-lightest);padding:0 32px;width:100%}@media (max-width:768px){.header{padding:0 16px}}.header__container{-ms-flex-align:center;-ms-flex-pack:justify;align-items:center;display:-ms-flexbox;display:flex;justify-content:space-between;position:relative;width:100%}.header__logo{display:block;line-height:1;padding:16px 0}.header__logo svg{display:block;height:18px;width:120px}.header__search{margin:0;position:absolute;right:48px;top:7px;z-index:799}.header__search input{width:400px}@media (max-width:768px){.header__search input{width:calc(100vw - 94px)}}.header__menu{position:absolute;right:-12px;top:0;z-index:800}.footer{background:#584b4f;background:var(--color-base);padding:32px;text-align:center;text-shadow:1px 1px 0 rgba(0,0,0,.125)}.footer .links a{color:#eae8e3;color:var(--color-background-light);text-decoration:none}.footer .links a:hover{color:#9ad8bb;color:var(--color-green-light);text-decoration:none}.iframe{height:0;overflow:hidden;padding-bottom:56.25%;position:relative;width:100%}.iframe iframe{height:100%;left:0;position:absolute;top:0;width:100%}.links{margin:0;padding:0}.links li{display:inline-block;margin:0 8px;text-decoration:none}.links li:first-child{margin-left:0}.links li:last-child{margin-right:0}.links a{display:block}.box,.links a,.links a:hover{text-decoration:none}.box{background:#f4f3f1;background:var(--color-background-lighter);border-radius:4px;-webkit-box-shadow:0 1px 0 0 rgba(0,0,0,.1);box-shadow:0 1px 0 0 rgba(0,0,0,.1);-webkit-box-shadow:var(--box-shadow-lighter);box-shadow:var(--box-shadow-lighter);color:inherit;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;margin-bottom:24px;margin-top:0;overflow:auto;padding:24px;text-align:left;vertical-align:top}.box:hover{background:#eae8e3;background:var(--color-background-light);-webkit-box-shadow:0 1px 0 0 rgba(0,0,0,.15);box-shadow:0 1px 0 0 rgba(0,0,0,.15);-webkit-box-shadow:var(--box-shadow-light);box-shadow:var(--box-shadow-light);text-decoration:none}.box h1,.box h2,.box h3,.box h4,.box h5,.box h6,.box hr,.box ol,.box p,.box ul{margin-bottom:8px}.box h1,.box h2,.box h3,.box h4,.box h5,.box h6{color:#584b4f;color:var(--color-base)}.box :first-child{margin-top:0}.box :last-child{margin-bottom:0}.box__content{-ms-flex-positive:1;color:#584b4f;color:var(--color-base);flex-grow:1;text-decoration:none}.box__content p{font-size:.875rem}.box__content:hover{color:#584b4f;color:var(--color-base);text-decoration:none}.box__content:not(:last-child){margin-bottom:16px}.box__link{display:block;font-size:.75rem;text-decoration:none}.box__link,.box__link [class*=icon]{color:#4f5b93;color:var(--color-key)}.box__link:hover{color:#a2aacd;color:var(--color-key-light);text-decoration:none}code,pre,tt{font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace}code,tt{background-color:rgba(0,0,0,.05);border-radius:4px;font-size:.75rem;margin:0;padding:.3rem .45rem}code br,tt br{display:none}del code{text-decoration:inherit}pre{word-wrap:normal;font-size:.875rem;line-height:1.45;text-align:left}@media (max-width:768px){pre{font-size:.75rem}}pre>code{background:transparent;border:0;font-size:100%;margin:0;padding:0;white-space:pre;word-break:normal}.highlight{margin-bottom:16px}.highlight pre{margin-bottom:0;word-break:normal}.highlight pre,pre{background-color:#f9f9f8;background-color:var(--color-background-lightest);border-radius:4px;-webkit-box-shadow:0 1px 0 0 rgba(0,0,0,.08);box-shadow:0 1px 0 0 rgba(0,0,0,.08);-webkit-box-shadow:var(--box-shadow-lightest);box-shadow:var(--box-shadow-lightest);color:#584b4f;color:var(--color-base);overflow:auto;padding:16px 16px 14px;text-shadow:none!important}pre code,pre tt{word-wrap:normal;background-color:transparent;border:0;display:inline;line-height:inherit;margin:0;max-width:none;overflow:visible;padding:0}pre code:after,pre code:before,pre tt:after,pre tt:before{content:normal}.pl-c{color:#969896}.pl-c1,.pl-s .pl-v{color:#0086b3}.pl-e,.pl-en{color:#795da3}.pl-s .pl-s1,.pl-smi{color:#444}.pl-ent{color:#63a35c}.pl-k{color:#a71d5d}.pl-pds,.pl-s,.pl-s .pl-pse .pl-s1,.pl-sr,.pl-sr .pl-cce,.pl-sr .pl-sra,.pl-sr .pl-sre{color:#183691}.pl-smw,.pl-v{color:#ed6a43}.pl-bu{color:#b52a1d}.pl-c2,.pl-ii{background-color:#b52a1d;color:#f8f8f8}.pl-c2:before{content:"^M"}.pl-sr .pl-cce{color:#63a35c;font-weight:700}.pl-ml{color:#693a17}.pl-mh,.pl-mh .pl-en,.pl-ms{color:#1d3e81;font-weight:700}.pl-mq{color:teal}.pl-mi{color:#333;font-style:italic}.pl-mb{color:#333;font-weight:700}.pl-md{background-color:#ffecec;color:#bd2c00}.pl-mi1{background-color:#eaffea;color:#55a532}.pl-mc{background-color:#ffe3b4;color:#ef9700}.pl-mi2{background-color:grey;color:#d8d8d8}.pl-mdr{color:#795da3;font-weight:700}.pl-mo{color:#1d3e81}.pl-ba{color:#595e62}.pl-sg{color:silver}.pl-corl{color:#183691;text-decoration:underline}.anchor{display:block;float:left;padding-right:2px;position:absolute;text-decoration:none!important;-webkit-transform:translateX(-100%);transform:translateX(-100%)}.anchor:focus{outline:none}.anchor>*{visibility:hidden}:hover>.anchor>*{visibility:visible}.anchor>:before{color:#a2aacd;color:var(--color-key-light);content:"#";font-weight:400!important}.anchor--disable .anchor>*,.anchor.anchor--disable>*{visibility:hidden!important}.searchbox{width:100%}.searchbox,.searchbox:focus{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:#eae8e3 url(../assets/search.17d09555.svg) no-repeat 10px;background:var(--color-background-light) url(../assets/search.17d09555.svg) no-repeat 10px center;background-size:16px 16px;border:0;border-radius:4px;-webkit-box-shadow:0 1px 0 0 rgba(0,0,0,.15);box-shadow:0 1px 0 0 rgba(0,0,0,.15);-webkit-box-shadow:var(--box-shadow-light);box-shadow:var(--box-shadow-light);color:#584b4f;color:var(--color-base);font-size:.875rem;line-height:24px;outline:none;padding:6px 8px 6px 32px;-webkit-transition:width .35s cubic-bezier(.23,1,.32,1);-o-transition:width .35s cubic-bezier(.23,1,.32,1);transition:width .35s cubic-bezier(.23,1,.32,1)}.searchbox::-webkit-input-placeholder{color:#afa1a5;color:var(--color-base-light)}.searchbox:-moz-placeholder,.searchbox::-moz-placeholder{color:#afa1a5;color:var(--color-base-light)}.searchbox::-moz-placeholder{opacity:1}.searchbox:-ms-input-placeholder{color:#afa1a5;color:var(--color-base-light)}.searchbox:focus{background-color:#f4f3f1!important;background-color:var(--color-background-lighter)!important;-webkit-box-shadow:0 1px 0 0 rgba(0,0,0,.1);box-shadow:0 1px 0 0 rgba(0,0,0,.1);-webkit-box-shadow:var(--box-shadow-lighter);box-shadow:var(--box-shadow-lighter)}.searchbox--collapsed:not(:focus){background-color:transparent;border:0;-webkit-box-shadow:none;box-shadow:none;cursor:pointer;margin-right:-12px;width:32px!important}.searchbox--collapsed:not(:focus)::-webkit-search-cancel-button,.searchbox--collapsed:not(:focus)::-webkit-search-decoration{display:none}.searchbox--collapsed:not(:focus)::-webkit-search-results-button,.searchbox--collapsed:not(:focus)::-webkit-search-results-decoration{display:none}.searchbox--collapsed:not(:focus)::-ms-clear{display:none}.searchbox--large,.searchbox--large:focus{padding:8px 12px 8px 40px}.alert{background-color:#f4f3f1;background-color:var(--color-background-lighter);border-left:4px solid #ba3525;border-left:4px solid var(--color-red);border-radius:4px;-webkit-box-shadow:0 1px 0 0 rgba(0,0,0,.1);box-shadow:0 1px 0 0 rgba(0,0,0,.1);-webkit-box-shadow:var(--box-shadow-lighter);box-shadow:var(--box-shadow-lighter);font-size:.9em;padding:16px 16px 16px 24px;position:relative}.alert:before{background:#ba3525;background:var(--color-red);border-radius:50%;-webkit-box-sizing:border-box;box-sizing:border-box;color:#fff;content:"!";display:block;font-size:12px;font-weight:700;height:24px;left:-14px;line-height:22px;padding:0 4px;position:absolute;text-align:center;top:12px;width:24px}.alert a{color:#ba3525;color:var(--color-red)}.alert :last-child{margin-bottom:0}.toc{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;list-style:none;margin-left:-4px;padding:0}.toc li{margin:4px}.toc a{background-color:#584b4f;background-color:var(--color-base);border-radius:4px;-webkit-box-shadow:0 1px 0 0 rgba(0,0,0,.1);box-shadow:0 1px 0 0 rgba(0,0,0,.1);-webkit-box-shadow:var(--box-shadow-lighter);box-shadow:var(--box-shadow-lighter);display:-ms-flexbox;display:flex;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace;font-weight:bolder;letter-spacing:normal;padding:.25rem 1rem .15rem}.toc a,.toc a:hover{color:#fff;text-decoration:none}@media (max-width:768px){.toc{font-size:.85rem}}.welcome__intro{background-image:-o-radial-gradient(center,ellipse,#fff 0,#eae8e3 100%);background-image:radial-gradient(ellipse at center,#fff 0,#eae8e3 100%);background-image:-o-radial-gradient(center,ellipse,#fff 0,var(--color-background-light) 100%);background-image:radial-gradient(ellipse at center,#fff 0,var(--color-background-light) 100%);background-position:50% 0;background-size:auto 100%;border-bottom:1px dashed #eae8e3;border-bottom:1px dashed var(--color-background-light);padding:16px 0 136px}.welcome__intro h1{color:#4f5b93;color:var(--color-key);font-size:2rem;margin-bottom:16px}.welcome__logo{display:block;margin:0 auto;max-width:320px}.welcome__logo svg{display:block;height:240px}.welcome__content{display:block;max-width:calc(98% - 320px);padding-top:16px}.welcome__example{display:block;margin:-160px auto auto;max-width:850px}.welcome__example .highlight pre{background:#fff;-webkit-box-shadow:0 0 16px #d6d1c8;box-shadow:0 0 16px #d6d1c8;-webkit-box-shadow:0 0 16px var(--color-background);box-shadow:0 0 16px var(--color-background);padding:32px}.welcome__intro .links a{color:#584b4f;color:var(--color-base);text-decoration:none}.welcome__intro .links a:hover{color:#4f5b93;color:var(--color-key);text-decoration:none}.welcome__team img{border-radius:50%;display:inline-block;max-width:190px}.welcome__team h3{display:block;margin:.2em 0}.welcome__team div.grid>*{margin-bottom:1em}@media (max-width:768px){.welcome__content{max-width:100%;padding:32px 16px 16px}.welcome__logo svg{height:160px}.welcome__intro h1{color:#4f5b93;color:var(--color-key);font-size:1.75rem;margin-bottom:16px;text-align:center}.welcome__intro .links{text-align:center}}.off-canvas-menu{pointer-events:none;position:fixed;right:0;top:0}.off-canvas-menu__content{-webkit-transform:translate3d(105%,0,0);transform:translate3d(105%,0,0)}.component-info{background-color:#f4f3f1;background-color:var(--color-background-lighter);border-radius:4px;bottom:16px;-webkit-box-shadow:0 1px 0 0 rgba(0,0,0,.1);box-shadow:0 1px 0 0 rgba(0,0,0,.1);-webkit-box-shadow:var(--box-shadow-lighter);box-shadow:var(--box-shadow-lighter);font-size:.875rem;padding:24px;position:sticky;top:16px}.component-info,.component-info a,.component-info a [class*=icon]{color:#584b4f;color:var(--color-base)}.component-info a:hover{color:#afa1a5;color:var(--color-base-light);text-decoration:none}.component-info pre{font-size:.75rem;line-height:1}.component-info__title{-ms-flex-align:center;align-items:center;color:#584b4f;color:var(--color-base);display:-ms-flexbox;display:flex;font-size:1.5rem;line-height:1rem;margin-bottom:1rem}.component-info__title a{text-decoration:none}.component-info__title>:not(:last-child){margin-right:8px}.component-info__subtitle{color:#afa1a5;color:var(--color-base-light);font-size:.875rem;font-weight:700;letter-spacing:.1em;line-height:.875rem;margin-bottom:.875rem;text-transform:uppercase}.component-info__info{-ms-flex-pack:start;display:-ms-flexbox;display:flex;-ms-flex-flow:row;flex-flow:row;justify-content:flex-start;list-style:none;padding:0}.component-info__info li{margin-right:16px}.component-info__info li:last-child{margin-right:0}.component-info__info a{font-size:.75rem;text-decoration:none;-o-text-overflow:ellipsis;text-overflow:ellipsis;white-space:nowrap}.component-info__contributors{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;list-style:none;padding:0}.component-info__contributors li{margin:0;padding:0 4px 4px 0}.component-info__contributors img{border-radius:2px;display:block;height:auto;width:40px}.component-info__contributors img,.component-info__participation{-webkit-box-shadow:0 1px 0 0 rgba(0,0,0,.1);box-shadow:0 1px 0 0 rgba(0,0,0,.1);-webkit-box-shadow:var(--box-shadow-lighter);box-shadow:var(--box-shadow-lighter)}.component-info__participation{background-color:#f9f9f8;background-color:var(--color-background-lightest);border-radius:4px;padding:8px;text-align:center}.component-info__participation svg{display:block;height:auto!important;margin:auto;max-width:100%}:root{--color-key:#4f5b93;--color-key-light:#a2aacd;--color-base:#584b4f;--color-base-light:#afa1a5;--color-green:#40a977;--color-green-light:#9ad8bb;--color-red:#ba3525;--color-red-light:#e79187;--color-background:#d6d1c8;--color-background-light:#eae8e3;--color-background-lighter:#f4f3f1;--color-background-lightest:#f9f9f8;--box-shadow-light:0 1px 0 0 rgba(0,0,0,.15);--box-shadow-lighter:0 1px 0 0 rgba(0,0,0,.1);--box-shadow-lightest:0 1px 0 0 rgba(0,0,0,.08)}.version-selector{color:#fff;font-size:.875rem;position:relative}.version-selector :last-child{margin-bottom:0}.version-selector__button,.version-selector__version{-webkit-appearance:none;background-color:#584b4f;background-color:var(--color-base);border:0;border-radius:4px;-webkit-box-shadow:none;box-shadow:none;-webkit-box-shadow:0 1px 0 0 rgba(0,0,0,.1);box-shadow:0 1px 0 0 rgba(0,0,0,.1);-webkit-box-shadow:var(--box-shadow-lighter);box-shadow:var(--box-shadow-lighter);color:#fff;cursor:pointer;display:-ms-flexbox;display:flex;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace;font-size:.75rem;font-weight:bolder;letter-spacing:normal;margin:0;outline:none;overflow:visible;padding:.25rem .4rem .2rem;text-decoration:none;text-shadow:none;text-transform:none}.version-selector__button{position:relative}.version-selector__button [class=icon-chevron-down]{display:inline-block;margin-left:4px}.version-selector__button [class=icon-chevron-up]{display:none;margin-left:4px}.version-selector__version{background-color:hsla(0,0%,100%,.33);border:1px solid transparent;color:#fff!important;text-decoration:none}.version-selector__version:hover{background-color:hsla(0,0%,100%,.11);border:1px solid hsla(0,0%,100%,.22)}.version-selector__button--dev,.version-selector__version--dev,.version-selector__version--dev:hover{background-color:#ba3525;background-color:var(--color-red)}.version-selector__button--latest,.version-selector__version--latest,.version-selector__version--latest:hover{background-color:#40a977;background-color:var(--color-green)}.version-selector__panel{position:fixed;top:-20000em;visibility:hidden}</style>
<script async src="../assets/main.93d54642.js"></script>
</head>
<body>
<header class="header">
<div class="wrapper">
<div class="header__container">
<a class="header__logo" href="../">
<svg xmlns="http://www.w3.org/2000/svg" width="320" height="47.29" viewBox="0 428.964 320 47.29"><path fill="#584B4F" d="M30.86 452.385c1.637-2.287 2.455-5 2.455-8.134 0-4.313-1.367-7.87-4.088-10.68-2.723-2.812-6.39-4.216-11.004-4.216h-7.71c-3.79 0-6.49.798-8.1 2.388C.806 433.332 0 435.872 0 439.355v36.512h9.08v-17.245h6.53l9.08 17.245h10.52L24.82 457.12c2.395-.87 4.41-2.447 6.04-4.735zm-8.488-3.334c-1.24 1.33-2.82 1.99-4.734 1.99H9.08v-9.47c0-2.74 1.35-4.112 4.05-4.112h4.508c2 0 3.603.61 4.8 1.83 1.196 1.22 1.797 2.82 1.797 4.802 0 1.982-.623 3.64-1.864 4.964v-.003zm20.348 14.536c0 4.572 1.055 7.766 3.167 9.57 2.114 1.81 5.782 2.71 11.008 2.71h16.46v-8.1H57.548c-2.18 0-3.68-.35-4.51-1.045-.83-.695-1.24-1.96-1.24-3.788v-6.467h14.434l.656-8.1h-15.09v-10.912h21.56v-8.098H42.72v34.23zm57.97-33.442c-.718-.523-1.665-.787-2.84-.787-1.177 0-2.168.285-2.972.85-.807.567-1.537 1.592-2.19 3.073l-14.89 42.585h9.47l2.55-8.03h15.613l2.613 8.03h9.47l-14.893-42.588c-.567-1.572-1.21-2.613-1.93-3.135v.002zM92.1 460.19l5.75-18.42 5.487 18.418H92.1v.002zm53.074 5.455c-1.155 1.678-3.245 2.512-6.27 2.512-3.03 0-5.258-.914-6.697-2.74-1.394-1.83-2.093-5.25-2.093-10.256v-4.052c0-1.783.045-3.2.13-4.243.178-3.27.785-5.576 1.833-6.928 1.48-1.914 3.745-2.873 6.794-2.873 2.613 0 4.532.653 5.75 1.96 1.218 1.308 2.07 3.245 2.547 5.813h8.49c0-5.14-1.557-9.07-4.67-11.79-3.114-2.723-7.153-4.084-12.116-4.084-3.398 0-6.293.564-8.687 1.7-6.097 2.783-9.146 9.686-9.146 20.704v3.918c0 13.982 5.945 20.968 17.833 20.968 5.4 0 9.58-1.59 12.54-4.77 2.964-3.176 4.44-7.73 4.44-13.653h-8.426c-.346 3.53-1.1 6.134-2.25 7.81v.005zm14.667-36.29v8.1h12.412v38.41h9.08v-38.41h12.47v-8.1"/><path fill="#4F5B93" d="M218.89 429.356h-18.03v46.51h9.086v-14.897h8.944c4.876 0 8.647-1.337 11.328-4.016 2.683-2.68 4.02-6.608 4.02-11.788s-1.337-9.112-4.02-11.788c-2.68-2.68-6.454-4.02-11.328-4.02v-.002zm4.538 21.686c-1.15 1.177-2.815 1.768-5 1.768h-8.485v-15.354h8.484c4.483 0 6.73 2.572 6.73 7.71 0 2.744-.578 4.703-1.73 5.88v-.004zm43.93-2.02H250.31v-19.666h-9.088v46.51h9.086v-18.81h17.05v18.81h9.076v-46.51h-9.078m48.63 4.02c-2.683-2.68-6.46-4.02-11.335-4.02h-18.027v46.507h9.085V460.97h8.943c4.877 0 8.654-1.336 11.337-4.014 2.68-2.678 4.013-6.608 4.013-11.788s-1.332-9.112-4.013-11.79v-.003zm-6.795 17.666c-1.154 1.177-2.822 1.768-5 1.768h-8.484v-15.354h8.485c4.483 0 6.734 2.572 6.734 7.71 0 2.744-.583 4.703-1.735 5.88v-.004z"/></svg>
</a>
<form class="header__search">
<input type="search" class="searchbox searchbox--collapsed" data-docsearch placeholder="Search documentation...">
</form>
<div class="header__menu">
<button class="hamburger" data-ctrly="off-canvas-menu" data-off-canvas-menu-control>
<div class="hamburger__box">
<div class="hamburger__inner">
<span class="visually-hidden">Menu</span>
</div>
</div>
</button>
</div>
<nav id="off-canvas-menu" class="off-canvas-menu" aria-hidden="true" tabindex="0">
<div class="off-canvas-menu__content">
<button aria-label="Close menu" class="off-canvas-menu__close" data-ctrly="off-canvas-menu" data-off-canvas-menu-control>
<i class="icon-x" aria-hidden="true"></i>
</button>
<section class="off-canvas-menu__section">
<a class="off-canvas-menu__section-top" href="../">Home</a>
</section>
<section class="off-canvas-menu__section">
<a class="off-canvas-menu__section-top" href="../changelog.html">Changelog</a>
</section>
<section class="off-canvas-menu__section">
<h3 class="off-canvas-menu__section-header">Core Components</h3>
<ul class="off-canvas-menu__list">
<li>
<a class="off-canvas-menu__link" href="../event-loop/">
EventLoop
<span class="off-canvas-menu__version">
v1.5.0
</span>
</a>
</li>
<li>
<a class="off-canvas-menu__link" href="../stream/">
Stream
<span class="off-canvas-menu__version">
v1.4.0
</span>
</a>
</li>
<li>
<a class="off-canvas-menu__link" href="../promise/">
Promise
<span class="off-canvas-menu__version">
v3.2.0
</span>
</a>
</li>
<li>
<a class="off-canvas-menu__link" href="../async/">
Async
<span class="off-canvas-menu__version">
v4.3.0
</span>
</a>
</li>
</ul>
</section>
<section class="off-canvas-menu__section">
<h3 class="off-canvas-menu__section-header">Network Components</h3>
<ul class="off-canvas-menu__list">
<li>
<a class="off-canvas-menu__link" href="../socket/">
Socket
<span class="off-canvas-menu__version">
v1.16.0
</span>
</a>
</li>
<li>
<a class="off-canvas-menu__link" href="../datagram/">
Datagram
<span class="off-canvas-menu__version">
v1.10.0
</span>
</a>
</li>
<li>
<a class="off-canvas-menu__link" href="../http/">
HTTP
<span class="off-canvas-menu__version">
v1.11.0
</span>
</a>
</li>
<li>
<a class="off-canvas-menu__link" href="../dns/">
DNS
<span class="off-canvas-menu__version">
v1.13.0
</span>
</a>
</li>
</ul>
</section>
<section class="off-canvas-menu__section">
<h3 class="off-canvas-menu__section-header">Utility Components</h3>
<ul class="off-canvas-menu__list">
<li>
<a class="off-canvas-menu__link" href="../cache/">
Cache
<span class="off-canvas-menu__version">
v1.2.0
</span>
</a>
</li>
<li>
<a class="off-canvas-menu__link" href="../child-process/">
ChildProcess
<span class="off-canvas-menu__version">
v0.6.6
</span>
</a>
</li>
<li>
<a class="off-canvas-menu__link" href="../promise-timer/">
PromiseTimer
<span class="off-canvas-menu__version">
v1.11.0
</span>
</a>
</li>
<li>
<a class="off-canvas-menu__link" href="../promise-stream/">
PromiseStream
<span class="off-canvas-menu__version">
v1.7.0
</span>
</a>
</li>
</ul>
</section>
<section class="off-canvas-menu__section">
<h3 class="off-canvas-menu__section-header">Legacy Components</h3>
<ul class="off-canvas-menu__list">
<li>
<a class="off-canvas-menu__link" href="../http-client/">
HttpClient
<span class="off-canvas-menu__version">
v0.5.11
</span>
</a>
</li>
<li>
<a class="off-canvas-menu__link" href="../socket-client/">
SocketClient
<span class="off-canvas-menu__version">
v0.7.0
</span>
</a>
</li>
</ul>
</section>
</div>
</nav>
</div>
</div>
</header>
<div class="container">
<div class="wrapper">
<div class="grid grid--wrap grid--gutter">
<main class="main">
<h1>HTTP</h1>
<div class="markdown-heading"><h1 class="heading-element">HTTP</h1><a id="http" class="anchor" aria-label="Permalink: HTTP" href="#http"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p><a href="https://github.com/reactphp/http/actions"><img src="https://github.com/reactphp/http/actions/workflows/ci.yml/badge.svg" alt="CI status" style="max-width: 100%;"></a>
<a href="https://packagist.org/packages/react/http" rel="nofollow"><img src="https://camo.githubusercontent.com/3c77bd631328ff8ceaaadf84752cc87f88b8691a1f70d93c3b07aaffec4754f3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72656163742f687474703f636f6c6f723d626c7565266c6162656c3d696e7374616c6c732532306f6e2532305061636b6167697374" alt="installs on Packagist" data-canonical-src="https://img.shields.io/packagist/dt/react/http?color=blue&label=installs%20on%20Packagist" style="max-width: 100%;"></a></p>
<p>Event-driven, streaming HTTP client and server implementation for <a href="https://reactphp.org/" rel="nofollow">ReactPHP</a>.</p>
<p>This HTTP library provides re-usable implementations for an HTTP client and
server based on ReactPHP's <a href="../socket/"><code>Socket</code></a> and
<a href="../event-loop/"><code>EventLoop</code></a> components.
Its client component allows you to send any number of async HTTP/HTTPS requests
concurrently.
Its server component allows you to build plaintext HTTP and secure HTTPS servers
that accept incoming HTTP requests from HTTP clients (such as web browsers).
This library provides async, streaming means for all of this, so you can handle
multiple concurrent HTTP requests without blocking.</p>
<p><strong>Table of contents</strong></p>
<ul>
<li><a href="#quickstart-example">Quickstart example</a></li>
<li>
<a href="#client-usage">Client Usage</a>
<ul>
<li><a href="#request-methods">Request methods</a></li>
<li><a href="#promises">Promises</a></li>
<li><a href="#cancellation">Cancellation</a></li>
<li><a href="#timeouts">Timeouts</a></li>
<li><a href="#authentication">Authentication</a></li>
<li><a href="#redirects">Redirects</a></li>
<li><a href="#blocking">Blocking</a></li>
<li><a href="#concurrency">Concurrency</a></li>
<li><a href="#streaming-response">Streaming response</a></li>
<li><a href="#streaming-request">Streaming request</a></li>
<li><a href="#http-proxy">HTTP proxy</a></li>
<li><a href="#socks-proxy">SOCKS proxy</a></li>
<li><a href="#ssh-proxy">SSH proxy</a></li>
<li><a href="#unix-domain-sockets">Unix domain sockets</a></li>
</ul>
</li>
<li>
<a href="#server-usage">Server Usage</a>
<ul>
<li><a href="#httpserver">HttpServer</a></li>
<li><a href="#listen">listen()</a></li>
<li>
<a href="#server-request">Server Request</a>
<ul>
<li><a href="#request-parameters">Request parameters</a></li>
<li><a href="#query-parameters">Query parameters</a></li>
<li><a href="#request-body">Request body</a></li>
<li><a href="#streaming-incoming-request">Streaming incoming request</a></li>
<li><a href="#request-method">Request method</a></li>
<li><a href="#cookie-parameters">Cookie parameters</a></li>
<li><a href="#invalid-request">Invalid request</a></li>
</ul>
</li>
<li>
<a href="#server-response">Server Response</a>
<ul>
<li><a href="#deferred-response">Deferred response</a></li>
<li><a href="#streaming-outgoing-response">Streaming outgoing response</a></li>
<li><a href="#response-length">Response length</a></li>
<li><a href="#invalid-response">Invalid response</a></li>
<li><a href="#default-response-headers">Default response headers</a></li>
</ul>
</li>
<li>
<a href="#middleware">Middleware</a>
<ul>
<li><a href="#custom-middleware">Custom middleware</a></li>
<li><a href="#third-party-middleware">Third-Party Middleware</a></li>
</ul>
</li>
</ul>
</li>
<li>
<a href="#api">API</a>
<ul>
<li>
<a href="#browser">Browser</a>
<ul>
<li><a href="#get">get()</a></li>
<li><a href="#post">post()</a></li>
<li><a href="#head">head()</a></li>
<li><a href="#patch">patch()</a></li>
<li><a href="#put">put()</a></li>
<li><a href="#delete">delete()</a></li>
<li><a href="#request">request()</a></li>
<li><a href="#requeststreaming">requestStreaming()</a></li>
<li><a href="#withtimeout">withTimeout()</a></li>
<li><a href="#withfollowredirects">withFollowRedirects()</a></li>
<li><a href="#withrejecterrorresponse">withRejectErrorResponse()</a></li>
<li><a href="#withbase">withBase()</a></li>
<li><a href="#withprotocolversion">withProtocolVersion()</a></li>
<li><a href="#withresponsebuffer">withResponseBuffer()</a></li>
<li><a href="#withheader">withHeader()</a></li>
<li><a href="#withoutheader">withoutHeader()</a></li>
</ul>
</li>
<li>
<a href="#reacthttpmessage">React\Http\Message</a>
<ul>
<li>
<a href="#response">Response</a>
<ul>
<li><a href="#html">html()</a></li>
<li><a href="#json">json()</a></li>
<li><a href="#plaintext">plaintext()</a></li>
<li><a href="#xml">xml()</a></li>
</ul>
</li>
<li><a href="#request-1">Request</a></li>
<li><a href="#serverrequest">ServerRequest</a></li>
<li><a href="#uri">Uri</a></li>
<li><a href="#responseexception">ResponseException</a></li>
</ul>
</li>
<li>
<a href="#reacthttpmiddleware">React\Http\Middleware</a>
<ul>
<li><a href="#streamingrequestmiddleware">StreamingRequestMiddleware</a></li>
<li><a href="#limitconcurrentrequestsmiddleware">LimitConcurrentRequestsMiddleware</a></li>
<li><a href="#requestbodybuffermiddleware">RequestBodyBufferMiddleware</a></li>
<li><a href="#requestbodyparsermiddleware">RequestBodyParserMiddleware</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#install">Install</a></li>
<li><a href="#tests">Tests</a></li>
<li><a href="#license">License</a></li>
</ul>
<div class="markdown-heading"><h2 class="heading-element">Quickstart example</h2><a id="quickstart-example" class="anchor" aria-label="Permalink: Quickstart example" href="#quickstart-example"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>Once <a href="#install">installed</a>, you can use the following code to access an
HTTP web server and send some simple HTTP GET requests:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-ent"><?php</span>
<span class="pl-k">require</span> <span class="pl-c1">__DIR__</span> . <span class="pl-s">'<span class="pl-s">/vendor/autoload.php</span>'</span>;
<span class="pl-s1"><span class="pl-c1">$</span>client</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">Browser</span>();
<span class="pl-s1"><span class="pl-c1">$</span>client</span>-><span class="pl-en">get</span>(<span class="pl-s">'<span class="pl-s">http://www.google.com/</span>'</span>)-><span class="pl-en">then</span>(<span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-v">Psr</span>\<span class="pl-v">Http</span>\<span class="pl-v">Message</span>\<span class="pl-smi">ResponseInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>response</span>) {
<span class="pl-en">var_dump</span>(<span class="pl-s1"><span class="pl-c1">$</span>response</span>-><span class="pl-en">getHeaders</span>(), (<span class="pl-smi">string</span>)<span class="pl-s1"><span class="pl-c1">$</span>response</span>-><span class="pl-en">getBody</span>());
}, <span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-smi">Exception</span></span> <span class="pl-s1"><span class="pl-c1">$</span>e</span>) {
<span class="pl-k">echo</span> <span class="pl-s">'<span class="pl-s">Error: </span>'</span> . <span class="pl-s1"><span class="pl-c1">$</span>e</span>-><span class="pl-en">getMessage</span>() . <span class="pl-c1">PHP_EOL</span>;
});</pre></div>
<p>This is an HTTP server which responds with <code>Hello World!</code> to every request.</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-ent"><?php</span>
<span class="pl-k">require</span> <span class="pl-c1">__DIR__</span> . <span class="pl-s">'<span class="pl-s">/vendor/autoload.php</span>'</span>;
<span class="pl-s1"><span class="pl-c1">$</span>http</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">HttpServer</span>(<span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-v">Psr</span>\<span class="pl-v">Http</span>\<span class="pl-v">Message</span>\<span class="pl-smi">ServerRequestInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>request</span>) {
<span class="pl-k">return</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">Message</span>\Response::<span class="pl-en">plaintext</span>(
<span class="pl-s">"<span class="pl-s">Hello World!</span>\n"</span>
);
});
<span class="pl-s1"><span class="pl-c1">$</span>socket</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Socket</span>\<span class="pl-v">SocketServer</span>(<span class="pl-s">'<span class="pl-s">127.0.0.1:8080</span>'</span>);
<span class="pl-s1"><span class="pl-c1">$</span>http</span>-><span class="pl-en">listen</span>(<span class="pl-s1"><span class="pl-c1">$</span>socket</span>);</pre></div>
<p>See also the <a href="https://github.com/reactphp/http/blob/v1.11.0/examples/">examples</a>.</p>
<div class="markdown-heading"><h2 class="heading-element">Client Usage</h2><a id="client-usage" class="anchor" aria-label="Permalink: Client Usage" href="#client-usage"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<div class="markdown-heading"><h3 class="heading-element">Request methods</h3><a id="request-methods" class="anchor" aria-label="Permalink: Request methods" href="#request-methods"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>Most importantly, this project provides a <a href="#browser"><code>Browser</code></a> object that
offers several methods that resemble the HTTP protocol methods:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">get</span>(<span class="pl-s1"><span class="pl-c1">$</span>url</span>, array <span class="pl-s1"><span class="pl-c1">$</span>headers</span> = <span class="pl-en">array</span>());
<span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">head</span>(<span class="pl-s1"><span class="pl-c1">$</span>url</span>, array <span class="pl-s1"><span class="pl-c1">$</span>headers</span> = <span class="pl-en">array</span>());
<span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">post</span>(<span class="pl-s1"><span class="pl-c1">$</span>url</span>, array <span class="pl-s1"><span class="pl-c1">$</span>headers</span> = <span class="pl-en">array</span>(), string|ReadableStreamInterface <span class="pl-s1"><span class="pl-c1">$</span>body</span> = <span class="pl-s">''</span>);
<span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">delete</span>(<span class="pl-s1"><span class="pl-c1">$</span>url</span>, array <span class="pl-s1"><span class="pl-c1">$</span>headers</span> = <span class="pl-en">array</span>(), string|ReadableStreamInterface <span class="pl-s1"><span class="pl-c1">$</span>body</span> = <span class="pl-s">''</span>);
<span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">put</span>(<span class="pl-s1"><span class="pl-c1">$</span>url</span>, array <span class="pl-s1"><span class="pl-c1">$</span>headers</span> = <span class="pl-en">array</span>(), string|ReadableStreamInterface <span class="pl-s1"><span class="pl-c1">$</span>body</span> = <span class="pl-s">''</span>);
<span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">patch</span>(<span class="pl-s1"><span class="pl-c1">$</span>url</span>, array <span class="pl-s1"><span class="pl-c1">$</span>headers</span> = <span class="pl-en">array</span>(), string|ReadableStreamInterface <span class="pl-s1"><span class="pl-c1">$</span>body</span> = <span class="pl-s">''</span>);</pre></div>
<p>Each of these methods requires a <code>$url</code> and some optional parameters to send an
HTTP request. Each of these method names matches the respective HTTP request
method, for example the <a href="#get"><code>get()</code></a> method sends an HTTP <code>GET</code> request.</p>
<p>You can optionally pass an associative array of additional <code>$headers</code> that will be
sent with this HTTP request. Additionally, each method will automatically add a
matching <code>Content-Length</code> request header if an outgoing request body is given and its
size is known and non-empty. For an empty request body, if will only include a
<code>Content-Length: 0</code> request header if the request method usually expects a request
body (only applies to <code>POST</code>, <code>PUT</code> and <code>PATCH</code> HTTP request methods).</p>
<p>If you're using a <a href="#streaming-request">streaming request body</a>, it will default
to using <code>Transfer-Encoding: chunked</code> unless you explicitly pass in a matching <code>Content-Length</code>
request header. See also <a href="#streaming-request">streaming request</a> for more details.</p>
<p>By default, all of the above methods default to sending requests using the
HTTP/1.1 protocol version. If you want to explicitly use the legacy HTTP/1.0
protocol version, you can use the <a href="#withprotocolversion"><code>withProtocolVersion()</code></a>
method. If you want to use any other or even custom HTTP request method, you can
use the <a href="#request"><code>request()</code></a> method.</p>
<p>Each of the above methods supports async operation and either <em>fulfills</em> with a
<a href="https://www.php-fig.org/psr/psr-7/#33-psrhttpmessageresponseinterface" rel="nofollow">PSR-7 <code>ResponseInterface</code></a>
or <em>rejects</em> with an <code>Exception</code>.
Please see the following chapter about <a href="#promises">promises</a> for more details.</p>
<div class="markdown-heading"><h3 class="heading-element">Promises</h3><a id="promises" class="anchor" aria-label="Permalink: Promises" href="#promises"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>Sending requests is async (non-blocking), so you can actually send multiple
requests in parallel.
The <code>Browser</code> will respond to each request with a
<a href="https://www.php-fig.org/psr/psr-7/#33-psrhttpmessageresponseinterface" rel="nofollow">PSR-7 <code>ResponseInterface</code></a>
message, the order is not guaranteed.
Sending requests uses a <a href="../promise/">Promise</a>-based
interface that makes it easy to react to when an HTTP request is completed
(i.e. either successfully fulfilled or rejected with an error):</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">get</span>(<span class="pl-s1"><span class="pl-c1">$</span>url</span>)-><span class="pl-en">then</span>(
<span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-v">Psr</span>\<span class="pl-v">Http</span>\<span class="pl-v">Message</span>\<span class="pl-smi">ResponseInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>response</span>) {
<span class="pl-en">var_dump</span>(<span class="pl-s">'<span class="pl-s">Response received</span>'</span>, <span class="pl-s1"><span class="pl-c1">$</span>response</span>);
},
<span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-smi">Exception</span></span> <span class="pl-s1"><span class="pl-c1">$</span>e</span>) {
<span class="pl-k">echo</span> <span class="pl-s">'<span class="pl-s">Error: </span>'</span> . <span class="pl-s1"><span class="pl-c1">$</span>e</span>-><span class="pl-en">getMessage</span>() . <span class="pl-c1">PHP_EOL</span>;
}
);</pre></div>
<p>If this looks strange to you, you can also use the more traditional <a href="#blocking">blocking API</a>.</p>
<p>Keep in mind that resolving the Promise with the full response message means the
whole response body has to be kept in memory.
This is easy to get started and works reasonably well for smaller responses
(such as common HTML pages or RESTful or JSON API requests).</p>
<p>You may also want to look into the <a href="#streaming-response">streaming API</a>:</p>
<ul>
<li>If you're dealing with lots of concurrent requests (100+) or</li>
<li>If you want to process individual data chunks as they happen (without having to wait for the full response body) or</li>
<li>If you're expecting a big response body size (1 MiB or more, for example when downloading binary files) or</li>
<li>If you're unsure about the response body size (better be safe than sorry when accessing arbitrary remote HTTP endpoints and the response body size is unknown in advance).</li>
</ul>
<div class="markdown-heading"><h3 class="heading-element">Cancellation</h3><a id="cancellation" class="anchor" aria-label="Permalink: Cancellation" href="#cancellation"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>The returned Promise is implemented in such a way that it can be cancelled
when it is still pending.
Cancelling a pending promise will reject its value with an Exception and
clean up any underlying resources.</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>promise</span> = <span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">get</span>(<span class="pl-s1"><span class="pl-c1">$</span>url</span>);
Loop::<span class="pl-en">addTimer</span>(<span class="pl-c1">2.0</span>, <span class="pl-k">function</span> () <span class="pl-k">use</span> (<span class="pl-s1"><span class="pl-c1">$</span>promise</span>) {
<span class="pl-s1"><span class="pl-c1">$</span>promise</span>-><span class="pl-en">cancel</span>();
});</pre></div>
<div class="markdown-heading"><h3 class="heading-element">Timeouts</h3><a id="timeouts" class="anchor" aria-label="Permalink: Timeouts" href="#timeouts"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>This library uses a very efficient HTTP implementation, so most HTTP requests
should usually be completed in mere milliseconds. However, when sending HTTP
requests over an unreliable network (the internet), there are a number of things
that can go wrong and may cause the request to fail after a time. As such, this
library respects PHP's <code>default_socket_timeout</code> setting (default 60s) as a timeout
for sending the outgoing HTTP request and waiting for a successful response and
will otherwise cancel the pending request and reject its value with an Exception.</p>
<p>Note that this timeout value covers creating the underlying transport connection,
sending the HTTP request, receiving the HTTP response headers and its full
response body and following any eventual <a href="#redirects">redirects</a>. See also
<a href="#redirects">redirects</a> below to configure the number of redirects to follow (or
disable following redirects altogether) and also <a href="#streaming-response">streaming</a>
below to not take receiving large response bodies into account for this timeout.</p>
<p>You can use the <a href="#withtimeout"><code>withTimeout()</code> method</a> to pass a custom timeout
value in seconds like this:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>browser</span> = <span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">withTimeout</span>(<span class="pl-c1">10.0</span>);
<span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">get</span>(<span class="pl-s1"><span class="pl-c1">$</span>url</span>)-><span class="pl-en">then</span>(<span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-v">Psr</span>\<span class="pl-v">Http</span>\<span class="pl-v">Message</span>\<span class="pl-smi">ResponseInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>response</span>) {
<span class="pl-c">// response received within 10 seconds maximum</span>
<span class="pl-en">var_dump</span>(<span class="pl-s1"><span class="pl-c1">$</span>response</span>-><span class="pl-en">getHeaders</span>());
}, <span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-smi">Exception</span></span> <span class="pl-s1"><span class="pl-c1">$</span>e</span>) {
<span class="pl-k">echo</span> <span class="pl-s">'<span class="pl-s">Error: </span>'</span> . <span class="pl-s1"><span class="pl-c1">$</span>e</span>-><span class="pl-en">getMessage</span>() . <span class="pl-c1">PHP_EOL</span>;
});</pre></div>
<p>Similarly, you can use a bool <code>false</code> to not apply a timeout at all
or use a bool <code>true</code> value to restore the default handling.
See <a href="#withtimeout"><code>withTimeout()</code></a> for more details.</p>
<p>If you're using a <a href="#streaming-response">streaming response body</a>, the time it
takes to receive the response body stream will not be included in the timeout.
This allows you to keep this incoming stream open for a longer time, such as
when downloading a very large stream or when streaming data over a long-lived
connection.</p>
<p>If you're using a <a href="#streaming-request">streaming request body</a>, the time it
takes to send the request body stream will not be included in the timeout. This
allows you to keep this outgoing stream open for a longer time, such as when
uploading a very large stream.</p>
<p>Note that this timeout handling applies to the higher-level HTTP layer. Lower
layers such as socket and DNS may also apply (different) timeout values. In
particular, the underlying socket connection uses the same <code>default_socket_timeout</code>
setting to establish the underlying transport connection. To control this
connection timeout behavior, you can <a href="#browser">inject a custom <code>Connector</code></a>
like this:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>browser</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">Browser</span>(
<span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Socket</span>\<span class="pl-v">Connector</span>(
<span class="pl-en">array</span>(
<span class="pl-s">'<span class="pl-s">timeout</span>'</span> => <span class="pl-c1">5</span>
)
)
);</pre></div>
<div class="markdown-heading"><h3 class="heading-element">Authentication</h3><a id="authentication" class="anchor" aria-label="Permalink: Authentication" href="#authentication"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>This library supports <a href="https://en.wikipedia.org/wiki/Basic_access_authentication" rel="nofollow">HTTP Basic Authentication</a>
using the <code>Authorization: Basic …</code> request header or allows you to set an explicit
<code>Authorization</code> request header.</p>
<p>By default, this library does not include an outgoing <code>Authorization</code> request
header. If the server requires authentication, if may return a <code>401</code> (Unauthorized)
status code which will reject the request by default (see also the
<a href="#withrejecterrorresponse"><code>withRejectErrorResponse()</code> method</a> below).</p>
<p>In order to pass authentication details, you can simply pass the username and
password as part of the request URL like this:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>promise</span> = <span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">get</span>(<span class="pl-s">'<span class="pl-s">https://user:pass@example.com/api</span>'</span>);</pre></div>
<p>Note that special characters in the authentication details have to be
percent-encoded, see also <a href="https://www.php.net/manual/en/function.rawurlencode.php" rel="nofollow"><code>rawurlencode()</code></a>.
This example will automatically pass the base64-encoded authentication details
using the outgoing <code>Authorization: Basic …</code> request header. If the HTTP endpoint
you're talking to requires any other authentication scheme, you can also pass
this header explicitly. This is common when using (RESTful) HTTP APIs that use
OAuth access tokens or JSON Web Tokens (JWT):</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>token</span> = <span class="pl-s">'<span class="pl-s">abc123</span>'</span>;
<span class="pl-s1"><span class="pl-c1">$</span>promise</span> = <span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">get</span>(
<span class="pl-s">'<span class="pl-s">https://example.com/api</span>'</span>,
<span class="pl-en">array</span>(
<span class="pl-s">'<span class="pl-s">Authorization</span>'</span> => <span class="pl-s">'<span class="pl-s">Bearer </span>'</span> . <span class="pl-s1"><span class="pl-c1">$</span>token</span>
)
);</pre></div>
<p>When following redirects, the <code>Authorization</code> request header will never be sent
to any remote hosts by default. When following a redirect where the <code>Location</code>
response header contains authentication details, these details will be sent for
following requests. See also <a href="#redirects">redirects</a> below.</p>
<div class="markdown-heading"><h3 class="heading-element">Redirects</h3><a id="redirects" class="anchor" aria-label="Permalink: Redirects" href="#redirects"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>By default, this library follows any redirects and obeys <code>3xx</code> (Redirection)
status codes using the <code>Location</code> response header from the remote server.
The promise will be fulfilled with the last response from the chain of redirects.</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">get</span>(<span class="pl-s1"><span class="pl-c1">$</span>url</span>, <span class="pl-s1"><span class="pl-c1">$</span>headers</span>)-><span class="pl-en">then</span>(<span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-v">Psr</span>\<span class="pl-v">Http</span>\<span class="pl-v">Message</span>\<span class="pl-smi">ResponseInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>response</span>) {
<span class="pl-c">// the final response will end up here</span>
<span class="pl-en">var_dump</span>(<span class="pl-s1"><span class="pl-c1">$</span>response</span>-><span class="pl-en">getHeaders</span>());
}, <span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-smi">Exception</span></span> <span class="pl-s1"><span class="pl-c1">$</span>e</span>) {
<span class="pl-k">echo</span> <span class="pl-s">'<span class="pl-s">Error: </span>'</span> . <span class="pl-s1"><span class="pl-c1">$</span>e</span>-><span class="pl-en">getMessage</span>() . <span class="pl-c1">PHP_EOL</span>;
});</pre></div>
<p>Any redirected requests will follow the semantics of the original request and
will include the same request headers as the original request except for those
listed below.
If the original request is a temporary (307) or a permanent (308) redirect, request
body and headers will be passed to the redirected request. Otherwise, the request
body will never be passed to the redirected request. Accordingly, each redirected
request will remove any <code>Content-Length</code> and <code>Content-Type</code> request headers.</p>
<p>If the original request used HTTP authentication with an <code>Authorization</code> request
header, this request header will only be passed as part of the redirected
request if the redirected URL is using the same host. In other words, the
<code>Authorizaton</code> request header will not be forwarded to other foreign hosts due to
possible privacy/security concerns. When following a redirect where the <code>Location</code>
response header contains authentication details, these details will be sent for
following requests.</p>
<p>You can use the <a href="#withfollowredirects"><code>withFollowRedirects()</code></a> method to
control the maximum number of redirects to follow or to return any redirect
responses as-is and apply custom redirection logic like this:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>browser</span> = <span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">withFollowRedirects</span>(<span class="pl-c1">false</span>);
<span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">get</span>(<span class="pl-s1"><span class="pl-c1">$</span>url</span>)-><span class="pl-en">then</span>(<span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-v">Psr</span>\<span class="pl-v">Http</span>\<span class="pl-v">Message</span>\<span class="pl-smi">ResponseInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>response</span>) {
<span class="pl-c">// any redirects will now end up here</span>
<span class="pl-en">var_dump</span>(<span class="pl-s1"><span class="pl-c1">$</span>response</span>-><span class="pl-en">getHeaders</span>());
}, <span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-smi">Exception</span></span> <span class="pl-s1"><span class="pl-c1">$</span>e</span>) {
<span class="pl-k">echo</span> <span class="pl-s">'<span class="pl-s">Error: </span>'</span> . <span class="pl-s1"><span class="pl-c1">$</span>e</span>-><span class="pl-en">getMessage</span>() . <span class="pl-c1">PHP_EOL</span>;
});</pre></div>
<p>See also <a href="#withfollowredirects"><code>withFollowRedirects()</code></a> for more details.</p>
<div class="markdown-heading"><h3 class="heading-element">Blocking</h3><a id="blocking" class="anchor" aria-label="Permalink: Blocking" href="#blocking"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>As stated above, this library provides you a powerful, async API by default.</p>
<p>You can also integrate this into your traditional, blocking environment by using
<a href="../async/">reactphp/async</a>. This allows you to simply
await async HTTP requests like this:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-k">use</span> <span class="pl-k">function</span> <span class="pl-v">React</span>\<span class="pl-v">Async</span>\<span class="pl-en">await</span>;
<span class="pl-s1"><span class="pl-c1">$</span>browser</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">Browser</span>();
<span class="pl-s1"><span class="pl-c1">$</span>promise</span> = <span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">get</span>(<span class="pl-s">'<span class="pl-s">http://example.com/</span>'</span>);
<span class="pl-k">try</span> {
<span class="pl-s1"><span class="pl-c1">$</span>response</span> = <span class="pl-en">await</span>(<span class="pl-s1"><span class="pl-c1">$</span>promise</span>);
<span class="pl-c">// response successfully received</span>
} <span class="pl-k">catch</span> (<span class="pl-smi"><span class="pl-smi">Exception</span></span> <span class="pl-s1"><span class="pl-c1">$</span>e</span>) {
<span class="pl-c">// an error occurred while performing the request</span>
}</pre></div>
<p>Similarly, you can also process multiple requests concurrently and await an array of <code>Response</code> objects:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-k">use</span> <span class="pl-k">function</span> <span class="pl-v">React</span>\<span class="pl-v">Async</span>\<span class="pl-en">await</span>;
<span class="pl-k">use</span> <span class="pl-k">function</span> <span class="pl-v">React</span>\<span class="pl-v">Promise</span>\<span class="pl-en">all</span>;
<span class="pl-s1"><span class="pl-c1">$</span>promises</span> = <span class="pl-en">array</span>(
<span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">get</span>(<span class="pl-s">'<span class="pl-s">http://example.com/</span>'</span>),
<span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">get</span>(<span class="pl-s">'<span class="pl-s">http://www.example.org/</span>'</span>),
);
<span class="pl-s1"><span class="pl-c1">$</span>responses</span> = <span class="pl-en">await</span>(<span class="pl-en">all</span>(<span class="pl-s1"><span class="pl-c1">$</span>promises</span>));</pre></div>
<p>This is made possible thanks to fibers available in PHP 8.1+ and our
compatibility API that also works on all supported PHP versions.
Please refer to <a href="../async/#readme">reactphp/async</a> for more details.</p>
<p>Keep in mind the above remark about buffering the whole response message in memory.
As an alternative, you may also see one of the following chapters for the
<a href="#streaming-response">streaming API</a>.</p>
<div class="markdown-heading"><h3 class="heading-element">Concurrency</h3><a id="concurrency" class="anchor" aria-label="Permalink: Concurrency" href="#concurrency"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>As stated above, this library provides you a powerful, async API. Being able to
send a large number of requests at once is one of the core features of this
project. For instance, you can easily send 100 requests concurrently while
processing SQL queries at the same time.</p>
<p>Remember, with great power comes great responsibility. Sending an excessive
number of requests may either take up all resources on your side or it may even
get you banned by the remote side if it sees an unreasonable number of requests
from your side.</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-c">// watch out if array contains many elements</span>
<span class="pl-k">foreach</span> (<span class="pl-s1"><span class="pl-c1">$</span>urls</span> <span class="pl-k">as</span> <span class="pl-s1"><span class="pl-c1">$</span>url</span>) {
<span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">get</span>(<span class="pl-s1"><span class="pl-c1">$</span>url</span>)-><span class="pl-en">then</span>(<span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-v">Psr</span>\<span class="pl-v">Http</span>\<span class="pl-v">Message</span>\<span class="pl-smi">ResponseInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>response</span>) {
<span class="pl-en">var_dump</span>(<span class="pl-s1"><span class="pl-c1">$</span>response</span>-><span class="pl-en">getHeaders</span>());
}, <span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-smi">Exception</span></span> <span class="pl-s1"><span class="pl-c1">$</span>e</span>) {
<span class="pl-k">echo</span> <span class="pl-s">'<span class="pl-s">Error: </span>'</span> . <span class="pl-s1"><span class="pl-c1">$</span>e</span>-><span class="pl-en">getMessage</span>() . <span class="pl-c1">PHP_EOL</span>;
});
}</pre></div>
<p>As a consequence, it's usually recommended to limit concurrency on the sending
side to a reasonable value. It's common to use a rather small limit, as doing
more than a dozen of things at once may easily overwhelm the receiving side. You
can use <a href="https://github.com/clue/reactphp-mq">clue/reactphp-mq</a> as a lightweight
in-memory queue to concurrently do many (but not too many) things at once:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-c">// wraps Browser in a Queue object that executes no more than 10 operations at once</span>
<span class="pl-s1"><span class="pl-c1">$</span>q</span> = <span class="pl-k">new</span> <span class="pl-v">Clue</span>\<span class="pl-v">React</span>\<span class="pl-v">Mq</span>\<span class="pl-v">Queue</span>(<span class="pl-c1">10</span>, <span class="pl-c1">null</span>, <span class="pl-k">function</span> (<span class="pl-s1"><span class="pl-c1">$</span>url</span>) <span class="pl-k">use</span> (<span class="pl-s1"><span class="pl-c1">$</span>browser</span>) {
<span class="pl-k">return</span> <span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">get</span>(<span class="pl-s1"><span class="pl-c1">$</span>url</span>);
});
<span class="pl-k">foreach</span> (<span class="pl-s1"><span class="pl-c1">$</span>urls</span> <span class="pl-k">as</span> <span class="pl-s1"><span class="pl-c1">$</span>url</span>) {
<span class="pl-s1"><span class="pl-c1">$</span>q</span>(<span class="pl-s1"><span class="pl-c1">$</span>url</span>)-><span class="pl-en">then</span>(<span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-v">Psr</span>\<span class="pl-v">Http</span>\<span class="pl-v">Message</span>\<span class="pl-smi">ResponseInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>response</span>) {
<span class="pl-en">var_dump</span>(<span class="pl-s1"><span class="pl-c1">$</span>response</span>-><span class="pl-en">getHeaders</span>());
}, <span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-smi">Exception</span></span> <span class="pl-s1"><span class="pl-c1">$</span>e</span>) {
<span class="pl-k">echo</span> <span class="pl-s">'<span class="pl-s">Error: </span>'</span> . <span class="pl-s1"><span class="pl-c1">$</span>e</span>-><span class="pl-en">getMessage</span>() . <span class="pl-c1">PHP_EOL</span>;
});
}</pre></div>
<p>Additional requests that exceed the concurrency limit will automatically be
enqueued until one of the pending requests completes. This integrates nicely
with the existing <a href="#promises">Promise-based API</a>. Please refer to
<a href="https://github.com/clue/reactphp-mq">clue/reactphp-mq</a> for more details.</p>
<p>This in-memory approach works reasonably well for some thousand outstanding
requests. If you're processing a very large input list (think millions of rows
in a CSV or NDJSON file), you may want to look into using a streaming approach
instead. See <a href="https://github.com/clue/reactphp-flux">clue/reactphp-flux</a> for
more details.</p>
<div class="markdown-heading"><h3 class="heading-element">Streaming response</h3><a id="streaming-response" class="anchor" aria-label="Permalink: Streaming response" href="#streaming-response"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>All of the above examples assume you want to store the whole response body in memory.
This is easy to get started and works reasonably well for smaller responses.</p>
<p>However, there are several situations where it's usually a better idea to use a
streaming approach, where only small chunks have to be kept in memory:</p>
<ul>
<li>If you're dealing with lots of concurrent requests (100+) or</li>
<li>If you want to process individual data chunks as they happen (without having to wait for the full response body) or</li>
<li>If you're expecting a big response body size (1 MiB or more, for example when downloading binary files) or</li>
<li>If you're unsure about the response body size (better be safe than sorry when accessing arbitrary remote HTTP endpoints and the response body size is unknown in advance).</li>
</ul>
<p>You can use the <a href="#requeststreaming"><code>requestStreaming()</code></a> method to send an
arbitrary HTTP request and receive a streaming response. It uses the same HTTP
message API, but does not buffer the response body in memory. It only processes
the response body in small chunks as data is received and forwards this data
through <a href="../stream/">ReactPHP's Stream API</a>. This works
for (any number of) responses of arbitrary sizes.</p>
<p>This means it resolves with a normal
<a href="https://www.php-fig.org/psr/psr-7/#33-psrhttpmessageresponseinterface" rel="nofollow">PSR-7 <code>ResponseInterface</code></a>,
which can be used to access the response message parameters as usual.
You can access the message body as usual, however it now also
implements <a href="../stream/#readablestreaminterface">ReactPHP's <code>ReadableStreamInterface</code></a>
as well as parts of the <a href="https://www.php-fig.org/psr/psr-7/#34-psrhttpmessagestreaminterface" rel="nofollow">PSR-7 <code>StreamInterface</code></a>.</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">requestStreaming</span>(<span class="pl-s">'<span class="pl-s">GET</span>'</span>, <span class="pl-s1"><span class="pl-c1">$</span>url</span>)-><span class="pl-en">then</span>(<span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-v">Psr</span>\<span class="pl-v">Http</span>\<span class="pl-v">Message</span>\<span class="pl-smi">ResponseInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>response</span>) {
<span class="pl-s1"><span class="pl-c1">$</span>body</span> = <span class="pl-s1"><span class="pl-c1">$</span>response</span>-><span class="pl-en">getBody</span>();
<span class="pl-en">assert</span>(<span class="pl-s1"><span class="pl-c1">$</span>body</span> <span class="pl-k">instanceof</span> <span class="pl-v">Psr</span>\<span class="pl-v">Http</span>\<span class="pl-v">Message</span>\StreamInterface);
<span class="pl-en">assert</span>(<span class="pl-s1"><span class="pl-c1">$</span>body</span> <span class="pl-k">instanceof</span> <span class="pl-v">React</span>\<span class="pl-v">Stream</span>\ReadableStreamInterface);
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">on</span>(<span class="pl-s">'<span class="pl-s">data</span>'</span>, <span class="pl-k">function</span> (<span class="pl-s1"><span class="pl-c1">$</span>chunk</span>) {
<span class="pl-k">echo</span> <span class="pl-s1"><span class="pl-c1">$</span>chunk</span>;
});
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">on</span>(<span class="pl-s">'<span class="pl-s">error</span>'</span>, <span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-smi">Exception</span></span> <span class="pl-s1"><span class="pl-c1">$</span>e</span>) {
<span class="pl-k">echo</span> <span class="pl-s">'<span class="pl-s">Error: </span>'</span> . <span class="pl-s1"><span class="pl-c1">$</span>e</span>-><span class="pl-en">getMessage</span>() . <span class="pl-c1">PHP_EOL</span>;
});
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">on</span>(<span class="pl-s">'<span class="pl-s">close</span>'</span>, <span class="pl-k">function</span> () {
<span class="pl-k">echo</span> <span class="pl-s">'<span class="pl-s">[DONE]</span>'</span> . <span class="pl-c1">PHP_EOL</span>;
});
}, <span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-smi">Exception</span></span> <span class="pl-s1"><span class="pl-c1">$</span>e</span>) {
<span class="pl-k">echo</span> <span class="pl-s">'<span class="pl-s">Error: </span>'</span> . <span class="pl-s1"><span class="pl-c1">$</span>e</span>-><span class="pl-en">getMessage</span>() . <span class="pl-c1">PHP_EOL</span>;
});</pre></div>
<p>See also the <a href="https://github.com/reactphp/http/blob/v1.11.0/examples/91-client-benchmark-download.php">stream download benchmark example</a> and
the <a href="https://github.com/reactphp/http/blob/v1.11.0/examples/21-client-request-streaming-to-stdout.php">stream forwarding example</a>.</p>
<p>You can invoke the following methods on the message body:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">on</span>(<span class="pl-s1"><span class="pl-c1">$</span>event</span>, <span class="pl-s1"><span class="pl-c1">$</span>callback</span>);
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">eof</span>();
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">isReadable</span>();
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">pipe</span>(<span class="pl-v">React</span>\<span class="pl-v">Stream</span>\<span class="pl-v">WritableStreamInterface</span> <span class="pl-s1"><span class="pl-c1">$</span>dest</span>, array <span class="pl-s1"><span class="pl-c1">$</span>options</span> = <span class="pl-en">array</span>());
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">close</span>();
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">pause</span>();
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">resume</span>();</pre></div>
<p>Because the message body is in a streaming state, invoking the following methods
doesn't make much sense:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">__toString</span>(); <span class="pl-c">// ''</span>
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">detach</span>(); <span class="pl-c">// throws BadMethodCallException</span>
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">getSize</span>(); <span class="pl-c">// null</span>
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">tell</span>(); <span class="pl-c">// throws BadMethodCallException</span>
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">isSeekable</span>(); <span class="pl-c">// false</span>
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">seek</span>(); <span class="pl-c">// throws BadMethodCallException</span>
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">rewind</span>(); <span class="pl-c">// throws BadMethodCallException</span>
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">isWritable</span>(); <span class="pl-c">// false</span>
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">write</span>(); <span class="pl-c">// throws BadMethodCallException</span>
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">read</span>(); <span class="pl-c">// throws BadMethodCallException</span>
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">getContents</span>(); <span class="pl-c">// throws BadMethodCallException</span></pre></div>
<p>Note how <a href="#timeouts">timeouts</a> apply slightly differently when using streaming.
In streaming mode, the timeout value covers creating the underlying transport
connection, sending the HTTP request, receiving the HTTP response headers and
following any eventual <a href="#redirects">redirects</a>. In particular, the timeout value
does not take receiving (possibly large) response bodies into account.</p>
<p>If you want to integrate the streaming response into a higher level API, then
working with Promise objects that resolve with Stream objects is often inconvenient.
Consider looking into also using <a href="../promise-stream/">react/promise-stream</a>.
The resulting streaming code could look something like this:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-k">use</span> <span class="pl-v">React</span>\<span class="pl-v">Promise</span>\<span class="pl-smi">Stream</span>;
<span class="pl-k">function</span> <span class="pl-en">download</span>(<span class="pl-smi"><span class="pl-smi">Browser</span></span> <span class="pl-s1"><span class="pl-c1">$</span>browser</span>, <span class="pl-smi">string</span> <span class="pl-s1"><span class="pl-c1">$</span>url</span>): <span class="pl-smi"><span class="pl-v">React</span>\<span class="pl-v">Stream</span>\<span class="pl-smi">ReadableStreamInterface</span></span> {
<span class="pl-k">return</span> <span class="pl-en"><span class="pl-v">Stream</span>\unwrapReadable</span>(
<span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">requestStreaming</span>(<span class="pl-s">'<span class="pl-s">GET</span>'</span>, <span class="pl-s1"><span class="pl-c1">$</span>url</span>)-><span class="pl-en">then</span>(<span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-v">Psr</span>\<span class="pl-v">Http</span>\<span class="pl-v">Message</span>\<span class="pl-smi">ResponseInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>response</span>) {
<span class="pl-k">return</span> <span class="pl-s1"><span class="pl-c1">$</span>response</span>-><span class="pl-en">getBody</span>();
})
);
}
<span class="pl-s1"><span class="pl-c1">$</span>stream</span> = <span class="pl-en">download</span>(<span class="pl-s1"><span class="pl-c1">$</span>browser</span>, <span class="pl-s1"><span class="pl-c1">$</span>url</span>);
<span class="pl-s1"><span class="pl-c1">$</span>stream</span>-><span class="pl-en">on</span>(<span class="pl-s">'<span class="pl-s">data</span>'</span>, <span class="pl-k">function</span> (<span class="pl-s1"><span class="pl-c1">$</span>data</span>) {
<span class="pl-k">echo</span> <span class="pl-s1"><span class="pl-c1">$</span>data</span>;
});
<span class="pl-s1"><span class="pl-c1">$</span>stream</span>-><span class="pl-en">on</span>(<span class="pl-s">'<span class="pl-s">error</span>'</span>, <span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-smi">Exception</span></span> <span class="pl-s1"><span class="pl-c1">$</span>e</span>) {
<span class="pl-k">echo</span> <span class="pl-s">'<span class="pl-s">Error: </span>'</span> . <span class="pl-s1"><span class="pl-c1">$</span>e</span>-><span class="pl-en">getMessage</span>() . <span class="pl-c1">PHP_EOL</span>;
});</pre></div>
<p>See also the <a href="#requeststreaming"><code>requestStreaming()</code></a> method for more details.</p>
<div class="markdown-heading"><h3 class="heading-element">Streaming request</h3><a id="streaming-request" class="anchor" aria-label="Permalink: Streaming request" href="#streaming-request"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>Besides streaming the response body, you can also stream the request body.
This can be useful if you want to send big POST requests (uploading files etc.)
or process many outgoing streams at once.
Instead of passing the body as a string, you can simply pass an instance
implementing <a href="../stream/#readablestreaminterface">ReactPHP's <code>ReadableStreamInterface</code></a>
to the <a href="#request-methods">request methods</a> like this:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">post</span>(<span class="pl-s1"><span class="pl-c1">$</span>url</span>, <span class="pl-en">array</span>(), <span class="pl-s1"><span class="pl-c1">$</span>stream</span>)-><span class="pl-en">then</span>(<span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-v">Psr</span>\<span class="pl-v">Http</span>\<span class="pl-v">Message</span>\<span class="pl-smi">ResponseInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>response</span>) {
<span class="pl-k">echo</span> <span class="pl-s">'<span class="pl-s">Successfully sent.</span>'</span>;
}, <span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-smi">Exception</span></span> <span class="pl-s1"><span class="pl-c1">$</span>e</span>) {
<span class="pl-k">echo</span> <span class="pl-s">'<span class="pl-s">Error: </span>'</span> . <span class="pl-s1"><span class="pl-c1">$</span>e</span>-><span class="pl-en">getMessage</span>() . <span class="pl-c1">PHP_EOL</span>;
});</pre></div>
<p>If you're using a streaming request body (<code>React\Stream\ReadableStreamInterface</code>), it will
default to using <code>Transfer-Encoding: chunked</code> or you have to explicitly pass in a
matching <code>Content-Length</code> request header like so:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>body</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Stream</span>\<span class="pl-v">ThroughStream</span>();
Loop::<span class="pl-en">addTimer</span>(<span class="pl-c1">1.0</span>, <span class="pl-k">function</span> () <span class="pl-k">use</span> (<span class="pl-s1"><span class="pl-c1">$</span>body</span>) {
<span class="pl-s1"><span class="pl-c1">$</span>body</span>-><span class="pl-en">end</span>(<span class="pl-s">"<span class="pl-s">hello world</span>"</span>);
});
<span class="pl-s1"><span class="pl-c1">$</span>browser</span>-><span class="pl-en">post</span>(<span class="pl-s1"><span class="pl-c1">$</span>url</span>, <span class="pl-en">array</span>(<span class="pl-s">'<span class="pl-s">Content-Length</span>'</span> => <span class="pl-s">'<span class="pl-s">11</span>'</span>), <span class="pl-s1"><span class="pl-c1">$</span>body</span>);</pre></div>
<p>If the streaming request body emits an <code>error</code> event or is explicitly closed
without emitting a successful <code>end</code> event first, the request will automatically
be closed and rejected.</p>
<div class="markdown-heading"><h3 class="heading-element">HTTP proxy</h3><a id="http-proxy" class="anchor" aria-label="Permalink: HTTP proxy" href="#http-proxy"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>You can also establish your outgoing connections through an HTTP CONNECT proxy server
by adding a dependency to <a href="https://github.com/clue/reactphp-http-proxy">clue/reactphp-http-proxy</a>.</p>
<p>HTTP CONNECT proxy servers (also commonly known as "HTTPS proxy" or "SSL proxy")
are commonly used to tunnel HTTPS traffic through an intermediary ("proxy"), to
conceal the origin address (anonymity) or to circumvent address blocking
(geoblocking). While many (public) HTTP CONNECT proxy servers often limit this
to HTTPS port <code>443</code> only, this can technically be used to tunnel any TCP/IP-based
protocol, such as plain HTTP and TLS-encrypted HTTPS.</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>proxy</span> = <span class="pl-k">new</span> <span class="pl-v">Clue</span>\<span class="pl-v">React</span>\<span class="pl-v">HttpProxy</span>\<span class="pl-v">ProxyConnector</span>(<span class="pl-s">'<span class="pl-s">127.0.0.1:8080</span>'</span>);
<span class="pl-s1"><span class="pl-c1">$</span>connector</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Socket</span>\<span class="pl-v">Connector</span>(<span class="pl-en">array</span>(
<span class="pl-s">'<span class="pl-s">tcp</span>'</span> => <span class="pl-s1"><span class="pl-c1">$</span>proxy</span>,
<span class="pl-s">'<span class="pl-s">dns</span>'</span> => <span class="pl-c1">false</span>
));
<span class="pl-s1"><span class="pl-c1">$</span>browser</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">Browser</span>(<span class="pl-s1"><span class="pl-c1">$</span>connector</span>);</pre></div>
<p>See also the <a href="https://github.com/reactphp/http/blob/v1.11.0/examples/11-client-http-proxy.php">HTTP proxy example</a>.</p>
<div class="markdown-heading"><h3 class="heading-element">SOCKS proxy</h3><a id="socks-proxy" class="anchor" aria-label="Permalink: SOCKS proxy" href="#socks-proxy"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>You can also establish your outgoing connections through a SOCKS proxy server
by adding a dependency to <a href="https://github.com/clue/reactphp-socks">clue/reactphp-socks</a>.</p>
<p>The SOCKS proxy protocol family (SOCKS5, SOCKS4 and SOCKS4a) is commonly used to
tunnel HTTP(S) traffic through an intermediary ("proxy"), to conceal the origin
address (anonymity) or to circumvent address blocking (geoblocking). While many
(public) SOCKS proxy servers often limit this to HTTP(S) port <code>80</code> and <code>443</code>
only, this can technically be used to tunnel any TCP/IP-based protocol.</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>proxy</span> = <span class="pl-k">new</span> <span class="pl-v">Clue</span>\<span class="pl-v">React</span>\<span class="pl-v">Socks</span>\<span class="pl-v">Client</span>(<span class="pl-s">'<span class="pl-s">127.0.0.1:1080</span>'</span>);
<span class="pl-s1"><span class="pl-c1">$</span>connector</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Socket</span>\<span class="pl-v">Connector</span>(<span class="pl-en">array</span>(
<span class="pl-s">'<span class="pl-s">tcp</span>'</span> => <span class="pl-s1"><span class="pl-c1">$</span>proxy</span>,
<span class="pl-s">'<span class="pl-s">dns</span>'</span> => <span class="pl-c1">false</span>
));
<span class="pl-s1"><span class="pl-c1">$</span>browser</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">Browser</span>(<span class="pl-s1"><span class="pl-c1">$</span>connector</span>);</pre></div>
<p>See also the <a href="https://github.com/reactphp/http/blob/v1.11.0/examples/12-client-socks-proxy.php">SOCKS proxy example</a>.</p>
<div class="markdown-heading"><h3 class="heading-element">SSH proxy</h3><a id="ssh-proxy" class="anchor" aria-label="Permalink: SSH proxy" href="#ssh-proxy"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>You can also establish your outgoing connections through an SSH server
by adding a dependency to <a href="https://github.com/clue/reactphp-ssh-proxy">clue/reactphp-ssh-proxy</a>.</p>
<p><a href="https://en.wikipedia.org/wiki/Secure_Shell" rel="nofollow">Secure Shell (SSH)</a> is a secure
network protocol that is most commonly used to access a login shell on a remote
server. Its architecture allows it to use multiple secure channels over a single
connection. Among others, this can also be used to create an "SSH tunnel", which
is commonly used to tunnel HTTP(S) traffic through an intermediary ("proxy"), to
conceal the origin address (anonymity) or to circumvent address blocking
(geoblocking). This can be used to tunnel any TCP/IP-based protocol (HTTP, SMTP,
IMAP etc.), allows you to access local services that are otherwise not accessible
from the outside (database behind firewall) and as such can also be used for
plain HTTP and TLS-encrypted HTTPS.</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>proxy</span> = <span class="pl-k">new</span> <span class="pl-v">Clue</span>\<span class="pl-v">React</span>\<span class="pl-v">SshProxy</span>\<span class="pl-v">SshSocksConnector</span>(<span class="pl-s">'<span class="pl-s">alice@example.com</span>'</span>);
<span class="pl-s1"><span class="pl-c1">$</span>connector</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Socket</span>\<span class="pl-v">Connector</span>(<span class="pl-en">array</span>(
<span class="pl-s">'<span class="pl-s">tcp</span>'</span> => <span class="pl-s1"><span class="pl-c1">$</span>proxy</span>,
<span class="pl-s">'<span class="pl-s">dns</span>'</span> => <span class="pl-c1">false</span>
));
<span class="pl-s1"><span class="pl-c1">$</span>browser</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">Browser</span>(<span class="pl-s1"><span class="pl-c1">$</span>connector</span>);</pre></div>
<p>See also the <a href="https://github.com/reactphp/http/blob/v1.11.0/examples/13-client-ssh-proxy.php">SSH proxy example</a>.</p>
<div class="markdown-heading"><h3 class="heading-element">Unix domain sockets</h3><a id="unix-domain-sockets" class="anchor" aria-label="Permalink: Unix domain sockets" href="#unix-domain-sockets"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>By default, this library supports transport over plaintext TCP/IP and secure
TLS connections for the <code>http://</code> and <code>https://</code> URL schemes respectively.
This library also supports Unix domain sockets (UDS) when explicitly configured.</p>
<p>In order to use a UDS path, you have to explicitly configure the connector to
override the destination URL so that the hostname given in the request URL will
no longer be used to establish the connection:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>connector</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Socket</span>\<span class="pl-v">FixedUriConnector</span>(
<span class="pl-s">'<span class="pl-s">unix:///var/run/docker.sock</span>'</span>,
<span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Socket</span>\<span class="pl-v">UnixConnector</span>()
);
<span class="pl-s1"><span class="pl-c1">$</span>browser</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">Browser</span>(<span class="pl-s1"><span class="pl-c1">$</span>connector</span>);
<span class="pl-s1"><span class="pl-c1">$</span>client</span>-><span class="pl-en">get</span>(<span class="pl-s">'<span class="pl-s">http://localhost/info</span>'</span>)-><span class="pl-en">then</span>(<span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-v">Psr</span>\<span class="pl-v">Http</span>\<span class="pl-v">Message</span>\<span class="pl-smi">ResponseInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>response</span>) {
<span class="pl-en">var_dump</span>(<span class="pl-s1"><span class="pl-c1">$</span>response</span>-><span class="pl-en">getHeaders</span>(), (<span class="pl-smi">string</span>)<span class="pl-s1"><span class="pl-c1">$</span>response</span>-><span class="pl-en">getBody</span>());
}, <span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-smi">Exception</span></span> <span class="pl-s1"><span class="pl-c1">$</span>e</span>) {
<span class="pl-k">echo</span> <span class="pl-s">'<span class="pl-s">Error: </span>'</span> . <span class="pl-s1"><span class="pl-c1">$</span>e</span>-><span class="pl-en">getMessage</span>() . <span class="pl-c1">PHP_EOL</span>;
});</pre></div>
<p>See also the <a href="https://github.com/reactphp/http/blob/v1.11.0/examples/14-client-unix-domain-sockets.php">Unix Domain Sockets (UDS) example</a>.</p>
<div class="markdown-heading"><h2 class="heading-element">Server Usage</h2><a id="server-usage" class="anchor" aria-label="Permalink: Server Usage" href="#server-usage"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<div class="markdown-heading"><h3 class="heading-element">HttpServer</h3><a id="httpserver" class="anchor" aria-label="Permalink: HttpServer" href="#httpserver"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p><a id="server"></a> </p>
<p>The <code>React\Http\HttpServer</code> class is responsible for handling incoming connections and then
processing each incoming HTTP request.</p>
<p>When a complete HTTP request has been received, it will invoke the given
request handler function. This request handler function needs to be passed to
the constructor and will be invoked with the respective <a href="#server-request">request</a>
object and expects a <a href="#server-response">response</a> object in return:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>http</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">HttpServer</span>(<span class="pl-k">function</span> (<span class="pl-smi"><span class="pl-v">Psr</span>\<span class="pl-v">Http</span>\<span class="pl-v">Message</span>\<span class="pl-smi">ServerRequestInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>request</span>) {
<span class="pl-k">return</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">Message</span>\Response::<span class="pl-en">plaintext</span>(
<span class="pl-s">"<span class="pl-s">Hello World!</span>\n"</span>
);
});</pre></div>
<p>Each incoming HTTP request message is always represented by the
<a href="https://www.php-fig.org/psr/psr-7/#321-psrhttpmessageserverrequestinterface" rel="nofollow">PSR-7 <code>ServerRequestInterface</code></a>,
see also following <a href="#server-request">request</a> chapter for more details.</p>
<p>Each outgoing HTTP response message is always represented by the
<a href="https://www.php-fig.org/psr/psr-7/#33-psrhttpmessageresponseinterface" rel="nofollow">PSR-7 <code>ResponseInterface</code></a>,
see also following <a href="#server-response">response</a> chapter for more details.</p>
<p>This class takes an optional <code>LoopInterface|null $loop</code> parameter that can be used to
pass the event loop instance to use for this object. You can use a <code>null</code> value
here in order to use the <a href="../event-loop/#loop">default loop</a>.
This value SHOULD NOT be given unless you're sure you want to explicitly use a
given event loop instance.</p>
<p>In order to start listening for any incoming connections, the <code>HttpServer</code> needs
to be attached to an instance of
<a href="../socket/#serverinterface"><code>React\Socket\ServerInterface</code></a>
through the <a href="#listen"><code>listen()</code></a> method as described in the following
chapter. In its most simple form, you can attach this to a
<a href="../socket/#socketserver"><code>React\Socket\SocketServer</code></a>
in order to start a plaintext HTTP server like this:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>http</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">HttpServer</span>(<span class="pl-s1"><span class="pl-c1">$</span>handler</span>);
<span class="pl-s1"><span class="pl-c1">$</span>socket</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Socket</span>\<span class="pl-v">SocketServer</span>(<span class="pl-s">'<span class="pl-s">0.0.0.0:8080</span>'</span>);
<span class="pl-s1"><span class="pl-c1">$</span>http</span>-><span class="pl-en">listen</span>(<span class="pl-s1"><span class="pl-c1">$</span>socket</span>);</pre></div>
<p>See also the <a href="#listen"><code>listen()</code></a> method and the
<a href="https://github.com/reactphp/http/blob/v1.11.0/examples/51-server-hello-world.php">hello world server example</a>
for more details.</p>
<p>By default, the <code>HttpServer</code> buffers and parses the complete incoming HTTP
request in memory. It will invoke the given request handler function when the
complete request headers and request body has been received. This means the
<a href="#server-request">request</a> object passed to your request handler function will be
fully compatible with PSR-7 (http-message). This provides sane defaults for
80% of the use cases and is the recommended way to use this library unless
you're sure you know what you're doing.</p>
<p>On the other hand, buffering complete HTTP requests in memory until they can
be processed by your request handler function means that this class has to
employ a number of limits to avoid consuming too much memory. In order to
take the more advanced configuration out your hand, it respects setting from
your <a href="https://www.php.net/manual/en/ini.core.php" rel="nofollow"><code>php.ini</code></a> to apply its
default settings. This is a list of PHP settings this class respects with
their respective default values:</p>
<pre><code>memory_limit 128M
post_max_size 8M // capped at 64K
enable_post_data_reading 1
max_input_nesting_level 64
max_input_vars 1000
file_uploads 1
upload_max_filesize 2M
max_file_uploads 20
</code></pre>
<p>In particular, the <code>post_max_size</code> setting limits how much memory a single
HTTP request is allowed to consume while buffering its request body. This
needs to be limited because the server can process a large number of requests
concurrently, so the server may potentially consume a large amount of memory
otherwise. To support higher concurrency by default, this value is capped
at <code>64K</code>. If you assign a higher value, it will only allow <code>64K</code> by default.
If a request exceeds this limit, its request body will be ignored and it will
be processed like a request with no request body at all. See below for
explicit configuration to override this setting.</p>
<p>By default, this class will try to avoid consuming more than half of your
<code>memory_limit</code> for buffering multiple concurrent HTTP requests. As such, with
the above default settings of <code>128M</code> max, it will try to consume no more than
<code>64M</code> for buffering multiple concurrent HTTP requests. As a consequence, it
will limit the concurrency to <code>1024</code> HTTP requests with the above defaults.</p>
<p>It is imperative that you assign reasonable values to your PHP ini settings.
It is usually recommended to not support buffering incoming HTTP requests
with a large HTTP request body (e.g. large file uploads). If you want to
increase this buffer size, you will have to also increase the total memory
limit to allow for more concurrent requests (set <code>memory_limit 512M</code> or more)
or explicitly limit concurrency.</p>
<p>In order to override the above buffering defaults, you can configure the
<code>HttpServer</code> explicitly. You can use the
<a href="#limitconcurrentrequestsmiddleware"><code>LimitConcurrentRequestsMiddleware</code></a> and
<a href="#requestbodybuffermiddleware"><code>RequestBodyBufferMiddleware</code></a> (see below)
to explicitly configure the total number of requests that can be handled at
once like this:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>http</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">HttpServer</span>(
<span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">Middleware</span>\<span class="pl-v">StreamingRequestMiddleware</span>(),
<span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">Middleware</span>\<span class="pl-v">LimitConcurrentRequestsMiddleware</span>(<span class="pl-c1">100</span>), <span class="pl-c">// 100 concurrent buffering handlers</span>
<span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">Middleware</span>\<span class="pl-v">RequestBodyBufferMiddleware</span>(<span class="pl-c1">2</span> * <span class="pl-c1">1024</span> * <span class="pl-c1">1024</span>), <span class="pl-c">// 2 MiB per request</span>
<span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">Middleware</span>\<span class="pl-v">RequestBodyParserMiddleware</span>(),
<span class="pl-s1"><span class="pl-c1">$</span>handler</span>
);</pre></div>
<p>In this example, we allow processing up to 100 concurrent requests at once
and each request can buffer up to <code>2M</code>. This means you may have to keep a
maximum of <code>200M</code> of memory for incoming request body buffers. Accordingly,
you need to adjust the <code>memory_limit</code> ini setting to allow for these buffers
plus your actual application logic memory requirements (think <code>512M</code> or more).</p>
<blockquote>
<p>Internally, this class automatically assigns these middleware handlers
automatically when no <a href="#streamingrequestmiddleware"><code>StreamingRequestMiddleware</code></a>
is given. Accordingly, you can use this example to override all default
settings to implement custom limits.</p>
</blockquote>
<p>As an alternative to buffering the complete request body in memory, you can
also use a streaming approach where only small chunks of data have to be kept
in memory:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>http</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">HttpServer</span>(
<span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">Middleware</span>\<span class="pl-v">StreamingRequestMiddleware</span>(),
<span class="pl-s1"><span class="pl-c1">$</span>handler</span>
);</pre></div>
<p>In this case, it will invoke the request handler function once the HTTP
request headers have been received, i.e. before receiving the potentially
much larger HTTP request body. This means the <a href="#server-request">request</a> passed to
your request handler function may not be fully compatible with PSR-7. This is
specifically designed to help with more advanced use cases where you want to
have full control over consuming the incoming HTTP request body and
concurrency settings. See also <a href="#streaming-incoming-request">streaming incoming request</a>
below for more details.</p>
<blockquote>
<p>Changelog v1.5.0: This class has been renamed to <code>HttpServer</code> from the
previous <code>Server</code> class in order to avoid any ambiguities.
The previous name has been deprecated and should not be used anymore.</p>
</blockquote>
<div class="markdown-heading"><h3 class="heading-element">listen()</h3><a id="listen" class="anchor" aria-label="Permalink: listen()" href="#listen"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>
<p>The <code>listen(React\Socket\ServerInterface $socket): void</code> method can be used to
start listening for HTTP requests on the given socket server instance.</p>
<p>The given <a href="../socket/#serverinterface"><code>React\Socket\ServerInterface</code></a>
is responsible for emitting the underlying streaming connections. This
HTTP server needs to be attached to it in order to process any
connections and pase incoming streaming data as incoming HTTP request
messages. In its most common form, you can attach this to a
<a href="../socket/#socketserver"><code>React\Socket\SocketServer</code></a>
in order to start a plaintext HTTP server like this:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>http</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">HttpServer</span>(<span class="pl-s1"><span class="pl-c1">$</span>handler</span>);
<span class="pl-s1"><span class="pl-c1">$</span>socket</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Socket</span>\<span class="pl-v">SocketServer</span>(<span class="pl-s">'<span class="pl-s">0.0.0.0:8080</span>'</span>);
<span class="pl-s1"><span class="pl-c1">$</span>http</span>-><span class="pl-en">listen</span>(<span class="pl-s1"><span class="pl-c1">$</span>socket</span>);</pre></div>
<p>See also <a href="https://github.com/reactphp/http/blob/v1.11.0/examples/51-server-hello-world.php">hello world server example</a>
for more details.</p>
<p>This example will start listening for HTTP requests on the alternative
HTTP port <code>8080</code> on all interfaces (publicly). As an alternative, it is
very common to use a reverse proxy and let this HTTP server listen on the
localhost (loopback) interface only by using the listen address
<code>127.0.0.1:8080</code> instead. This way, you host your application(s) on the
default HTTP port <code>80</code> and only route specific requests to this HTTP
server.</p>
<p>Likewise, it's usually recommended to use a reverse proxy setup to accept
secure HTTPS requests on default HTTPS port <code>443</code> (TLS termination) and
only route plaintext requests to this HTTP server. As an alternative, you
can also accept secure HTTPS requests with this HTTP server by attaching
this to a <a href="../socket/#socketserver"><code>React\Socket\SocketServer</code></a>
using a secure TLS listen address, a certificate file and optional
<code>passphrase</code> like this:</p>
<div class="highlight highlight-text-html-php"><pre><span class="pl-s1"><span class="pl-c1">$</span>http</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Http</span>\<span class="pl-v">HttpServer</span>(<span class="pl-s1"><span class="pl-c1">$</span>handler</span>);
<span class="pl-s1"><span class="pl-c1">$</span>socket</span> = <span class="pl-k">new</span> <span class="pl-v">React</span>\<span class="pl-v">Socket</span>\<span class="pl-v">SocketServer</span>(<span class="pl-s">'<span class="pl-s">tls://0.0.0.0:8443</span>'</span>, <span class="pl-en">array</span>(
<span class="pl-s">'<span class="pl-s">tls</span>'</span> => <span class="pl-en">array</span>(
<span class="pl-s">'<span class="pl-s">local_cert</span>'</span> => <span class="pl-c1">__DIR__</span> . <span class="pl-s">'<span class="pl-s">/localhost.pem</span>'</span>
)
));
<span class="pl-s1"><span class="pl-c1">$</span>http</span>-><span class="pl-en">listen</span>(<span class="pl-s1"><span class="pl-c1">$</span>socket</span>);</pre></div>
<p>See also <a href="https://github.com/reactphp/http/blob/v1.11.0/examples/61-server-hello-world-https.php">hello world HTTPS example</a>
for more details.</p>
<div class="markdown-heading"><h3 class="heading-element">Server Request</h3><a id="server-request" class="anchor" aria-label="Permalink: Server Request" href="#server-request"><span aria-hidden="true" class="octicon octicon-link"></span></a></div>