Annotation of freem/mlib/%NETHTTP.m, revision 1.1.1.1
1.1 snw 1: %NET.HTTP ;VCL/JPW-FREEM HTTP SYSTEM LIBRARY; 10/23/2020 6:55 PM
2: ;0.0;FreeM;****FREEM**;John P Willis @2020
3: ;
4: ; *
5: ; * *
6: ; * *
7: ; ***************
8: ; * * * *
9: ; * MUMPS *
10: ; * * * *
11: ; ***************
12: ; * *
13: ; * *
14: ; *
15: ;
16: ; %HTTP.m
17: ; FreeM HTTP system library
18: ;
19: ;
20: ; Author: John P. Willis <jpw@coherent-logic.com>
21: ; Copyright (C) 1998 MUG Deutschland
22: ; Copyright (C) 2020 Coherent Logic Development LLC
23: ;
24: ;
25: ; This file is part of FreeM.
26: ;
27: ; FreeM is free software: you can redistribute it and/or modify
28: ; it under the terms of the GNU Affero Public License as published by
29: ; the Free Software Foundation, either version 3 of the License, or
30: ; (at your option) any later version.
31: ;
32: ; FreeM is distributed in the hope that it will be useful,
33: ; but WITHOUT ANY WARRANTY; without even the implied warranty of
34: ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35: ; GNU Affero Public License for more details.
36: ;
37: ; You should have received a copy of the GNU Affero Public License
38: ; along with FreeM. If not, see <https://www.gnu.org/licenses/>.
39: ;
40: ;
41: QUIT
42: ;
43: ;
44: GET(URL) ; HTTP GET
45: ;
46: ; SET UP ERROR TRAP
47: ;
48: N OET S OET=$ZTRAP S $ZTRAP="GETERR^%HTTP"
49: ; INIT TERMINATION SEQUENCE
50: N CH,%,LN S CH=255,^$DEVICE(CH,"TERMINATOR")=$C(13,10),LN=0
51: ; PARSE URL
52: N PROTO S PROTO=$P(URL,":",1)
53: N SRV,HOST,PRT S SRV=$P(URL,"/",3) I $L(SRV,":") S PRT=$P(SRV,":",2),HOST=$P(SRV,":",1) E S HOST=SRV,PRT=80
54: N PTH I $L(URL,"/")>3 S PTH=$P(URL,"/",4) E S PTH="/"
55: I PROTO'="http" K % W "Protocol "_PROTO_" not supported.",! G GETERR
56: ; OPEN CONNECTION TO SERVER
57: O CH:HOST_":"_PRT_":IPV4:TCP"
58: U CH:/CONNECT
59: ; SEND GET COMMAND
60: W "GET "_PTH_" HTTP/1.1",!,"Host: "_HOST,!,!
61: ;
62: ;
63: GETERR U $P C CH K % S $ZTRAP=OET Q 0
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>