interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / aienux / allen / tests / http.om

105 lines · 2763 bytes Raw Blame History
1note HTTP response boundary tests; concatenate after base.om, github.om, http.om, tests/check.om.
2note Fixtures are protocol data only. This gate makes no network or TLS qualification claim.
3text Hcases "HTTP/1.1 200 OK\nContent-Length: 5\n\nhello|HTTP/1.1 200 OK\nTransfer-Encoding: chunked\n\n2;ext=yes\nhe\n3\nllo\n0\nX-Trace: safe\n\n|HTTP/1.1 200 OK\nContent-Length: 5\nContent-Length: 5\n\nhello|HTTP/1.1 200 OK\nContent-Length: 5\nTransfer-Encoding: chunked\n\n|HTTP/1.1 200 OK\nContent-Encoding: gzip\nContent-Length: 5\n\nhello|HTTP/1.1 200 OK\nContent-Length: 9999999999999999999999999\n\n|HTTP/1.1 200 OK\n\nhello|HTTP/1.1 200 OK\nContent-Length: 5\n\nhell|HTTP/1.1 200 OK\nTransfer-Encoding: chunked\n\n1\nh\n0\nContent-Length: 0\n\n|HTTP/1.1 103 Early Hints\nLink: x\n\nHTTP/1.1 200 OK\nContent-Length: 5\n\nhello|HTTP/1.1 200 OK\nContent-Length: 0\n\nx|HTTP/1.1 200 OK\nTransfer-Encoding: chunked\n\n6\nhello!\n0\n\n|HTTP/1.1 204 No Content\nContent-Length: 4\n\n|HTTP/1.1 403 Forbidden\nContent-Length: 2\n\n{}|HTTP/1.1 200 OK\nTransfer-Encoding: chunked, gzip\n\n|HTTP/1.1 200 OK\nBad Header: x\n\n|"
4text Hpath "/repos/aien-dev/allen"
5text Hhello "hello"
6fn htbegin cap ulong to void
7for i ulong len Hpath
8put Ghpath i get Hpath i
9end
10check httpstart 1 42 0 cap len Hpath 1
11end
12fn htpush c uchar to void
13put Hchunk 0 c
14ok = httpfeed 1
15end
16fn htcase wanted ulong to void
17index = ulong 0
18for i ulong len Hcases
19c = get Hcases i
20if eq c 124
21if eq index wanted
22ret
23end
24index = add index 1
25else
26if eq index wanted
27if eq c 10
28htpush 13
29end
30htpush c
31end
32end
33end
34end
35fn htgood id ulong to void
36check eq get Hstate 0 2 id
37check eq get Hstate 2 5 add id 1
38ok = true
39for i ulong 5
40if ne get Ghbody i get Hhello i
41ok = false
42end
43end
44check ok add id 2
45check eq get Hstate 3 42 add id 3
46end
47fn main to int
48htbegin 5
49htcase 0
50htgood 10
51htbegin 5
52htcase 1
53htgood 20
54for i ulong 4
55htbegin 5
56htcase add i 2
57check eq get Hstate 0 3 add 30 i
58end
59htbegin 5
60htcase 6
61check eq get Hstate 0 1 40
62check httpend true 41
63htgood 42
64htbegin 5
65htcase 6
66check not httpend false 46
67check eq get Hstate 0 3 47
68htbegin 5
69htcase 7
70check not httpend true 50
71check eq get Hstate 0 3 51
72htbegin 5
73htcase 8
74check eq get Hstate 0 3 52
75htbegin 5
76htcase 9
77htgood 60
78for i ulong 3
79htbegin 5
80htcase add i 10
81check eq get Hstate 0 3 add 70 i
82end
83htbegin 5
84htcase 13
85check eq get Hstate 0 2 80
86check eq get Hstate 1 403 81
87check eq get Hstate 2 2 82
88for i ulong 2
89htbegin 5
90htcase add i 14
91check eq get Hstate 0 3 add 85 i
92end
93htbegin 5
94htpush 10
95check eq get Hstate 0 3 90
96htbegin 5
97put Ghpath 1 13
98check not httpstart 1 43 0 5 len Hpath 91
99check eq get Httpreqn 0 0 92
100htbegin 5
101put Ghpath 1 35
102check not httpstart 1 43 0 5 len Hpath 93
103check eq get Httpreqn 0 0 94
104ret int get Fails 0
105end