summaryrefslogtreecommitdiffstats
path: root/archives/extend/2013-October.txt
blob: 4a9176a4a9daa0b3706833fcfcdbfe4a2b644ec7 (plain) (blame)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
From marcel.meyer at gmail.com  Thu Oct  3 07:00:28 2013
From: marcel.meyer at gmail.com (Marcel Meyer)
Date: Wed, 2 Oct 2013 22:00:28 -0700
Subject: [99s-extend] websocket_info and RPC
Message-ID: <CAFXVr=ZuQNiChQGFHVcS4jGOHXG5NEazbZcP8qp5E91smJEN1A@mail.gmail.com>

Hi there,

How do I use the websocket infrastructure of cowboy to implement RPC?
It seems like I can talk to the client using websocket_info, but the
response comes in on websocket_handle, all asynchronously.

Kind regards,
Marcel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131002/4463e3fa/attachment.html>

From ryankbrown at gmail.com  Tue Oct  8 05:55:57 2013
From: ryankbrown at gmail.com (Ryan Brown)
Date: Mon, 7 Oct 2013 21:55:57 -0600
Subject: [99s-extend] Problem with cowboy ssl example
Message-ID: <CAChGYf-ykW7HRb6Hoy6h1NHxmUrbfZ+NBsubvrW-pMieFhESkg@mail.gmail.com>

I was trying to compile and run the ssl_hello_world example in the cowboy
project and am getting the following error at start-up:

