-
Notifications
You must be signed in to change notification settings - Fork 7
/
http.m
59 lines (52 loc) · 1.47 KB
/
http.m
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
# hypertext transfer protocol
test _ =
sock = Socket 0
Socket.connect sock 'jigsaw.w3.org' 80
request = S.fill 'GET / HTTP/1.1
Host: jigsaw.w3.org
' []
File.out sock.File.of request
#
HTTP/1.1 200 OK
Content-Type: text/plain
Date: Sun, 08 May 2016 14:39:55 GMT
Server: Google Frontend
Content-Length: 15
24.130.149.219
Fact.do $Fun (Regex.search 'HTTP/1.. 200 OK' (File.in_size sock.File.of 1000))
0
# ?chunk_size is broken - http://httpbin.org/range/1024?chunk_size=10
test2 _ =
sock = Socket 0
Socket.connect sock 'jigsaw.w3.org' 80
request = S.fill 'GET /HTTP/ChunkedScript HTTP/1.1
Host: httpbin.org
' []
# request . Log
File.out sock.File.of request
# 2000...
File.in_size sock.File.of 40 . Log
0
# https://tools.ietf.org/html/rfc7230#section-4.2 # 4.2. Compression Codings
test3 _ =
sock = Socket 0
Socket.connect sock 'httpbin.org' 80
# curl httpbin.org/deflate
request = S.fill 'GET /deflate HTTP/1.1
Host: httpbin.org
' []
File.out sock.File.of request
b = File.in_size sock.File.of 10000
# {"deflated": true, "headers": {"Host": "httpbin.org"}, "method": "GET", "origin": "108.245.44.219"}
#
{
"deflated": true,
"headers": {
"Host": "httpbin.org"
},
"method": "GET",
"origin": "24.130.149.219"
}
# fixme - httpbin.org now only accepts https (not http)
#Fact.do $Fun (Regex.search '"deflated": true,' (uncompress (S.drop (S.str b "\!\.\!\.") 4) 1000))
0