=INFO REPORT==== 7-Oct-2013::21:38:01 ===    application: ssl_hello_world
  exited: {bad_return,             {{ssl_hello_world_app,start,[normal,[]]},
            {'EXIT',               {{badmatch,                 {error,
            {{shutdown,
{failed_to_start_child,ranch_acceptors_sup,
 {{case_clause,                       {error,{"no such file or
directory","asn1.app"}}},
[{ranch,require,1,[{file,"src/ranch.erl"},{line,207}]},

I can start asn1 from the erl console so I am not sure what I am missing.
Any help is greatly appreciated.

Best regards.

-- 
-rb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131007/fdef2170/attachment.html>

From essen at ninenines.eu  Tue Oct  8 06:13:04 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Tue, 08 Oct 2013 06:13:04 +0200
Subject: [99s-extend] Problem with cowboy ssl example
In-Reply-To: <CAChGYf-ykW7HRb6Hoy6h1NHxmUrbfZ+NBsubvrW-pMieFhESkg@mail.gmail.com>
References: <CAChGYf-ykW7HRb6Hoy6h1NHxmUrbfZ+NBsubvrW-pMieFhESkg@mail.gmail.com>
Message-ID: <[email protected]>

I'm guessing you run an older Erlang which had that issue. Either 
upgrade Erlang or add asn1 to the list of apps to include in the release 
(and open a ticket for it please so it can be made to work with older 
versions).

On 10/08/2013 05:55 AM, Ryan Brown wrote:
> I was trying to compile and run the ssl_hello_world example in the
> cowboy project and am getting the following error at start-up:
>
>
>   =INFO REPORT==== 7-Oct-2013::21:38:01 ===
>
>
>        application: ssl_hello_world
>
>
>        exited: {bad_return,
>
>
>                 {{ssl_hello_world_app,start,[normal,[]]},
>
>
>                  {'EXIT',
>
>
>                   {{badmatch,
>
>
>                     {error,
>
>
>                      {{shutdown,
>
>
>                        {failed_to_start_child,ranch_acceptors_sup,
>
>
>                         {{case_clause,
>
>
>                           {error,{"no such file or directory","asn1.app"}}},
>
>
>
>   [{ranch,require,1,[{file,"src/ranch.erl"},{line,207}]},
>
>
> I can start asn1 from the erl console so I am not sure what I am
> missing. Any help is greatly appreciated.
>
> Best regards.
>
> --
> -rb
>
>
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From ryankbrown at gmail.com  Tue Oct  8 06:24:54 2013
From: ryankbrown at gmail.com (Ryan Brown)
Date: Mon, 7 Oct 2013 22:24:54 -0600
Subject: [99s-extend] Problem with cowboy ssl example
In-Reply-To: <[email protected]>
References: <CAChGYf-ykW7HRb6Hoy6h1NHxmUrbfZ+NBsubvrW-pMieFhESkg@mail.gmail.com>
 <[email protected]>
Message-ID: <CAChGYf-krBbQYAkxMuGt-byPV6PSC-50yrOgBMqUJrQBUZeKcA@mail.gmail.com>

Thanks Lo?c. I am actually running R16B on a macbook OS X 10.8. (I'm
wondering if the Od could have any effect?)

Best,

Ryan


On Mon, Oct 7, 2013 at 10:13 PM, Lo?c Hoguin <essen at ninenines.eu> wrote:

> I'm guessing you run an older Erlang which had that issue. Either upgrade
> Erlang or add asn1 to the list of apps to include in the release (and open
> a ticket for it please so it can be made to work with older versions).
>
>
> On 10/08/2013 05:55 AM, Ryan Brown wrote:
>
>> I was trying to compile and run the ssl_hello_world example in the
>> cowboy project and am getting the following error at start-up:
>>
>>
>>   =INFO REPORT==== 7-Oct-2013::21:38:01 ===
>>
>>
>>        application: ssl_hello_world
>>
>>
>>        exited: {bad_return,
>>
>>
>>                 {{ssl_hello_world_app,start,[**normal,[]]},
>>
>>
>>                  {'EXIT',
>>
>>
>>                   {{badmatch,
>>
>>
>>                     {error,
>>
>>
>>                      {{shutdown,
>>
>>
>>                        {failed_to_start_child,ranch_**acceptors_sup,
>>
>>
>>                         {{case_clause,
>>
>>
>>                           {error,{"no such file or
>> directory","asn1.app"}}},
>>
>>
>>
>>   [{ranch,require,1,[{file,"src/**ranch.erl"},{line,207}]},
>>
>>
>> I can start asn1 from the erl console so I am not sure what I am
>> missing. Any help is greatly appreciated.
>>
>> Best regards.
>>
>> --
>> -rb
>>
>>
>> ______________________________**_________________
>> Extend mailing list
>> Extend at lists.ninenines.eu
>> http://lists.ninenines.eu:81/**listinfo/extend<http://lists.ninenines.eu:81/listinfo/extend>
>>
>>
>
> --
> Lo?c Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu
>



-- 
-rb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131007/863e7358/attachment.html>

From ryankbrown at gmail.com  Tue Oct  8 17:33:36 2013
From: ryankbrown at gmail.com (Ryan Brown)
Date: Tue, 8 Oct 2013 09:33:36 -0600
Subject: [99s-extend] Problem with cowboy ssl example
In-Reply-To: <CAChGYf-krBbQYAkxMuGt-byPV6PSC-50yrOgBMqUJrQBUZeKcA@mail.gmail.com>
References: <CAChGYf-ykW7HRb6Hoy6h1NHxmUrbfZ+NBsubvrW-pMieFhESkg@mail.gmail.com>
 <[email protected]>
 <CAChGYf-krBbQYAkxMuGt-byPV6PSC-50yrOgBMqUJrQBUZeKcA@mail.gmail.com>
Message-ID: <CAChGYf95Zp7gwj3dxtcw1vU-9wWce6PwA2Z2KJjCPU3jan43eA@mail.gmail.com>

Just to complete the loop. As would be expected, adding asn1 to the app.src
applications fixes the issue.

Thank you,

Ryan


On Mon, Oct 7, 2013 at 10:24 PM, Ryan Brown <ryankbrown at gmail.com> wrote:

> Thanks Lo?c. I am actually running R16B on a macbook OS X 10.8. (I'm
> wondering if the Od could have any effect?)
>
> Best,
>
> Ryan
>
>
> On Mon, Oct 7, 2013 at 10:13 PM, Lo?c Hoguin <essen at ninenines.eu> wrote:
>
>> I'm guessing you run an older Erlang which had that issue. Either upgrade
>> Erlang or add asn1 to the list of apps to include in the release (and open
>> a ticket for it please so it can be made to work with older versions).
>>
>>
>> On 10/08/2013 05:55 AM, Ryan Brown wrote:
>>
>>> I was trying to compile and run the ssl_hello_world example in the
>>> cowboy project and am getting the following error at start-up:
>>>
>>>
>>>   =INFO REPORT==== 7-Oct-2013::21:38:01 ===
>>>
>>>
>>>        application: ssl_hello_world
>>>
>>>
>>>        exited: {bad_return,
>>>
>>>
>>>                 {{ssl_hello_world_app,start,[**normal,[]]},
>>>
>>>
>>>                  {'EXIT',
>>>
>>>
>>>                   {{badmatch,
>>>
>>>
>>>                     {error,
>>>
>>>
>>>                      {{shutdown,
>>>
>>>
>>>                        {failed_to_start_child,ranch_**acceptors_sup,
>>>
>>>
>>>                         {{case_clause,
>>>
>>>
>>>                           {error,{"no such file or
>>> directory","asn1.app"}}},
>>>
>>>
>>>
>>>   [{ranch,require,1,[{file,"src/**ranch.erl"},{line,207}]},
>>>
>>>
>>> I can start asn1 from the erl console so I am not sure what I am
>>> missing. Any help is greatly appreciated.
>>>
>>> Best regards.
>>>
>>> --
>>> -rb
>>>
>>>
>>> ______________________________**_________________
>>> Extend mailing list
>>> Extend at lists.ninenines.eu
>>> http://lists.ninenines.eu:81/**listinfo/extend<http://lists.ninenines.eu:81/listinfo/extend>
>>>
>>>
>>
>> --
>> Lo?c Hoguin
>> Erlang Cowboy
>> Nine Nines
>> http://ninenines.eu
>>
>
>
>
> --
> -rb
>



-- 
-rb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131008/8752fdd7/attachment.html>

From lee.sylvester at gmail.com  Wed Oct  9 15:27:25 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Wed, 9 Oct 2013 14:27:25 +0100
Subject: [99s-extend] Cowboy Calling Hostname
Message-ID: <[email protected]>

Hi,

When receiving a Cowboy request, is there a way to find out which hostname the user made the request from?  I'm using CORS in my REST and Bullet app, where each call can be made through a given account.  However, I'd like to be able to lock requests for each account to a designated hostname to protect that users account usage.

Thanks,
Lee



From essen at ninenines.eu  Wed Oct  9 15:31:04 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Wed, 09 Oct 2013 15:31:04 +0200
Subject: [99s-extend] Cowboy Calling Hostname
In-Reply-To: <[email protected]>
References: <[email protected]>
Message-ID: <[email protected]>

cowboy_req:host/1?

Please use the nice manual we have now.

   http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_req

On 10/09/2013 03:27 PM, Lee Sylvester wrote:
> Hi,
>
> When receiving a Cowboy request, is there a way to find out which hostname the user made the request from?  I'm using CORS in my REST and Bullet app, where each call can be made through a given account.  However, I'd like to be able to lock requests for each account to a designated hostname to protect that users account usage.
>
> Thanks,
> Lee
>
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From lee.sylvester at gmail.com  Wed Oct  9 17:30:21 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Wed, 9 Oct 2013 16:30:21 +0100
Subject: [99s-extend] Cowboy Calling Hostname
In-Reply-To: <[email protected]>
References: <[email protected]>
 <[email protected]>
Message-ID: <[email protected]>

Thank you.  I couldn't work out if that's the host being called from or the host name in the request.  For example, a store called things.com makes a request to my service on widgets.net.  I need to see that the request is made FROM things.com for validation purposes. Is it correct that host will provide this?

Thanks,
Lee

Sent from my iPhone

> On Oct 9, 2013, at 2:31 PM, Lo?c Hoguin <essen at ninenines.eu> wrote:
> 
> cowboy_req:host/1?
> 
> Please use the nice manual we have now.
> 
>  http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_req
> 
>> On 10/09/2013 03:27 PM, Lee Sylvester wrote:
>> Hi,
>> 
>> When receiving a Cowboy request, is there a way to find out which hostname the user made the request from?  I'm using CORS in my REST and Bullet app, where each call can be made through a given account.  However, I'd like to be able to lock requests for each account to a designated hostname to protect that users account usage.
>> 
>> Thanks,
>> Lee
>> 
>> _______________________________________________
>> Extend mailing list
>> Extend at lists.ninenines.eu
>> http://lists.ninenines.eu:81/listinfo/extend
> 
> 
> -- 
> Lo?c Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu


From essen at ninenines.eu  Wed Oct  9 17:32:54 2013
From: essen at ninenines.eu (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=)
Date: Wed, 09 Oct 2013 17:32:54 +0200
Subject: [99s-extend] Cowboy Calling Hostname
In-Reply-To: <[email protected]>
References: <[email protected]>
 <[email protected]>
 <[email protected]>
Message-ID: <[email protected]>

In short: you can't.

Browsers may send origin/referer/.. headers depending on the type of 
request, but you can't rely on them to be real or even just there.

On 10/09/2013 05:30 PM, Lee Sylvester wrote:
> Thank you.  I couldn't work out if that's the host being called from or the host name in the request.  For example, a store called things.com makes a request to my service on widgets.net.  I need to see that the request is made FROM things.com for validation purposes. Is it correct that host will provide this?
>
> Thanks,
> Lee
>
> Sent from my iPhone
>
>> On Oct 9, 2013, at 2:31 PM, Lo?c Hoguin <essen at ninenines.eu> wrote:
>>
>> cowboy_req:host/1?
>>
>> Please use the nice manual we have now.
>>
>>   http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_req
>>
>>> On 10/09/2013 03:27 PM, Lee Sylvester wrote:
>>> Hi,
>>>
>>> When receiving a Cowboy request, is there a way to find out which hostname the user made the request from?  I'm using CORS in my REST and Bullet app, where each call can be made through a given account.  However, I'd like to be able to lock requests for each account to a designated hostname to protect that users account usage.
>>>
>>> Thanks,
>>> Lee
>>>
>>> _______________________________________________
>>> Extend mailing list
>>> Extend at lists.ninenines.eu
>>> http://lists.ninenines.eu:81/listinfo/extend
>>
>>
>> --
>> Lo?c Hoguin
>> Erlang Cowboy
>> Nine Nines
>> http://ninenines.eu


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From nathan at nmichaels.org  Wed Oct  9 17:51:14 2013
From: nathan at nmichaels.org (Nathan Michaels)
Date: Wed, 9 Oct 2013 11:51:14 -0400
Subject: [99s-extend] Cowboy Calling Hostname
In-Reply-To: <[email protected]>
References: <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
Message-ID: <CALvUveMuMZabtizGQDURJs7x62RjZNr=NukQLF49MDtZBiPF6A@mail.gmail.com>

Is the client making the request to your service on widgets.net because
things.com sent them there, or is things.com making the request directly on
behalf of the client? The first is what Lo?c is talking about. The second
is the source IP of the request, which you can definitely get.


On Wed, Oct 9, 2013 at 11:32 AM, Lo?c Hoguin <essen at ninenines.eu> wrote:

> In short: you can't.
>
> Browsers may send origin/referer/.. headers depending on the type of
> request, but you can't rely on them to be real or even just there.
>
>
> On 10/09/2013 05:30 PM, Lee Sylvester wrote:
>
>> Thank you.  I couldn't work out if that's the host being called from or
>> the host name in the request.  For example, a store called things.commakes a request to my service on
>> widgets.net.  I need to see that the request is made FROM things.com for
>> validation purposes. Is it correct that host will provide this?
>>
>> Thanks,
>> Lee
>>
>> Sent from my iPhone
>>
>>  On Oct 9, 2013, at 2:31 PM, Lo?c Hoguin <essen at ninenines.eu> wrote:
>>>
>>> cowboy_req:host/1?
>>>
>>> Please use the nice manual we have now.
>>>
>>>   http://ninenines.eu/docs/en/**cowboy/HEAD/manual/cowboy_req<http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_req>
>>>
>>>  On 10/09/2013 03:27 PM, Lee Sylvester wrote:
>>>> Hi,
>>>>
>>>> When receiving a Cowboy request, is there a way to find out which
>>>> hostname the user made the request from?  I'm using CORS in my REST and
>>>> Bullet app, where each call can be made through a given account.  However,
>>>> I'd like to be able to lock requests for each account to a designated
>>>> hostname to protect that users account usage.
>>>>
>>>> Thanks,
>>>> Lee
>>>>
>>>> ______________________________**_________________
>>>> Extend mailing list
>>>> Extend at lists.ninenines.eu
>>>> http://lists.ninenines.eu:81/**listinfo/extend<http://lists.ninenines.eu:81/listinfo/extend>
>>>>
>>>
>>>
>>> --
>>> Lo?c Hoguin
>>> Erlang Cowboy
>>> Nine Nines
>>> http://ninenines.eu
>>>
>>
>
> --
> Lo?c Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu
> ______________________________**_________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/**listinfo/extend<http://lists.ninenines.eu:81/listinfo/extend>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131009/cc05d6f5/attachment.html>

From lee.sylvester at gmail.com  Wed Oct  9 19:28:40 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Wed, 9 Oct 2013 18:28:40 +0100
Subject: [99s-extend] Cowboy Calling Hostname
In-Reply-To: <CALvUveMuMZabtizGQDURJs7x62RjZNr=NukQLF49MDtZBiPF6A@mail.gmail.com>
References: <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
 <CALvUveMuMZabtizGQDURJs7x62RjZNr=NukQLF49MDtZBiPF6A@mail.gmail.com>
Message-ID: <[email protected]>

Essentially, the REST service endpoint would be on widgets.net while the clients website, in this case things.com, has a JavaScript that makes an AJAX call to widgets.net.  The account on widgets.net for things.com will have the things.com domain registered to its account, so that widgets.net can check to see if the request is coming from an expected domain.

Thanks,
Lee


On 9 Oct 2013, at 16:51, Nathan Michaels <nathan at nmichaels.org> wrote:

> Is the client making the request to your service on widgets.net because things.com sent them there, or is things.com making the request directly on behalf of the client? The first is what Lo?c is talking about. The second is the source IP of the request, which you can definitely get.
> 
> 
> On Wed, Oct 9, 2013 at 11:32 AM, Lo?c Hoguin <essen at ninenines.eu> wrote:
> In short: you can't.
> 
> Browsers may send origin/referer/.. headers depending on the type of request, but you can't rely on them to be real or even just there.
> 
> 
> On 10/09/2013 05:30 PM, Lee Sylvester wrote:
> Thank you.  I couldn't work out if that's the host being called from or the host name in the request.  For example, a store called things.com makes a request to my service on widgets.net.  I need to see that the request is made FROM things.com for validation purposes. Is it correct that host will provide this?
> 
> Thanks,
> Lee
> 
> Sent from my iPhone
> 
> On Oct 9, 2013, at 2:31 PM, Lo?c Hoguin <essen at ninenines.eu> wrote:
> 
> cowboy_req:host/1?
> 
> Please use the nice manual we have now.
> 
>   http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_req
> 
> On 10/09/2013 03:27 PM, Lee Sylvester wrote:
> Hi,
> 
> When receiving a Cowboy request, is there a way to find out which hostname the user made the request from?  I'm using CORS in my REST and Bullet app, where each call can be made through a given account.  However, I'd like to be able to lock requests for each account to a designated hostname to protect that users account usage.
> 
> Thanks,
> Lee
> 
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
> 
> 
> --
> Lo?c Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu
> 
> 
> -- 
> Lo?c Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
> 
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131009/7c03cefc/attachment.html>

From daniel at whitehouse.id.au  Thu Oct 10 01:03:08 2013
From: daniel at whitehouse.id.au (Daniel White)
Date: Thu, 10 Oct 2013 10:03:08 +1100
Subject: [99s-extend] Cowboy Calling Hostname
In-Reply-To: <[email protected]>
References: <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
 <CALvUveMuMZabtizGQDURJs7x62RjZNr=NukQLF49MDtZBiPF6A@mail.gmail.com>
 <[email protected]>
Message-ID: <CAMD5n_3RJT3Nd0p4cbgCtR1XavDXSY6kaWTbwiLwqH_bF74KOw@mail.gmail.com>

Depending on your requirements, there is a high likelihood that you
need to support pre-flight requests.  Especially if you're intending
on providing credentials in the requests.  Many of the interesting
headers are not simple headers (for CORS) and require a handshake
first between browser and server to ensure the headers in question are
allowed to be sent.

This obviously limits the amount of information you can determine
about the caller.  One alternative here, is the use of OAuth2 with the
'access_token' query parameter.  This can be sent along with the
pre-flight request.

On the other hand, some providers (Github, IIRC) will simply validate
a CORS request by comparing the 'Origin' against their entire list of
registered origins.  This opens up some opportunity for abuse by other
clients in the system, but can be further mitigated by enforcing the
'Origin' more strictly at the authorization step of the request.

As an aside, I have a cowboy middleware project to do the heavy
lifting for CORS at https://github.com/danielwhite/cowboy_cors.
Business policies can be implemented by means of a callback module.

Cheers,


On Thu, Oct 10, 2013 at 4:28 AM, Lee Sylvester <lee.sylvester at gmail.com> wrote:
> Essentially, the REST service endpoint would be on widgets.net while the
> clients website, in this case things.com, has a JavaScript that makes an
> AJAX call to widgets.net.  The account on widgets.net for things.com will
> have the things.com domain registered to its account, so that widgets.net
> can check to see if the request is coming from an expected domain.
>
> Thanks,
> Lee
>
>
> On 9 Oct 2013, at 16:51, Nathan Michaels <nathan at nmichaels.org> wrote:
>
> Is the client making the request to your service on widgets.net because
> things.com sent them there, or is things.com making the request directly on
> behalf of the client? The first is what Lo?c is talking about. The second is
> the source IP of the request, which you can definitely get.
>
>
> On Wed, Oct 9, 2013 at 11:32 AM, Lo?c Hoguin <essen at ninenines.eu> wrote:
>>
>> In short: you can't.
>>
>> Browsers may send origin/referer/.. headers depending on the type of
>> request, but you can't rely on them to be real or even just there.
>>
>>
>> On 10/09/2013 05:30 PM, Lee Sylvester wrote:
>>>
>>> Thank you.  I couldn't work out if that's the host being called from or
>>> the host name in the request.  For example, a store called things.com makes
>>> a request to my service on widgets.net.  I need to see that the request is
>>> made FROM things.com for validation purposes. Is it correct that host will
>>> provide this?
>>>
>>> Thanks,
>>> Lee
>>>
>>> Sent from my iPhone
>>>
>>>> On Oct 9, 2013, at 2:31 PM, Lo?c Hoguin <essen at ninenines.eu> wrote:
>>>>
>>>> cowboy_req:host/1?
>>>>
>>>> Please use the nice manual we have now.
>>>>
>>>>   http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_req
>>>>
>>>>> On 10/09/2013 03:27 PM, Lee Sylvester wrote:
>>>>> Hi,
>>>>>
>>>>> When receiving a Cowboy request, is there a way to find out which
>>>>> hostname the user made the request from?  I'm using CORS in my REST and
>>>>> Bullet app, where each call can be made through a given account.  However,
>>>>> I'd like to be able to lock requests for each account to a designated
>>>>> hostname to protect that users account usage.
>>>>>
>>>>> Thanks,
>>>>> Lee
>>>>>
>>>>> _______________________________________________
>>>>> Extend mailing list
>>>>> Extend at lists.ninenines.eu
>>>>> http://lists.ninenines.eu:81/listinfo/extend
>>>>
>>>>
>>>>
>>>> --
>>>> Lo?c Hoguin
>>>> Erlang Cowboy
>>>> Nine Nines
>>>> http://ninenines.eu
>>
>>
>>
>> --
>> Lo?c Hoguin
>> Erlang Cowboy
>> Nine Nines
>> http://ninenines.eu
>> _______________________________________________
>> Extend mailing list
>> Extend at lists.ninenines.eu
>> http://lists.ninenines.eu:81/listinfo/extend
>
>
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
>
>
>
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
>



-- 
Daniel White


From lee.sylvester at gmail.com  Thu Oct 10 08:05:23 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Thu, 10 Oct 2013 07:05:23 +0100
Subject: [99s-extend] Cowboy Calling Hostname
In-Reply-To: <CAMD5n_3RJT3Nd0p4cbgCtR1XavDXSY6kaWTbwiLwqH_bF74KOw@mail.gmail.com>
References: <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
 <CALvUveMuMZabtizGQDURJs7x62RjZNr=NukQLF49MDtZBiPF6A@mail.gmail.com>
 <[email protected]>
 <CAMD5n_3RJT3Nd0p4cbgCtR1XavDXSY6kaWTbwiLwqH_bF74KOw@mail.gmail.com>
Message-ID: <[email protected]>

Thank you, Daniel.  The project looks very useful.  At this stage, I don't need to strictly require calls to come from a set domain but would like this to be a hurdle for hackers.  I may set up an IP restriction instead.

Thanks,
Lee

Sent from my iPhone

> On Oct 10, 2013, at 12:03 AM, Daniel White <daniel at whitehouse.id.au> wrote:
> 
> Depending on your requirements, there is a high likelihood that you
> need to support pre-flight requests.  Especially if you're intending
> on providing credentials in the requests.  Many of the interesting
> headers are not simple headers (for CORS) and require a handshake
> first between browser and server to ensure the headers in question are
> allowed to be sent.
> 
> This obviously limits the amount of information you can determine
> about the caller.  One alternative here, is the use of OAuth2 with the
> 'access_token' query parameter.  This can be sent along with the
> pre-flight request.
> 
> On the other hand, some providers (Github, IIRC) will simply validate
> a CORS request by comparing the 'Origin' against their entire list of
> registered origins.  This opens up some opportunity for abuse by other
> clients in the system, but can be further mitigated by enforcing the
> 'Origin' more strictly at the authorization step of the request.
> 
> As an aside, I have a cowboy middleware project to do the heavy
> lifting for CORS at https://github.com/danielwhite/cowboy_cors.
> Business policies can be implemented by means of a callback module.
> 
> Cheers,
> 
> 
>> On Thu, Oct 10, 2013 at 4:28 AM, Lee Sylvester <lee.sylvester at gmail.com> wrote:
>> Essentially, the REST service endpoint would be on widgets.net while the
>> clients website, in this case things.com, has a JavaScript that makes an
>> AJAX call to widgets.net.  The account on widgets.net for things.com will
>> have the things.com domain registered to its account, so that widgets.net
>> can check to see if the request is coming from an expected domain.
>> 
>> Thanks,
>> Lee
>> 
>> 
>> On 9 Oct 2013, at 16:51, Nathan Michaels <nathan at nmichaels.org> wrote:
>> 
>> Is the client making the request to your service on widgets.net because
>> things.com sent them there, or is things.com making the request directly on
>> behalf of the client? The first is what Lo?c is talking about. The second is
>> the source IP of the request, which you can definitely get.
>> 
>> 
>>> On Wed, Oct 9, 2013 at 11:32 AM, Lo?c Hoguin <essen at ninenines.eu> wrote:
>>> 
>>> In short: you can't.
>>> 
>>> Browsers may send origin/referer/.. headers depending on the type of
>>> request, but you can't rely on them to be real or even just there.
>>> 
>>> 
>>>> On 10/09/2013 05:30 PM, Lee Sylvester wrote:
>>>> 
>>>> Thank you.  I couldn't work out if that's the host being called from or
>>>> the host name in the request.  For example, a store called things.com makes
>>>> a request to my service on widgets.net.  I need to see that the request is
>>>> made FROM things.com for validation purposes. Is it correct that host will
>>>> provide this?
>>>> 
>>>> Thanks,
>>>> Lee
>>>> 
>>>> Sent from my iPhone
>>>> 
>>>>> On Oct 9, 2013, at 2:31 PM, Lo?c Hoguin <essen at ninenines.eu> wrote:
>>>>> 
>>>>> cowboy_req:host/1?
>>>>> 
>>>>> Please use the nice manual we have now.
>>>>> 
>>>>>  http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_req
>>>>> 
>>>>>> On 10/09/2013 03:27 PM, Lee Sylvester wrote:
>>>>>> Hi,
>>>>>> 
>>>>>> When receiving a Cowboy request, is there a way to find out which
>>>>>> hostname the user made the request from?  I'm using CORS in my REST and
>>>>>> Bullet app, where each call can be made through a given account.  However,
>>>>>> I'd like to be able to lock requests for each account to a designated
>>>>>> hostname to protect that users account usage.
>>>>>> 
>>>>>> Thanks,
>>>>>> Lee
>>>>>> 
>>>>>> _______________________________________________
>>>>>> Extend mailing list
>>>>>> Extend at lists.ninenines.eu
>>>>>> http://lists.ninenines.eu:81/listinfo/extend
>>>>> 
>>>>> 
>>>>> 
>>>>> --
>>>>> Lo?c Hoguin
>>>>> Erlang Cowboy
>>>>> Nine Nines
>>>>> http://ninenines.eu
>>> 
>>> 
>>> 
>>> --
>>> Lo?c Hoguin
>>> Erlang Cowboy
>>> Nine Nines
>>> http://ninenines.eu
>>> _______________________________________________
>>> Extend mailing list
>>> Extend at lists.ninenines.eu
>>> http://lists.ninenines.eu:81/listinfo/extend
>> 
>> 
>> _______________________________________________
>> Extend mailing list
>> Extend at lists.ninenines.eu
>> http://lists.ninenines.eu:81/listinfo/extend
>> 
>> 
>> 
>> _______________________________________________
>> Extend mailing list
>> Extend at lists.ninenines.eu
>> http://lists.ninenines.eu:81/listinfo/extend
> 
> 
> 
> -- 
> Daniel White


From prinbit at gmail.com  Tue Oct 15 03:53:05 2013
From: prinbit at gmail.com (=?GB2312?B?scjB2rHIzNhQcmluYml0?=)
Date: Tue, 15 Oct 2013 09:53:05 +0800
Subject: [99s-extend] SSL Example
In-Reply-To: <CAO_b8hZeQwEyDKtGbCgLWKSKDD+uW7PbeC-MZME=QVRK2xn4TA@mail.gmail.com>
References: <CAO_b8hZeQwEyDKtGbCgLWKSKDD+uW7PbeC-MZME=QVRK2xn4TA@mail.gmail.com>
Message-ID: <CAO_b8hbgbhKYxuh2SGA7n0SSQqCWOCjhKWzL5xhjcC4ht2h7WA@mail.gmail.com>

Hi Essen,

Any suggestion on the question?

I can't receive any email from the lists.

Thanks in advance

2013/10/13 ????Prinbit <prinbit at gmail.com>:
> Hi essen
>
> In your ssl example, three files are needed in ssl folder, they are
> cowboy-ca.crt, server.crt and server.key.
>
> I am applying for a free ssl in startssl, and found there are only
> server.crt and server.key generated.
>
> What is cowboy-ca.crt used for?
>
> I want to add ssl certificate in http://prinbit.com, my question is
> that is cowboy-ca.crt is needed for me?
>
> Thanks in advance
>
> --
> Thanks & Regards,
>
> PrinBit, Video Chatting and Collaborative Coding, Together
>
> http://prinbit.com



-- 
Thanks & Regards,

PrinBit, Video Chatting and Collaborative Coding, Together

http://prinbit.com


From akonsu at gmail.com  Wed Oct 16 04:55:28 2013
From: akonsu at gmail.com (akonsu)
Date: Tue, 15 Oct 2013 22:55:28 -0400
Subject: [99s-extend] timeout in cowboy loop handler
Message-ID: <CA+eMAwZDCwOi32RY_mwKY7w-O1Q+PTGQwp4vY72KJY3C-Q8_Xw@mail.gmail.com>

Hello,

the documentation for `init` at
http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_loop_handler says:

The receive loop will run for a duration of up to Timeout milliseconds
after it last received data from the socket, at which point it will stop
and send a 204 No Content reply.

What socket does it refer to? I had an impression that the loop handles
erlang messages. Do these messages come through a socket (sorry about a
trivial question, but I am new to erlang), and this is the socket that the
docs talk about?

The reason why I am asking is because I used to have a Timeout of 60000,
and even though messages kept coming non stop, it still kept disconnecting
after a minute, until I set Timeout to infinity.

thanks
Konstantin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131015/94506752/attachment.html>

From essen at ninenines.eu  Wed Oct 16 05:01:38 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Wed, 16 Oct 2013 05:01:38 +0200
Subject: [99s-extend] timeout in cowboy loop handler
In-Reply-To: <CA+eMAwZDCwOi32RY_mwKY7w-O1Q+PTGQwp4vY72KJY3C-Q8_Xw@mail.gmail.com>
References: <CA+eMAwZDCwOi32RY_mwKY7w-O1Q+PTGQwp4vY72KJY3C-Q8_Xw@mail.gmail.com>
Message-ID: <[email protected]>

The socket connected to the client.

TCP isn't perfect, there is no way to be 100% sure the client is still 
connected, hence the timeout. If the client is still up you should make 
it reconnect.

On 10/16/2013 04:55 AM, akonsu wrote:
> Hello,
>
> the documentation for `init` at
> http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_loop_handler says:
>
> The receive loop will run for a duration of up to Timeout milliseconds
> after it last received data from the socket, at which point it will stop
> and send a 204 No Content reply.
>
> What socket does it refer to? I had an impression that the loop handles
> erlang messages. Do these messages come through a socket (sorry about a
> trivial question, but I am new to erlang), and this is the socket that
> the docs talk about?
>
> The reason why I am asking is because I used to have a Timeout of 60000,
> and even though messages kept coming non stop, it still kept
> disconnecting after a minute, until I set Timeout to infinity.
>
> thanks
> Konstantin
>
>
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From akonsu at gmail.com  Wed Oct 16 05:03:53 2013
From: akonsu at gmail.com (akonsu)
Date: Tue, 15 Oct 2013 23:03:53 -0400
Subject: [99s-extend] timeout in cowboy loop handler
In-Reply-To: <[email protected]>
References: <CA+eMAwZDCwOi32RY_mwKY7w-O1Q+PTGQwp4vY72KJY3C-Q8_Xw@mail.gmail.com>
 <[email protected]>
Message-ID: <CA+eMAwYP_rRrgTSqwv7nD2UAJkvKDzpKDfkrfLaLJTff_Dg7ig@mail.gmail.com>

so it will disconnect if the client only listens and sends nothing to the
socket, correct?


2013/10/15 Lo?c Hoguin <essen at ninenines.eu>

> The socket connected to the client.
>
> TCP isn't perfect, there is no way to be 100% sure the client is still
> connected, hence the timeout. If the client is still up you should make it
> reconnect.
>
>
> On 10/16/2013 04:55 AM, akonsu wrote:
>
>> Hello,
>>
>> the documentation for `init` at
>> http://ninenines.eu/docs/en/**cowboy/HEAD/manual/cowboy_**loop_handler<http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_loop_handler>says:
>>
>> The receive loop will run for a duration of up to Timeout milliseconds
>> after it last received data from the socket, at which point it will stop
>> and send a 204 No Content reply.
>>
>> What socket does it refer to? I had an impression that the loop handles
>> erlang messages. Do these messages come through a socket (sorry about a
>> trivial question, but I am new to erlang), and this is the socket that
>> the docs talk about?
>>
>> The reason why I am asking is because I used to have a Timeout of 60000,
>> and even though messages kept coming non stop, it still kept
>> disconnecting after a minute, until I set Timeout to infinity.
>>
>> thanks
>> Konstantin
>>
>>
>> ______________________________**_________________
>> Extend mailing list
>> Extend at lists.ninenines.eu
>> http://lists.ninenines.eu:81/**listinfo/extend<http://lists.ninenines.eu:81/listinfo/extend>
>>
>>
>
> --
> Lo?c Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131015/591e8649/attachment.html>

From essen at ninenines.eu  Wed Oct 16 05:11:30 2013
From: essen at ninenines.eu (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=)
Date: Wed, 16 Oct 2013 05:11:30 +0200
Subject: [99s-extend] timeout in cowboy loop handler
In-Reply-To: <CA+eMAwYP_rRrgTSqwv7nD2UAJkvKDzpKDfkrfLaLJTff_Dg7ig@mail.gmail.com>
References: <CA+eMAwZDCwOi32RY_mwKY7w-O1Q+PTGQwp4vY72KJY3C-Q8_Xw@mail.gmail.com>
 <[email protected]>
 <CA+eMAwYP_rRrgTSqwv7nD2UAJkvKDzpKDfkrfLaLJTff_Dg7ig@mail.gmail.com>
Message-ID: <[email protected]>

Yep. And it will also disconnect if the client sends too much. It has to 
disconnect and reconnect eventually, there's no way around it.

On 10/16/2013 05:03 AM, akonsu wrote:
> so it will disconnect if the client only listens and sends nothing to
> the socket, correct?
>
>
> 2013/10/15 Lo?c Hoguin <essen at ninenines.eu <mailto:essen at ninenines.eu>>
>
>     The socket connected to the client.
>
>     TCP isn't perfect, there is no way to be 100% sure the client is
>     still connected, hence the timeout. If the client is still up you
>     should make it reconnect.
>
>
>     On 10/16/2013 04:55 AM, akonsu wrote:
>
>         Hello,
>
>         the documentation for `init` at
>         http://ninenines.eu/docs/en/__cowboy/HEAD/manual/cowboy___loop_handler
>         <http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_loop_handler>
>         says:
>
>         The receive loop will run for a duration of up to Timeout
>         milliseconds
>         after it last received data from the socket, at which point it
>         will stop
>         and send a 204 No Content reply.
>
>         What socket does it refer to? I had an impression that the loop
>         handles
>         erlang messages. Do these messages come through a socket (sorry
>         about a
>         trivial question, but I am new to erlang), and this is the
>         socket that
>         the docs talk about?
>
>         The reason why I am asking is because I used to have a Timeout
>         of 60000,
>         and even though messages kept coming non stop, it still kept
>         disconnecting after a minute, until I set Timeout to infinity.
>
>         thanks
>         Konstantin
>
>
>         _________________________________________________
>         Extend mailing list
>         Extend at lists.ninenines.eu <mailto:Extend at lists.ninenines.eu>
>         http://lists.ninenines.eu:81/__listinfo/extend
>         <http://lists.ninenines.eu:81/listinfo/extend>
>
>
>
>     --
>     Lo?c Hoguin
>     Erlang Cowboy
>     Nine Nines
>     http://ninenines.eu
>
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From akonsu at gmail.com  Wed Oct 16 05:31:46 2013
From: akonsu at gmail.com (akonsu)
Date: Tue, 15 Oct 2013 23:31:46 -0400
Subject: [99s-extend] timeout in cowboy loop handler
In-Reply-To: <[email protected]>
References: <CA+eMAwZDCwOi32RY_mwKY7w-O1Q+PTGQwp4vY72KJY3C-Q8_Xw@mail.gmail.com>
 <[email protected]>
 <CA+eMAwYP_rRrgTSqwv7nD2UAJkvKDzpKDfkrfLaLJTff_Dg7ig@mail.gmail.com>
 <[email protected]>
Message-ID: <CA+eMAwY75j1G2Ew13WY5dMCT8_E41b85OjoKdFHw9AZfX9qQcg@mail.gmail.com>

thanks for your help. suppose that I want to stream live audio. I do not
know how long my audio program will be, and as I stream it, if I have a
timeout, the server will just disconnect the user that listens to the audio
in the browser. and the browser won't reconnect. Would you suggest the
"right" way to implement something like that? Would infinite timeout
suffice? or is it a bad practice? another type of handler maybe?


2013/10/15 Lo?c Hoguin <essen at ninenines.eu>

> Yep. And it will also disconnect if the client sends too much. It has to
> disconnect and reconnect eventually, there's no way around it.
>
>
> On 10/16/2013 05:03 AM, akonsu wrote:
>
>> so it will disconnect if the client only listens and sends nothing to
>> the socket, correct?
>>
>>
>> 2013/10/15 Lo?c Hoguin <essen at ninenines.eu <mailto:essen at ninenines.eu>>
>>
>>
>>     The socket connected to the client.
>>
>>     TCP isn't perfect, there is no way to be 100% sure the client is
>>     still connected, hence the timeout. If the client is still up you
>>     should make it reconnect.
>>
>>
>>     On 10/16/2013 04:55 AM, akonsu wrote:
>>
>>         Hello,
>>
>>         the documentation for `init` at
>>         http://ninenines.eu/docs/en/__**cowboy/HEAD/manual/cowboy___**
>> loop_handler<http://ninenines.eu/docs/en/__cowboy/HEAD/manual/cowboy___loop_handler>
>>
>>         <http://ninenines.eu/docs/en/**cowboy/HEAD/manual/cowboy_**
>> loop_handler<http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_loop_handler>
>> >
>>         says:
>>
>>         The receive loop will run for a duration of up to Timeout
>>         milliseconds
>>         after it last received data from the socket, at which point it
>>         will stop
>>         and send a 204 No Content reply.
>>
>>         What socket does it refer to? I had an impression that the loop
>>         handles
>>         erlang messages. Do these messages come through a socket (sorry
>>         about a
>>         trivial question, but I am new to erlang), and this is the
>>         socket that
>>         the docs talk about?
>>
>>         The reason why I am asking is because I used to have a Timeout
>>         of 60000,
>>         and even though messages kept coming non stop, it still kept
>>         disconnecting after a minute, until I set Timeout to infinity.
>>
>>         thanks
>>         Konstantin
>>
>>
>>         ______________________________**___________________
>>         Extend mailing list
>>         Extend at lists.ninenines.eu <mailto:Extend at lists.**ninenines.eu<Extend at lists.ninenines.eu>
>> >
>>         http://lists.ninenines.eu:81/_**_listinfo/extend<http://lists.ninenines.eu:81/__listinfo/extend>
>>
>>         <http://lists.ninenines.eu:81/**listinfo/extend<http://lists.ninenines.eu:81/listinfo/extend>
>> >
>>
>>
>>
>>     --
>>     Lo?c Hoguin
>>     Erlang Cowboy
>>     Nine Nines
>>     http://ninenines.eu
>>
>>
>>
>
> --
> Lo?c Hoguin
>
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131015/203060cc/attachment.html>

From essen at ninenines.eu  Wed Oct 16 05:40:31 2013
From: essen at ninenines.eu (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=)
Date: Wed, 16 Oct 2013 05:40:31 +0200
Subject: [99s-extend] timeout in cowboy loop handler
In-Reply-To: <CA+eMAwY75j1G2Ew13WY5dMCT8_E41b85OjoKdFHw9AZfX9qQcg@mail.gmail.com>
References: <CA+eMAwZDCwOi32RY_mwKY7w-O1Q+PTGQwp4vY72KJY3C-Q8_Xw@mail.gmail.com>
 <[email protected]>
 <CA+eMAwYP_rRrgTSqwv7nD2UAJkvKDzpKDfkrfLaLJTff_Dg7ig@mail.gmail.com>
 <[email protected]>
 <CA+eMAwY75j1G2Ew13WY5dMCT8_E41b85OjoKdFHw9AZfX9qQcg@mail.gmail.com>
Message-ID: <[email protected]>

Infinite is bad practice, yes. Infinite means some connections will 
*never* be closed, eating FDs and memory for nothing.

I'm not sure why you want to receive messages, you could just use a 
normal handler that asks for more data, sends it, ask for more data, 
sends it, etc.

On 10/16/2013 05:31 AM, akonsu wrote:
> thanks for your help. suppose that I want to stream live audio. I do not
> know how long my audio program will be, and as I stream it, if I have a
> timeout, the server will just disconnect the user that listens to the
> audio in the browser. and the browser won't reconnect. Would you suggest
> the "right" way to implement something like that? Would infinite timeout
> suffice? or is it a bad practice? another type of handler maybe?
>
>
> 2013/10/15 Lo?c Hoguin <essen at ninenines.eu <mailto:essen at ninenines.eu>>
>
>     Yep. And it will also disconnect if the client sends too much. It
>     has to disconnect and reconnect eventually, there's no way around it.
>
>
>     On 10/16/2013 05:03 AM, akonsu wrote:
>
>         so it will disconnect if the client only listens and sends
>         nothing to
>         the socket, correct?
>
>
>         2013/10/15 Lo?c Hoguin <essen at ninenines.eu
>         <mailto:essen at ninenines.eu> <mailto:essen at ninenines.eu
>         <mailto:essen at ninenines.eu>>>
>
>
>              The socket connected to the client.
>
>              TCP isn't perfect, there is no way to be 100% sure the
>         client is
>              still connected, hence the timeout. If the client is still
>         up you
>              should make it reconnect.
>
>
>              On 10/16/2013 04:55 AM, akonsu wrote:
>
>                  Hello,
>
>                  the documentation for `init` at
>         http://ninenines.eu/docs/en/____cowboy/HEAD/manual/cowboy_____loop_handler
>         <http://ninenines.eu/docs/en/__cowboy/HEAD/manual/cowboy___loop_handler>
>
>
>         <http://ninenines.eu/docs/en/__cowboy/HEAD/manual/cowboy___loop_handler
>         <http://ninenines.eu/docs/en/cowboy/HEAD/manual/cowboy_loop_handler>>
>                  says:
>
>                  The receive loop will run for a duration of up to Timeout
>                  milliseconds
>                  after it last received data from the socket, at which
>         point it
>                  will stop
>                  and send a 204 No Content reply.
>
>                  What socket does it refer to? I had an impression that
>         the loop
>                  handles
>                  erlang messages. Do these messages come through a
>         socket (sorry
>                  about a
>                  trivial question, but I am new to erlang), and this is the
>                  socket that
>                  the docs talk about?
>
>                  The reason why I am asking is because I used to have a
>         Timeout
>                  of 60000,
>                  and even though messages kept coming non stop, it still
>         kept
>                  disconnecting after a minute, until I set Timeout to
>         infinity.
>
>                  thanks
>                  Konstantin
>
>
>                  ___________________________________________________
>                  Extend mailing list
>         Extend at lists.ninenines.eu <mailto:Extend at lists.ninenines.eu>
>         <mailto:Extend at lists.__ninenines.eu
>         <mailto:Extend at lists.ninenines.eu>>
>         http://lists.ninenines.eu:81/____listinfo/extend
>         <http://lists.ninenines.eu:81/__listinfo/extend>
>
>                  <http://lists.ninenines.eu:81/__listinfo/extend
>         <http://lists.ninenines.eu:81/listinfo/extend>>
>
>
>
>              --
>              Lo?c Hoguin
>              Erlang Cowboy
>              Nine Nines
>         http://ninenines.eu
>
>
>
>
>     --
>     Lo?c Hoguin
>
>     Erlang Cowboy
>     Nine Nines
>     http://ninenines.eu
>
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From akonsu at gmail.com  Wed Oct 16 05:48:42 2013
From: akonsu at gmail.com (akonsu)
Date: Tue, 15 Oct 2013 23:48:42 -0400
Subject: [99s-extend] timeout in cowboy loop handler
In-Reply-To: <[email protected]>
References: <CA+eMAwZDCwOi32RY_mwKY7w-O1Q+PTGQwp4vY72KJY3C-Q8_Xw@mail.gmail.com>
 <[email protected]>
 <CA+eMAwYP_rRrgTSqwv7nD2UAJkvKDzpKDfkrfLaLJTff_Dg7ig@mail.gmail.com>
 <[email protected]>
 <CA+eMAwY75j1G2Ew13WY5dMCT8_E41b85OjoKdFHw9AZfX9qQcg@mail.gmail.com>
 <[email protected]>
Message-ID: <CA+eMAwZW64xGtVxca35PngCXBJEh8oaQk9TuOPesXf48XUH=qg@mail.gmail.com>

1. do you mean that there is no way on the server side to tell if the
client has disconnected?

2. if I use a normal handler, I will still run into the same problem, it
does not matter which handler I use, from the standpoint of deciding
whether the client is still there, right?

I am confused as to how I can implement my streaming and not drop the
connection on each client and yet make sure I do close the connections when
the clients disconnect...


2013/10/15 Lo?c Hoguin <essen at ninenines.eu>

> Infinite is bad practice, yes. Infinite means some connections will
> *never* be closed, eating FDs and memory for nothing.
>
> I'm not sure why you want to receive messages, you could just use a normal
> handler that asks for more data, sends it, ask for more data, sends it, etc.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131015/bac10460/attachment.html>

From essen at ninenines.eu  Wed Oct 16 06:07:26 2013
From: essen at ninenines.eu (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=)
Date: Wed, 16 Oct 2013 06:07:26 +0200
Subject: [99s-extend] timeout in cowboy loop handler
In-Reply-To: <CA+eMAwZW64xGtVxca35PngCXBJEh8oaQk9TuOPesXf48XUH=qg@mail.gmail.com>
References: <CA+eMAwZDCwOi32RY_mwKY7w-O1Q+PTGQwp4vY72KJY3C-Q8_Xw@mail.gmail.com>
 <[email protected]>
 <CA+eMAwYP_rRrgTSqwv7nD2UAJkvKDzpKDfkrfLaLJTff_Dg7ig@mail.gmail.com>
 <[email protected]>
 <CA+eMAwY75j1G2Ew13WY5dMCT8_E41b85OjoKdFHw9AZfX9qQcg@mail.gmail.com>
 <[email protected]>
 <CA+eMAwZW64xGtVxca35PngCXBJEh8oaQk9TuOPesXf48XUH=qg@mail.gmail.com>
Message-ID: <[email protected]>

On 10/16/2013 05:48 AM, akonsu wrote:
> 1. do you mean that there is no way on the server side to tell if the
> client has disconnected?

There are ways, and Cowboy will happily detect them. There's also the 
problem that a side may be closed without the other side knowing about 
it, which is why you need timeouts.

> 2. if I use a normal handler, I will still run into the same problem, it
> does not matter which handler I use, from the standpoint of deciding
> whether the client is still there, right?

If the client is gone, the send will fail. Normal handlers are pretty 
much the same except they don't have a timeout, because your code has an 
explicit end.

> I am confused as to how I can implement my streaming and not drop the
> connection on each client and yet make sure I do close the connections
> when the clients disconnect...
>
>
> 2013/10/15 Lo?c Hoguin <essen at ninenines.eu <mailto:essen at ninenines.eu>>
>
>     Infinite is bad practice, yes. Infinite means some connections will
>     *never* be closed, eating FDs and memory for nothing.
>
>     I'm not sure why you want to receive messages, you could just use a
>     normal handler that asks for more data, sends it, ask for more data,
>     sends it, etc.
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From akonsu at gmail.com  Wed Oct 16 06:12:29 2013
From: akonsu at gmail.com (akonsu)
Date: Wed, 16 Oct 2013 00:12:29 -0400
Subject: [99s-extend] timeout in cowboy loop handler
In-Reply-To: <[email protected]>
References: <CA+eMAwZDCwOi32RY_mwKY7w-O1Q+PTGQwp4vY72KJY3C-Q8_Xw@mail.gmail.com>
 <[email protected]>
 <CA+eMAwYP_rRrgTSqwv7nD2UAJkvKDzpKDfkrfLaLJTff_Dg7ig@mail.gmail.com>
 <[email protected]>
 <CA+eMAwY75j1G2Ew13WY5dMCT8_E41b85OjoKdFHw9AZfX9qQcg@mail.gmail.com>
 <[email protected]>
 <CA+eMAwZW64xGtVxca35PngCXBJEh8oaQk9TuOPesXf48XUH=qg@mail.gmail.com>
 <[email protected]>
Message-ID: <CA+eMAwb0ubM3O=yKmEJvrJ94Y2xVWpnPxXWO7Qx0q8kxL4+qwQ@mail.gmail.com>

thanks. one more question if you do not mind. you say that we need timeouts
when the client does not notify us when it dies. but then you say that if
the client dies then the socket write will fail. to me this sounds like a
contradiction. would you please clarify?

(I assume that this is the problem that we are discussing:
http://stackoverflow.com/questions/283375/detecting-tcp-client-disconnect,
right?)


2013/10/16 Lo?c Hoguin <essen at ninenines.eu>

> On 10/16/2013 05:48 AM, akonsu wrote:
>
>> 1. do you mean that there is no way on the server side to tell if the
>> client has disconnected?
>>
>
> There are ways, and Cowboy will happily detect them. There's also the
> problem that a side may be closed without the other side knowing about it,
> which is why you need timeouts.
>
>
>  2. if I use a normal handler, I will still run into the same problem, it
>> does not matter which handler I use, from the standpoint of deciding
>> whether the client is still there, right?
>>
>
> If the client is gone, the send will fail. Normal handlers are pretty much
> the same except they don't have a timeout, because your code has an
> explicit end.
>
>  I am confused as to how I can implement my streaming and not drop the
>> connection on each client and yet make sure I do close the connections
>> when the clients disconnect...
>>
>>
>> 2013/10/15 Lo?c Hoguin <essen at ninenines.eu <mailto:essen at ninenines.eu>>
>>
>>
>>     Infinite is bad practice, yes. Infinite means some connections will
>>     *never* be closed, eating FDs and memory for nothing.
>>
>>     I'm not sure why you want to receive messages, you could just use a
>>     normal handler that asks for more data, sends it, ask for more data,
>>     sends it, etc.
>>
>>
>
> --
> Lo?c Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131016/edbc349c/attachment.html>

From essen at ninenines.eu  Wed Oct 16 06:35:43 2013
From: essen at ninenines.eu (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=)
Date: Wed, 16 Oct 2013 06:35:43 +0200
Subject: [99s-extend] timeout in cowboy loop handler
In-Reply-To: <CA+eMAwb0ubM3O=yKmEJvrJ94Y2xVWpnPxXWO7Qx0q8kxL4+qwQ@mail.gmail.com>
References: <CA+eMAwZDCwOi32RY_mwKY7w-O1Q+PTGQwp4vY72KJY3C-Q8_Xw@mail.gmail.com>
 <[email protected]>
 <CA+eMAwYP_rRrgTSqwv7nD2UAJkvKDzpKDfkrfLaLJTff_Dg7ig@mail.gmail.com>
 <[email protected]>
 <CA+eMAwY75j1G2Ew13WY5dMCT8_E41b85OjoKdFHw9AZfX9qQcg@mail.gmail.com>
 <[email protected]>
 <CA+eMAwZW64xGtVxca35PngCXBJEh8oaQk9TuOPesXf48XUH=qg@mail.gmail.com>
 <[email protected]>
 <CA+eMAwb0ubM3O=yKmEJvrJ94Y2xVWpnPxXWO7Qx0q8kxL4+qwQ@mail.gmail.com>
Message-ID: <[email protected]>

Loop handlers are designed to wait for a long time with the socket 
*idle* and then eventually send one response then close the socket. 
Things like long-polling.

What you are doing is just streaming, for which you do not need a 
timeout because the socket isn't idle. You are just sending a large 
response, and normal handlers are perfectly capable of doing that.

On 10/16/2013 06:12 AM, akonsu wrote:
> thanks. one more question if you do not mind. you say that we need
> timeouts when the client does not notify us when it dies. but then you
> say that if the client dies then the socket write will fail. to me this
> sounds like a contradiction. would you please clarify?
>
> (I assume that this is the problem that we are discussing:
> http://stackoverflow.com/questions/283375/detecting-tcp-client-disconnect,
> right?)
>
>
> 2013/10/16 Lo?c Hoguin <essen at ninenines.eu <mailto:essen at ninenines.eu>>
>
>     On 10/16/2013 05:48 AM, akonsu wrote:
>
>         1. do you mean that there is no way on the server side to tell
>         if the
>         client has disconnected?
>
>
>     There are ways, and Cowboy will happily detect them. There's also
>     the problem that a side may be closed without the other side knowing
>     about it, which is why you need timeouts.
>
>
>         2. if I use a normal handler, I will still run into the same
>         problem, it
>         does not matter which handler I use, from the standpoint of deciding
>         whether the client is still there, right?
>
>
>     If the client is gone, the send will fail. Normal handlers are
>     pretty much the same except they don't have a timeout, because your
>     code has an explicit end.
>
>         I am confused as to how I can implement my streaming and not
>         drop the
>         connection on each client and yet make sure I do close the
>         connections
>         when the clients disconnect...
>
>
>         2013/10/15 Lo?c Hoguin <essen at ninenines.eu
>         <mailto:essen at ninenines.eu> <mailto:essen at ninenines.eu
>         <mailto:essen at ninenines.eu>>>
>
>
>              Infinite is bad practice, yes. Infinite means some
>         connections will
>              *never* be closed, eating FDs and memory for nothing.
>
>              I'm not sure why you want to receive messages, you could
>         just use a
>              normal handler that asks for more data, sends it, ask for
>         more data,
>              sends it, etc.
>
>
>
>     --
>     Lo?c Hoguin
>     Erlang Cowboy
>     Nine Nines
>     http://ninenines.eu
>
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From akonsu at gmail.com  Wed Oct 16 06:42:02 2013
From: akonsu at gmail.com (akonsu)
Date: Wed, 16 Oct 2013 00:42:02 -0400
Subject: [99s-extend] timeout in cowboy loop handler
In-Reply-To: <[email protected]>
References: <CA+eMAwZDCwOi32RY_mwKY7w-O1Q+PTGQwp4vY72KJY3C-Q8_Xw@mail.gmail.com>
 <[email protected]>
 <CA+eMAwYP_rRrgTSqwv7nD2UAJkvKDzpKDfkrfLaLJTff_Dg7ig@mail.gmail.com>
 <[email protected]>
 <CA+eMAwY75j1G2Ew13WY5dMCT8_E41b85OjoKdFHw9AZfX9qQcg@mail.gmail.com>
 <[email protected]>
 <CA+eMAwZW64xGtVxca35PngCXBJEh8oaQk9TuOPesXf48XUH=qg@mail.gmail.com>
 <[email protected]>
 <CA+eMAwb0ubM3O=yKmEJvrJ94Y2xVWpnPxXWO7Qx0q8kxL4+qwQ@mail.gmail.com>
 <[email protected]>
Message-ID: <CA+eMAwbh8xH9Etiev66oA90p7aw3RjffnYoBd8b3Kuab0Bg6WQ@mail.gmail.com>

ok. the data that I need to send are coming as erlang messages to the
process that runs my handler. so it sounds like if I want to use the
"normal" cowboy_http_handler, then I need a receive loop inside handle(Req,
State) callback, right? Basically, my response stream will potentially
never end, I do not know how to handle this properly in cowboy...


2013/10/16 Lo?c Hoguin <essen at ninenines.eu>

> Loop handlers are designed to wait for a long time with the socket *idle*
> and then eventually send one response then close the socket. Things like
> long-polling.
>
> What you are doing is just streaming, for which you do not need a timeout
> because the socket isn't idle. You are just sending a large response, and
> normal handlers are perfectly capable of doing that.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131016/abe38a1a/attachment.html>

From essen at ninenines.eu  Wed Oct 16 06:48:05 2013
From: essen at ninenines.eu (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=)
Date: Wed, 16 Oct 2013 06:48:05 +0200
Subject: [99s-extend] timeout in cowboy loop handler
In-Reply-To: <CA+eMAwbh8xH9Etiev66oA90p7aw3RjffnYoBd8b3Kuab0Bg6WQ@mail.gmail.com>
References: <CA+eMAwZDCwOi32RY_mwKY7w-O1Q+PTGQwp4vY72KJY3C-Q8_Xw@mail.gmail.com>
 <[email protected]>
 <CA+eMAwYP_rRrgTSqwv7nD2UAJkvKDzpKDfkrfLaLJTff_Dg7ig@mail.gmail.com>
 <[email protected]>
 <CA+eMAwY75j1G2Ew13WY5dMCT8_E41b85OjoKdFHw9AZfX9qQcg@mail.gmail.com>
 <[email protected]>
 <CA+eMAwZW64xGtVxca35PngCXBJEh8oaQk9TuOPesXf48XUH=qg@mail.gmail.com>
 <[email protected]>
 <CA+eMAwb0ubM3O=yKmEJvrJ94Y2xVWpnPxXWO7Qx0q8kxL4+qwQ@mail.gmail.com>
 <[email protected]>
 <CA+eMAwbh8xH9Etiev66oA90p7aw3RjffnYoBd8b3Kuab0Bg6WQ@mail.gmail.com>
Message-ID: <[email protected]>

Then use a loop handler, set its timeout to infinity *but* create a new 
timeout that checks regularly if the handler is active or not to be able 
to kill it off in case something happens.

On 10/16/2013 06:42 AM, akonsu wrote:
> ok. the data that I need to send are coming as erlang messages to the
> process that runs my handler. so it sounds like if I want to use the
> "normal" cowboy_http_handler, then I need a receive loop
> inside handle(Req, State) callback, right? Basically, my response stream
> will potentially never end, I do not know how to handle this properly in
> cowboy...
>
>
> 2013/10/16 Lo?c Hoguin <essen at ninenines.eu <mailto:essen at ninenines.eu>>
>
>     Loop handlers are designed to wait for a long time with the socket
>     *idle* and then eventually send one response then close the socket.
>     Things like long-polling.
>
>     What you are doing is just streaming, for which you do not need a
>     timeout because the socket isn't idle. You are just sending a large
>     response, and normal handlers are perfectly capable of doing that.
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From akonsu at gmail.com  Fri Oct 18 15:15:37 2013
From: akonsu at gmail.com (akonsu)
Date: Fri, 18 Oct 2013 09:15:37 -0400
Subject: [99s-extend] handler and a linked process
Message-ID: <CA+eMAwZE0WqFNH0=usVp0ykdGhNE0y7QoaDoRRNcMMveucy7Qw@mail.gmail.com>

Hi,

I have a handler that spawns a process and links to this process. the new
process does not trap exit signals.

When I open the URL that is handled by this handler in the browser, and
stop the browser before the handler finishes the request, the handler is
terminated and my terminate function is called with the Reason set to
{error,closed} or something similar.

When this happens, the linked process does not get killed, so I have to
call exit on it from the terminate function.

is this by design? I suppose when I cancel the browser request, the handler
is exited with normal exit code, correct? could you point me to the source
code for that part? it is perhaps in the "ranch" repo, no?

thanks in advance

konstantin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131018/00d4df12/attachment.html>

From essen at ninenines.eu  Mon Oct 21 15:07:34 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Mon, 21 Oct 2013 15:07:34 +0200
Subject: [99s-extend] handler and a linked process
In-Reply-To: <CA+eMAwZE0WqFNH0=usVp0ykdGhNE0y7QoaDoRRNcMMveucy7Qw@mail.gmail.com>
References: <CA+eMAwZE0WqFNH0=usVp0ykdGhNE0y7QoaDoRRNcMMveucy7Qw@mail.gmail.com>
Message-ID: <[email protected]>

Hey,

I'm guessing you use loop handler or websocket handler? The browser 
closing the connection in these cases is perfectly normal, that's part 
of the deal. What you can do is monitor the connection process from the 
other process if you need to go down in all cases. Links are only useful 
for crashing on errors.

On 10/18/2013 03:15 PM, akonsu wrote:
> Hi,
>
> I have a handler that spawns a process and links to this process. the
> new process does not trap exit signals.
>
> When I open the URL that is handled by this handler in the browser, and
> stop the browser before the handler finishes the request, the handler is
> terminated and my terminate function is called with the Reason set to
> {error,closed} or something similar.
>
> When this happens, the linked process does not get killed, so I have to
> call exit on it from the terminate function.
>
> is this by design? I suppose when I cancel the browser request, the
> handler is exited with normal exit code, correct? could you point me to
> the source code for that part? it is perhaps in the "ranch" repo, no?
>
> thanks in advance
>
> konstantin
>
>
>
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From antonio.valente at statpro.com  Tue Oct 22 10:51:14 2013
From: antonio.valente at statpro.com (Antonio Valente)
Date: Tue, 22 Oct 2013 10:51:14 +0200
Subject: [99s-extend] Generate url in cowboy
Message-ID: <[email protected]>

Hi all,
I need to automatically generate urls from the dispatcher configuration: 
I'm looking for some kind of function that, given the dispatcher 
configuration, a module and a list of bindings, returns an url.

For example, if I have the following dispatch configuration:

     [
     {'_', [

     {"/api/v1/container/:resource/something", a_module, []},
     ]}
     ].

I'd like to do something like:

<<"/api/v1/container/replaced/something">> = generate_url(Dispatch, 
a_module, [{resource, "replaced"}]).

Is there such a function? If not, can you give me some advice to write one?

Thanks
Antonio


This message is private and confidential. If you have received this message in error, please notify us and remove it from your system. Any views or opinions presented in this email are solely those of the author and might not represent those of StatPro. Warning: Although StatPro has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments.


From Rolph.deRuiter at spilgames.com  Tue Oct 29 10:00:53 2013
From: Rolph.deRuiter at spilgames.com (Rolph de Ruiter)
Date: Tue, 29 Oct 2013 09:00:53 +0000
Subject: [99s-extend] cowboy_rest, POST and redirect
Message-ID: <CE9537D4.769B%[email protected]>

Hi,

I'm using cowboy_rest for a part of our api to handle POST requests. Under certain conditions, I would like to redirect to a new location (based on availability of the redirect qs parameter).
I was unable to get the moved_temporarily/2 callback to work (was not invoked at al). So I just do the 302 myself, using cowboy_req:reply/4. This works, however, every time it produces an error in the emulator process:
 [error] emulator Error in process <0.509.0> on node 'api at dev.loc' with exit value: {function_clause,[{cowboy_req,reply,[204,[],<<0 bytes>>,{http_req,#Port<0.14491>,ranch_tcp,keepalive,<0.509.0>,<<4 bytes>>,'HTTP/1.1',{{10,10,10,1},62197},<<15 bytes>>,undefined,8000,<<26 bytes>>,undefined,<<14 bytes>>,[{<<8 bytes>>,<<5 bytes>>}],[{method,<<5 bytes>>}],[{<<4 bytes>>,<<20 bytes>>},{<<10 bytes>>,<<10 bytes>>},{<<14 bytes>>,<<2 bytes>>},{<<6 bytes>>,<<74 bytes>>},{<<6 bytes>>,<<27 bytes>>},{<<10 bytes>>,<<120 bytes>>},{<<12 bytes>>,<<33 bytes>>},{<<7 bytes>>,<<54 bytes>>},{<<15 bytes>>,<<17 bytes>>},{<<15 bytes>>,<<14 bytes>>},{<<6 bytes>>,<<245 bytes>>}],[{<<14 bytes>>,34},{<<6 bytes>>,undefined},{<<14 bytes>>,34},{<<12 bytes>>,{<<11 bytes>>,<<21 bytes>>,[]}},{<<17 bytes>>,undefined},{<<13 bytes>>,...

Can you point me out how to (ideally) make use of moved_temporarily/2 or how I can prevent cowboy_rest from wanting to reply with 204 in this case?

Cheers,
Rolph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131029/5fc5da75/attachment.html>

From essen at ninenines.eu  Tue Oct 29 10:09:20 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Tue, 29 Oct 2013 10:09:20 +0100
Subject: [99s-extend] cowboy_rest, POST and redirect
In-Reply-To: <CE9537D4.769B%[email protected]>
References: <CE9537D4.769B%[email protected]>
Message-ID: <[email protected]>

On 10/29/2013 10:00 AM, Rolph de Ruiter wrote:
> Hi,
>
> I'm using cowboy_rest for a part of our api to handle POST requests.
> Under certain conditions, I would like to redirect to a new location
> (based on availability of the redirect qs parameter).
> I was unable to get the moved_temporarily/2 callback to work (was not
> invoked at al). So I just do the 302 myself, using cowboy_req:reply/4.
> This works, however, every time it produces an error in the emulator
> process:
>   [error] emulator Error in process <0.509.0> on node 'api at dev.loc' with
> exit value: {function_clause,[{cowboy_req,reply,[204,[],<<0
> bytes>>,{http_req,#Port<0.14491>,ranch_tcp,keepalive,<0.509.0>,<<4
> bytes>>,'HTTP/1.1',{{10,10,10,1},62197},<<15 bytes>>,undefined,8000,<<26
> bytes>>,undefined,<<14 bytes>>,[{<<8 bytes>>,<<5 bytes>>}],[{method,<<5
> bytes>>}],[{<<4 bytes>>,<<20 bytes>>},{<<10 bytes>>,<<10 bytes>>},{<<14
> bytes>>,<<2 bytes>>},{<<6 bytes>>,<<74 bytes>>},{<<6 bytes>>,<<27
> bytes>>},{<<10 bytes>>,<<120 bytes>>},{<<12 bytes>>,<<33 bytes>>},{<<7
> bytes>>,<<54 bytes>>},{<<15 bytes>>,<<17 bytes>>},{<<15 bytes>>,<<14
> bytes>>},{<<6 bytes>>,<<245 bytes>>}],[{<<14 bytes>>,34},{<<6
> bytes>>,undefined},{<<14 bytes>>,34},{<<12 bytes>>,{<<11 bytes>>,<<21
> bytes>>,[]}},{<<17 bytes>>,undefined},{<<13 bytes>>,...
>
> Can you point me out how to (ideally) make use of moved_temporarily/2 or
> how I can prevent cowboy_rest from wanting to reply with 204 in this case?

moved_temporarily is only called if the resource previously existed.

As for calling reply yourself, you just need to return {halt, NewReq, 
State} afterwards.

-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From Rolph.deRuiter at spilgames.com  Tue Oct 29 10:16:15 2013
From: Rolph.deRuiter at spilgames.com (Rolph de Ruiter)
Date: Tue, 29 Oct 2013 09:16:15 +0000
Subject: [99s-extend] cowboy_rest, POST and redirect
In-Reply-To: <CE953AD7.76AD%[email protected]>
Message-ID: <CE953B4E.76B1%[email protected]>

(forgot to include the list)

On 10/29/13 10:14 AM, "Rolph de Ruiter" <Rolph.deRuiter at spilgames.com>
wrote:

>Thanks!
>
>{halt, NewReq, State} worked like a charm :)
>
>Cheers,
>Rolph
>
>On 10/29/13 10:09 AM, "Lo?c Hoguin" <essen at ninenines.eu> wrote:
>
>>On 10/29/2013 10:00 AM, Rolph de Ruiter wrote:
>>> Hi,
>>>
>>> I'm using cowboy_rest for a part of our api to handle POST requests.
>>> Under certain conditions, I would like to redirect to a new location
>>> (based on availability of the redirect qs parameter).
>>> I was unable to get the moved_temporarily/2 callback to work (was not
>>> invoked at al). So I just do the 302 myself, using cowboy_req:reply/4.
>>> This works, however, every time it produces an error in the emulator
>>> process:
>>>   [error] emulator Error in process <0.509.0> on node 'api at dev.loc'
>>>with
>>> exit value: {function_clause,[{cowboy_req,reply,[204,[],<<0
>>> bytes>>,{http_req,#Port<0.14491>,ranch_tcp,keepalive,<0.509.0>,<<4
>>> bytes>>,'HTTP/1.1',{{10,10,10,1},62197},<<15
>>>bytes>>,undefined,8000,<<26
>>> bytes>>,undefined,<<14 bytes>>,[{<<8 bytes>>,<<5 bytes>>}],[{method,<<5
>>> bytes>>}],[{<<4 bytes>>,<<20 bytes>>},{<<10 bytes>>,<<10 bytes>>},{<<14
>>> bytes>>,<<2 bytes>>},{<<6 bytes>>,<<74 bytes>>},{<<6 bytes>>,<<27
>>> bytes>>},{<<10 bytes>>,<<120 bytes>>},{<<12 bytes>>,<<33 bytes>>},{<<7
>>> bytes>>,<<54 bytes>>},{<<15 bytes>>,<<17 bytes>>},{<<15 bytes>>,<<14
>>> bytes>>},{<<6 bytes>>,<<245 bytes>>}],[{<<14 bytes>>,34},{<<6
>>> bytes>>,undefined},{<<14 bytes>>,34},{<<12 bytes>>,{<<11 bytes>>,<<21
>>> bytes>>,[]}},{<<17 bytes>>,undefined},{<<13 bytes>>,...
>>>
>>> Can you point me out how to (ideally) make use of moved_temporarily/2
>>>or
>>> how I can prevent cowboy_rest from wanting to reply with 204 in this
>>>case?
>>
>>moved_temporarily is only called if the resource previously existed.
>>
>>As for calling reply yourself, you just need to return {halt, NewReq,
>>State} afterwards.
>>
>>-- 
>>Lo?c Hoguin
>>Erlang Cowboy
>>Nine Nines
>>http://ninenines.eu
>



From daniel.goertzen at gmail.com  Tue Oct 29 21:25:54 2013
From: daniel.goertzen at gmail.com (Daniel Goertzen)
Date: Tue, 29 Oct 2013 15:25:54 -0500
Subject: [99s-extend] REST handler failure
Message-ID: <CAJCf5Rz0mKmouz5DEunOOZ+b21bfLCjyQy7ssbHAgUp+3rGCaw@mail.gmail.com>

My situation is that I have a rest handler that may fail due to invalid url
segments.  Example situation:


init(_Transport, _Req, _Opts) ->
        {upgrade, protocol, cowboy_rest}.

content_types_provided(Req, State) ->
    {[{<<"application/json">>, get_json}], Req, State}.

get_json(Req0, State) ->
    {Params, Req1} = lists:mapfoldl(fun cowboy_req:binding/2, Req0,
[param1, param2, param3, ....]),

    case catch other_module:request(Params) of
        {'EXIT', {badarg, _}} ->
            hmmm, Params were bad and I would like to return a 404 code now.
        Result ->
            {jiffy:encode(Result), Req1, State}
    end.



So I would like to return a 404 code when my underlying request function
fails, but it appears my choices are:

- return a 200 (ok) response with data.
- crash and cause a 500 (Internal Server Error) response to be returned.
Not exactly the sentiment I want.


Is there some other way to cause a 404 response?

I realize I could add path constraint functions, but I will be replicating
logic from my underlying request function.  Furthermore, the constraint
functions consider parameters in isolation, so that won't work if the
validity of parameters is coupled.

Thanks,
Dan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131029/a9204600/attachment.html>

From ivan at llaisdy.com  Tue Oct 29 22:01:30 2013
From: ivan at llaisdy.com (Ivan uemlianin)
Date: Tue, 29 Oct 2013 22:01:30 +0100
Subject: [99s-extend] REST handler failure
In-Reply-To: <CAJCf5Rz0mKmouz5DEunOOZ+b21bfLCjyQy7ssbHAgUp+3rGCaw@mail.gmail.com>
References: <CAJCf5Rz0mKmouz5DEunOOZ+b21bfLCjyQy7ssbHAgUp+3rGCaw@mail.gmail.com>
Message-ID: <[email protected]>

Sorry for terse but I only have a phone. Why can't you return a 404 here?  Using something like cowboy:reply(404, ...

Ivan

--
festina lente


On 29 Oct 2013, at 21:25, Daniel Goertzen <daniel.goertzen at gmail.com> wrote:

> My situation is that I have a rest handler that may fail due to invalid url segments.  Example situation:
> 
> 
> init(_Transport, _Req, _Opts) ->
>         {upgrade, protocol, cowboy_rest}.
> 
> content_types_provided(Req, State) ->
>     {[{<<"application/json">>, get_json}], Req, State}.
> 
> get_json(Req0, State) ->
>     {Params, Req1} = lists:mapfoldl(fun cowboy_req:binding/2, Req0, [param1, param2, param3, ....]),
> 
>     case catch other_module:request(Params) of
>         {'EXIT', {badarg, _}} ->
>             hmmm, Params were bad and I would like to return a 404 code now.
>         Result ->
>             {jiffy:encode(Result), Req1, State}
>     end.
> 
> 
> 
> So I would like to return a 404 code when my underlying request function fails, but it appears my choices are:
> 
> - return a 200 (ok) response with data.
> - crash and cause a 500 (Internal Server Error) response to be returned.  Not exactly the sentiment I want.
> 
> 
> Is there some other way to cause a 404 response?
> 
> I realize I could add path constraint functions, but I will be replicating logic from my underlying request function.  Furthermore, the constraint functions consider parameters in isolation, so that won't work if the validity of parameters is coupled.
> 
> Thanks,
> Dan.
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131029/3df30c1d/attachment.html>

From daniel.goertzen at gmail.com  Wed Oct 30 15:58:41 2013
From: daniel.goertzen at gmail.com (Daniel Goertzen)
Date: Wed, 30 Oct 2013 09:58:41 -0500
Subject: [99s-extend] REST handler failure
In-Reply-To: <[email protected]>
References: <CAJCf5Rz0mKmouz5DEunOOZ+b21bfLCjyQy7ssbHAgUp+3rGCaw@mail.gmail.com>
 <[email protected]>
Message-ID: <CAJCf5RzwUz1moQooTpMp33tFn8R9xkhxqOnR0joBSUSTwJ_CoQ@mail.gmail.com>

Well, this sort of works.  I tried this in the response handler:

            {ok, Req2} = cowboy_req:reply(404, [] , <<"this is the body
that gets used">>, Req1),
            {<<"this body gets ignored">>, Req2, State};



The client receives a 404 response, but cowboy crashes:

=ERROR REPORT==== 8-Sep-2013::22:22:03 ===
Error in process <0.131.0> with exit value:
{function_clause,[{cowboy_req,reply,[200,[],<<31
bytes>>,{http_req,#Port<0.1208>,ranch_tcp,keepalive,<0.131.0>,<<3
bytes>>,'HTTP/1.1',{{192,168,1,187},51017},<<12 bytes>>,undefined,80,<<24
bytes>>,undefined,<<0 bytes>>,undefined,[{channel_num,3}],[{<<10
bytes>>,<<11 bytes>>},{<<4 bytes>>,<<12 bytes>>},{<<6 bytes>>,<<3
bytes>>}],[{<<17 bytes>>,undefined},{<<13 bytes>>,undefined},{<<19
bytes>>,undefined},{<<8 bytes>>,undefined},{<<6 bytes>>,[...



The issue is that the REST wrapper wants to do the cowboy_req:reply(), and
when we do the call we cause the wrapper's call to fail.

Dan.



On Tue, Oct 29, 2013 at 4:01 PM, Ivan uemlianin <ivan at llaisdy.com> wrote:

> Sorry for terse but I only have a phone. Why can't you return a 404 here?
>  Using something like cowboy:reply(404, ...
>
> Ivan
>
> --
> festina lente
>
>
> On 29 Oct 2013, at 21:25, Daniel Goertzen <daniel.goertzen at gmail.com>
> wrote:
>
> My situation is that I have a rest handler that may fail due to invalid
> url segments.  Example situation:
>
>
> init(_Transport, _Req, _Opts) ->
>         {upgrade, protocol, cowboy_rest}.
>
> content_types_provided(Req, State) ->
>     {[{<<"application/json">>, get_json}], Req, State}.
>
> get_json(Req0, State) ->
>     {Params, Req1} = lists:mapfoldl(fun cowboy_req:binding/2, Req0,
> [param1, param2, param3, ....]),
>
>     case catch other_module:request(Params) of
>         {'EXIT', {badarg, _}} ->
>             hmmm, Params were bad and I would like to return a 404 code
> now.
>         Result ->
>             {jiffy:encode(Result), Req1, State}
>     end.
>
>
>
> So I would like to return a 404 code when my underlying request function
> fails, but it appears my choices are:
>
> - return a 200 (ok) response with data.
> - crash and cause a 500 (Internal Server Error) response to be returned.
> Not exactly the sentiment I want.
>
>
> Is there some other way to cause a 404 response?
>
> I realize I could add path constraint functions, but I will be replicating
> logic from my underlying request function.  Furthermore, the constraint
> functions consider parameters in isolation, so that won't work if the
> validity of parameters is coupled.
>
> Thanks,
> Dan.
>
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131030/460453c8/attachment.html>

From tilman.holschuh at gmail.com  Wed Oct 30 16:25:02 2013
From: tilman.holschuh at gmail.com (Tilman Holschuh)
Date: Wed, 30 Oct 2013 08:25:02 -0700
Subject: [99s-extend] REST handler failure
In-Reply-To: <CAJCf5RzwUz1moQooTpMp33tFn8R9xkhxqOnR0joBSUSTwJ_CoQ@mail.gmail.com>
References: <CAJCf5Rz0mKmouz5DEunOOZ+b21bfLCjyQy7ssbHAgUp+3rGCaw@mail.gmail.com>
 <[email protected]>
 <CAJCf5RzwUz1moQooTpMp33tFn8R9xkhxqOnR0joBSUSTwJ_CoQ@mail.gmail.com>
Message-ID: <[email protected]>

Why not let resource_exists/2 return false when your resource does not exist? You will get 404 on false. This way you separate the implementation for turning your data to json from checking if the request went to the correct resource. 

- Tilman

On 2013-10-30, at 7:58 AM, Daniel Goertzen wrote:

> Well, this sort of works.  I tried this in the response handler:
> 
>             {ok, Req2} = cowboy_req:reply(404, [] , <<"this is the body that gets used">>, Req1),
>             {<<"this body gets ignored">>, Req2, State};
> 
> 
> 
> The client receives a 404 response, but cowboy crashes:
> 
> =ERROR REPORT==== 8-Sep-2013::22:22:03 ===
> Error in process <0.131.0> with exit value: {function_clause,[{cowboy_req,reply,[200,[],<<31 bytes>>,{http_req,#Port<0.1208>,ranch_tcp,keepalive,<0.131.0>,<<3 bytes>>,'HTTP/1.1',{{192,168,1,187},51017},<<12 bytes>>,undefined,80,<<24 bytes>>,undefined,<<0 bytes>>,undefined,[{channel_num,3}],[{<<10 bytes>>,<<11 bytes>>},{<<4 bytes>>,<<12 bytes>>},{<<6 bytes>>,<<3 bytes>>}],[{<<17 bytes>>,undefined},{<<13 bytes>>,undefined},{<<19 bytes>>,undefined},{<<8 bytes>>,undefined},{<<6 bytes>>,[... 
> 
> 
> 
> The issue is that the REST wrapper wants to do the cowboy_req:reply(), and when we do the call we cause the wrapper's call to fail.
> 
> Dan.
> 
> 
> 
> On Tue, Oct 29, 2013 at 4:01 PM, Ivan uemlianin <ivan at llaisdy.com> wrote:
> Sorry for terse but I only have a phone. Why can't you return a 404 here?  Using something like cowboy:reply(404, ...
> 
> Ivan
> 
> --
> festina lente
> 
> 
> On 29 Oct 2013, at 21:25, Daniel Goertzen <daniel.goertzen at gmail.com> wrote:
> 
>> My situation is that I have a rest handler that may fail due to invalid url segments.  Example situation:
>> 
>> 
>> init(_Transport, _Req, _Opts) ->
>>         {upgrade, protocol, cowboy_rest}.
>> 
>> content_types_provided(Req, State) ->
>>     {[{<<"application/json">>, get_json}], Req, State}.
>> 
>> get_json(Req0, State) ->
>>     {Params, Req1} = lists:mapfoldl(fun cowboy_req:binding/2, Req0, [param1, param2, param3, ....]),
>> 
>>     case catch other_module:request(Params) of
>>         {'EXIT', {badarg, _}} ->
>>             hmmm, Params were bad and I would like to return a 404 code now.
>>         Result ->
>>             {jiffy:encode(Result), Req1, State}
>>     end.
>> 
>> 
>> 
>> So I would like to return a 404 code when my underlying request function fails, but it appears my choices are:
>> 
>> - return a 200 (ok) response with data.
>> - crash and cause a 500 (Internal Server Error) response to be returned.  Not exactly the sentiment I want.
>> 
>> 
>> Is there some other way to cause a 404 response?
>> 
>> I realize I could add path constraint functions, but I will be replicating logic from my underlying request function.  Furthermore, the constraint functions consider parameters in isolation, so that won't work if the validity of parameters is coupled.
>> 
>> Thanks,
>> Dan.
>> _______________________________________________
>> Extend mailing list
>> Extend at lists.ninenines.eu
>> http://lists.ninenines.eu:81/listinfo/extend
> 
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend



From ivan at llaisdy.com  Wed Oct 30 16:27:15 2013
From: ivan at llaisdy.com (Ivan uemlianin)
Date: Wed, 30 Oct 2013 16:27:15 +0100
Subject: [99s-extend] REST handler failure
In-Reply-To: <CAJCf5RzwUz1moQooTpMp33tFn8R9xkhxqOnR0joBSUSTwJ_CoQ@mail.gmail.com>
References: <CAJCf5Rz0mKmouz5DEunOOZ+b21bfLCjyQy7ssbHAgUp+3rGCaw@mail.gmail.com>
 <[email protected]>
 <CAJCf5RzwUz1moQooTpMp33tFn8R9xkhxqOnR0joBSUSTwJ_CoQ@mail.gmail.com>
Message-ID: <[email protected]>

Instead of <<"this body ignored">> can you return the atom halt?

#dontevenhaveanyofmycodewithme:(

Ivan

--
festina lente


On 30 Oct 2013, at 15:58, Daniel Goertzen <daniel.goertzen at gmail.com> wrote:

> Well, this sort of works.  I tried this in the response handler:
> 
>             {ok, Req2} = cowboy_req:reply(404, [] , <<"this is the body that gets used">>, Req1),
>             {<<"this body gets ignored">>, Req2, State};
> 
> 
> 
> The client receives a 404 response, but cowboy crashes:
> 
> =ERROR REPORT==== 8-Sep-2013::22:22:03 ===
> Error in process <0.131.0> with exit value: {function_clause,[{cowboy_req,reply,[200,[],<<31 bytes>>,{http_req,#Port<0.1208>,ranch_tcp,keepalive,<0.131.0>,<<3 bytes>>,'HTTP/1.1',{{192,168,1,187},51017},<<12 bytes>>,undefined,80,<<24 bytes>>,undefined,<<0 bytes>>,undefined,[{channel_num,3}],[{<<10 bytes>>,<<11 bytes>>},{<<4 bytes>>,<<12 bytes>>},{<<6 bytes>>,<<3 bytes>>}],[{<<17 bytes>>,undefined},{<<13 bytes>>,undefined},{<<19 bytes>>,undefined},{<<8 bytes>>,undefined},{<<6 bytes>>,[... 
> 
> 
> 
> The issue is that the REST wrapper wants to do the cowboy_req:reply(), and when we do the call we cause the wrapper's call to fail.
> 
> Dan.
> 
> 
> 
> On Tue, Oct 29, 2013 at 4:01 PM, Ivan uemlianin <ivan at llaisdy.com> wrote:
>> Sorry for terse but I only have a phone. Why can't you return a 404 here?  Using something like cowboy:reply(404, ...
>> 
>> Ivan
>> 
>> --
>> festina lente
>> 
>> 
>> On 29 Oct 2013, at 21:25, Daniel Goertzen <daniel.goertzen at gmail.com> wrote:
>> 
>>> My situation is that I have a rest handler that may fail due to invalid url segments.  Example situation:
>>> 
>>> 
>>> init(_Transport, _Req, _Opts) ->
>>>         {upgrade, protocol, cowboy_rest}.
>>> 
>>> content_types_provided(Req, State) ->
>>>     {[{<<"application/json">>, get_json}], Req, State}.
>>> 
>>> get_json(Req0, State) ->
>>>     {Params, Req1} = lists:mapfoldl(fun cowboy_req:binding/2, Req0, [param1, param2, param3, ....]),
>>> 
>>>     case catch other_module:request(Params) of
>>>         {'EXIT', {badarg, _}} ->
>>>             hmmm, Params were bad and I would like to return a 404 code now.
>>>         Result ->
>>>             {jiffy:encode(Result), Req1, State}
>>>     end.
>>> 
>>> 
>>> 
>>> So I would like to return a 404 code when my underlying request function fails, but it appears my choices are:
>>> 
>>> - return a 200 (ok) response with data.
>>> - crash and cause a 500 (Internal Server Error) response to be returned.  Not exactly the sentiment I want.
>>> 
>>> 
>>> Is there some other way to cause a 404 response?
>>> 
>>> I realize I could add path constraint functions, but I will be replicating logic from my underlying request function.  Furthermore, the constraint functions consider parameters in isolation, so that won't work if the validity of parameters is coupled.
>>> 
>>> Thanks,
>>> Dan.
>>> _______________________________________________
>>> Extend mailing list
>>> Extend at lists.ninenines.eu
>>> http://lists.ninenines.eu:81/listinfo/extend
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131030/6e8ec2f0/attachment.html>

From daniel.goertzen at gmail.com  Wed Oct 30 16:32:47 2013
From: daniel.goertzen at gmail.com (Daniel Goertzen)
Date: Wed, 30 Oct 2013 10:32:47 -0500
Subject: [99s-extend] REST handler failure
In-Reply-To: <[email protected]>
References: <CAJCf5Rz0mKmouz5DEunOOZ+b21bfLCjyQy7ssbHAgUp+3rGCaw@mail.gmail.com>
 <[email protected]>
 <CAJCf5RzwUz1moQooTpMp33tFn8R9xkhxqOnR0joBSUSTwJ_CoQ@mail.gmail.com>
 <[email protected]>
Message-ID: <CAJCf5Rx_o66FDE-91kX_=KBQou9wcx+UEenGPFYLE2nR_PRh8g@mail.gmail.com>

Returning 'halt' caused a status code of 204.

Dan.


On Wed, Oct 30, 2013 at 10:27 AM, Ivan uemlianin <ivan at llaisdy.com> wrote:

> Instead of <<"this body ignored">> can you return the atom halt?
>
> #dontevenhaveanyofmycodewithme:(
>
> Ivan
>
> --
> festina lente
>
>
> On 30 Oct 2013, at 15:58, Daniel Goertzen <daniel.goertzen at gmail.com>
> wrote:
>
> Well, this sort of works.  I tried this in the response handler:
>
>             {ok, Req2} = cowboy_req:reply(404, [] , <<"this is the body
> that gets used">>, Req1),
>             {<<"this body gets ignored">>, Req2, State};
>
>
>
> The client receives a 404 response, but cowboy crashes:
>
> =ERROR REPORT==== 8-Sep-2013::22:22:03 ===
> Error in process <0.131.0> with exit value:
> {function_clause,[{cowboy_req,reply,[200,[],<<31
> bytes>>,{http_req,#Port<0.1208>,ranch_tcp,keepalive,<0.131.0>,<<3
> bytes>>,'HTTP/1.1',{{192,168,1,187},51017},<<12 bytes>>,undefined,80,<<24
> bytes>>,undefined,<<0 bytes>>,undefined,[{channel_num,3}],[{<<10
> bytes>>,<<11 bytes>>},{<<4 bytes>>,<<12 bytes>>},{<<6 bytes>>,<<3
> bytes>>}],[{<<17 bytes>>,undefined},{<<13 bytes>>,undefined},{<<19
> bytes>>,undefined},{<<8 bytes>>,undefined},{<<6 bytes>>,[...
>
>
>
> The issue is that the REST wrapper wants to do the cowboy_req:reply(), and
> when we do the call we cause the wrapper's call to fail.
>
> Dan.
>
>
>
> On Tue, Oct 29, 2013 at 4:01 PM, Ivan uemlianin <ivan at llaisdy.com> wrote:
>
>> Sorry for terse but I only have a phone. Why can't you return a 404 here?
>>  Using something like cowboy:reply(404, ...
>>
>> Ivan
>>
>> --
>> festina lente
>>
>>
>> On 29 Oct 2013, at 21:25, Daniel Goertzen <daniel.goertzen at gmail.com>
>> wrote:
>>
>> My situation is that I have a rest handler that may fail due to invalid
>> url segments.  Example situation:
>>
>>
>> init(_Transport, _Req, _Opts) ->
>>         {upgrade, protocol, cowboy_rest}.
>>
>> content_types_provided(Req, State) ->
>>     {[{<<"application/json">>, get_json}], Req, State}.
>>
>> get_json(Req0, State) ->
>>     {Params, Req1} = lists:mapfoldl(fun cowboy_req:binding/2, Req0,
>> [param1, param2, param3, ....]),
>>
>>     case catch other_module:request(Params) of
>>         {'EXIT', {badarg, _}} ->
>>             hmmm, Params were bad and I would like to return a 404 code
>> now.
>>         Result ->
>>             {jiffy:encode(Result), Req1, State}
>>     end.
>>
>>
>>
>> So I would like to return a 404 code when my underlying request function
>> fails, but it appears my choices are:
>>
>> - return a 200 (ok) response with data.
>> - crash and cause a 500 (Internal Server Error) response to be returned.
>> Not exactly the sentiment I want.
>>
>>
>> Is there some other way to cause a 404 response?
>>
>> I realize I could add path constraint functions, but I will be
>> replicating logic from my underlying request function.  Furthermore, the
>> constraint functions consider parameters in isolation, so that won't work
>> if the validity of parameters is coupled.
>>
>> Thanks,
>> Dan.
>>
>> _______________________________________________
>> Extend mailing list
>> Extend at lists.ninenines.eu
>> http://lists.ninenines.eu:81/listinfo/extend
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131030/0ab7c8ee/attachment.html>

From daniel.goertzen at gmail.com  Wed Oct 30 16:46:37 2013
From: daniel.goertzen at gmail.com (Daniel Goertzen)
Date: Wed, 30 Oct 2013 10:46:37 -0500
Subject: [99s-extend] REST handler failure
In-Reply-To: <[email protected]>
References: <CAJCf5Rz0mKmouz5DEunOOZ+b21bfLCjyQy7ssbHAgUp+3rGCaw@mail.gmail.com>
 <[email protected]>
 <CAJCf5RzwUz1moQooTpMp33tFn8R9xkhxqOnR0joBSUSTwJ_CoQ@mail.gmail.com>
 <[email protected]>
Message-ID: <CAJCf5RzwO4nNcv=2Ezf7aMQqFShPhLs4zaYoBBunmzuC7Wp4uQ@mail.gmail.com>

That's what I was looking for, thanks!

Dan.


On Wed, Oct 30, 2013 at 10:25 AM, Tilman Holschuh <tilman.holschuh at gmail.com
> wrote:

> Why not let resource_exists/2 return false when your resource does not
> exist? You will get 404 on false. This way you separate the implementation
> for turning your data to json from checking if the request went to the
> correct resource.
>
> - Tilman
>
> On 2013-10-30, at 7:58 AM, Daniel Goertzen wrote:
>
> > Well, this sort of works.  I tried this in the response handler:
> >
> >             {ok, Req2} = cowboy_req:reply(404, [] , <<"this is the body
> that gets used">>, Req1),
> >             {<<"this body gets ignored">>, Req2, State};
> >
> >
> >
> > The client receives a 404 response, but cowboy crashes:
> >
> > =ERROR REPORT==== 8-Sep-2013::22:22:03 ===
> > Error in process <0.131.0> with exit value:
> {function_clause,[{cowboy_req,reply,[200,[],<<31
> bytes>>,{http_req,#Port<0.1208>,ranch_tcp,keepalive,<0.131.0>,<<3
> bytes>>,'HTTP/1.1',{{192,168,1,187},51017},<<12 bytes>>,undefined,80,<<24
> bytes>>,undefined,<<0 bytes>>,undefined,[{channel_num,3}],[{<<10
> bytes>>,<<11 bytes>>},{<<4 bytes>>,<<12 bytes>>},{<<6 bytes>>,<<3
> bytes>>}],[{<<17 bytes>>,undefined},{<<13 bytes>>,undefined},{<<19
> bytes>>,undefined},{<<8 bytes>>,undefined},{<<6 bytes>>,[...
> >
> >
> >
> > The issue is that the REST wrapper wants to do the cowboy_req:reply(),
> and when we do the call we cause the wrapper's call to fail.
> >
> > Dan.
> >
> >
> >
> > On Tue, Oct 29, 2013 at 4:01 PM, Ivan uemlianin <ivan at llaisdy.com>
> wrote:
> > Sorry for terse but I only have a phone. Why can't you return a 404
> here?  Using something like cowboy:reply(404, ...
> >
> > Ivan
> >
> > --
> > festina lente
> >
> >
> > On 29 Oct 2013, at 21:25, Daniel Goertzen <daniel.goertzen at gmail.com>
> wrote:
> >
> >> My situation is that I have a rest handler that may fail due to invalid
> url segments.  Example situation:
> >>
> >>
> >> init(_Transport, _Req, _Opts) ->
> >>         {upgrade, protocol, cowboy_rest}.
> >>
> >> content_types_provided(Req, State) ->
> >>     {[{<<"application/json">>, get_json}], Req, State}.
> >>
> >> get_json(Req0, State) ->
> >>     {Params, Req1} = lists:mapfoldl(fun cowboy_req:binding/2, Req0,
> [param1, param2, param3, ....]),
> >>
> >>     case catch other_module:request(Params) of
> >>         {'EXIT', {badarg, _}} ->
> >>             hmmm, Params were bad and I would like to return a 404 code
> now.
> >>         Result ->
> >>             {jiffy:encode(Result), Req1, State}
> >>     end.
> >>
> >>
> >>
> >> So I would like to return a 404 code when my underlying request
> function fails, but it appears my choices are:
> >>
> >> - return a 200 (ok) response with data.
> >> - crash and cause a 500 (Internal Server Error) response to be
> returned.  Not exactly the sentiment I want.
> >>
> >>
> >> Is there some other way to cause a 404 response?
> >>
> >> I realize I could add path constraint functions, but I will be
> replicating logic from my underlying request function.  Furthermore, the
> constraint functions consider parameters in isolation, so that won't work
> if the validity of parameters is coupled.
> >>
> >> Thanks,
> >> Dan.
> >> _______________________________________________
> >> Extend mailing list
> >> Extend at lists.ninenines.eu
> >> http://lists.ninenines.eu:81/listinfo/extend
> >
> > _______________________________________________
> > Extend mailing list
> > Extend at lists.ninenines.eu
> > http://lists.ninenines.eu:81/listinfo/extend
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20131030/3ea4ac64/attachment.html>