Skip to content

Commit 1f25d86

Browse files
committed
feat: add tests and contemplate streaming-hit
1 parent d7f5c8b commit 1f25d86

File tree

17 files changed

+657
-302
lines changed

17 files changed

+657
-302
lines changed

assets/embed.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ var (
3030
//go:embed examples/cached.txt
3131
VCLCached string
3232

33+
//go:embed examples/streaming-hit.txt
34+
VCLStreamingHit string
35+
3336
//go:embed examples/esi-1.txt
3437
VCLESI1 string
3538

assets/examples/backend-retry.txt

Lines changed: 57 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
* << Session >> 1
1+
* << Session >> 1
22
- Begin sess 0 HTTP/1
3-
- SessOpen 192.168.65.1 42108 http 192.168.50.10 80 1762954000.458467 22
3+
- SessOpen 192.168.65.1 17271 http 192.168.50.10 80 1763028889.799021 24
44
- Link req 2 rxreq
5-
- SessClose REM_CLOSE 0.004
6-
- End
7-
** << Request >> 2
5+
- SessClose REM_CLOSE 0.001
6+
- End
7+
** << Request >> 2
88
-- Begin req 1 rxreq
9-
-- Timestamp Start: 1762954000.458642 0.000000 0.000000
10-
-- Timestamp Req: 1762954000.458642 0.000000 0.000000
9+
-- Timestamp Start: 1763028889.799053 0.000000 0.000000
10+
-- Timestamp Req: 1763028889.799053 0.000000 0.000000
1111
-- VCL_use boot
12-
-- ReqStart 192.168.65.1 42108 http
12+
-- ReqStart 192.168.65.1 17271 http
1313
-- ReqMethod GET
1414
-- ReqURL /rbt
1515
-- ReqProtocol HTTP/1.1
1616
-- ReqHeader Host: varnishlog.iou.re
1717
-- ReqHeader Accept: */*
1818
-- ReqHeader User-Agent: hurl/7.0.0
1919
-- ReqHeader X-Forwarded-For: 192.168.65.1
20-
-- ReqHeader Via: 1.1 26f88e4aab50 (Varnish/7.7)
20+
-- ReqHeader Via: 1.1 4b1d1831226f (Varnish/7.7)
2121
-- VCL_call RECV
2222
-- VCL_Log start custom recv
23-
-- ReqHeader whoami: 1
2423
-- ReqHeader x-do-retry: yes
2524
-- VCL_Log end custom recv
2625
-- VCL_return hash
@@ -29,105 +28,105 @@
2928
-- VCL_call MISS
3029
-- VCL_return fetch
3130
-- Link bereq 3 fetch
32-
-- Timestamp Fetch: 1762954000.461894 0.003251 0.003251
31+
-- Timestamp Fetch: 1763028889.799810 0.000756 0.000756
3332
-- RespProtocol HTTP/1.1
3433
-- RespStatus 200
3534
-- RespReason OK
36-
-- RespHeader Date: Wed, 12 Nov 2025 13:26:40 GMT
37-
-- RespHeader Content-Length: 315
35+
-- RespHeader Date: Thu, 13 Nov 2025 10:14:49 GMT
36+
-- RespHeader Content-Length: 323
3837
-- RespHeader Content-Type: text/plain; charset=utf-8
39-
-- RespHeader Cache-Control: max-age=5
4038
-- RespHeader X-Varnish: 2
4139
-- RespHeader Age: 0
42-
-- RespHeader Via: 1.1 26f88e4aab50 (Varnish/7.7)
40+
-- RespHeader Via: 1.1 4b1d1831226f (Varnish/7.7)
4341
-- RespHeader Accept-Ranges: bytes
4442
-- VCL_call DELIVER
4543
-- VCL_return deliver
46-
-- Timestamp Process: 1762954000.461914 0.003272 0.000020
47-
-- Filters
44+
-- Timestamp Process: 1763028889.799817 0.000763 0.000007
45+
-- Filters
4846
-- RespHeader Connection: keep-alive
49-
-- Timestamp Resp: 1762954000.461997 0.003355 0.000083
50-
-- ReqAcct 83 0 83 249 315 564
51-
-- End
52-
*** << BeReq >> 3
47+
-- Timestamp Resp: 1763028889.799838 0.000784 0.000020
48+
-- ReqAcct 83 0 83 223 323 546
49+
-- End
50+
*** << BeReq >> 3
5351
--- Begin bereq 2 fetch
5452
--- VCL_use boot
55-
--- Timestamp Start: 1762954000.458817 0.000000 0.000000
53+
--- Timestamp Start: 1763028889.799103 0.000000 0.000000
5654
--- BereqMethod GET
5755
--- BereqURL /rbt
5856
--- BereqProtocol HTTP/1.1
5957
--- BereqHeader Host: varnishlog.iou.re
6058
--- BereqHeader Accept: */*
6159
--- BereqHeader User-Agent: hurl/7.0.0
6260
--- BereqHeader X-Forwarded-For: 192.168.65.1
63-
--- BereqHeader Via: 1.1 26f88e4aab50 (Varnish/7.7)
64-
--- BereqHeader whoami: 1
61+
--- BereqHeader Via: 1.1 4b1d1831226f (Varnish/7.7)
6562
--- BereqHeader x-do-retry: yes
6663
--- BereqHeader Accept-Encoding: gzip
6764
--- BereqHeader X-Varnish: 3
6865
--- VCL_call BACKEND_FETCH
6966
--- VCL_return fetch
70-
--- Timestamp Fetch: 1762954000.458845 0.000027 0.000027
71-
--- Timestamp Connected: 1762954000.459225 0.000407 0.000379
72-
--- BackendOpen 30 whoami 192.168.50.11 80 192.168.50.10 50338 connect
73-
--- Timestamp Bereq: 1762954000.459291 0.000473 0.000066
67+
--- Timestamp Fetch: 1763028889.799112 0.000009 0.000009
68+
--- Timestamp Connected: 1763028889.799176 0.000073 0.000064
69+
--- BackendOpen 30 backend1 192.168.50.11 80 192.168.50.10 54710 connect
70+
--- Timestamp Bereq: 1763028889.799194 0.000091 0.000017
7471
--- BerespProtocol HTTP/1.1
7572
--- BerespStatus 200
7673
--- BerespReason OK
77-
--- BerespHeader Date: Wed, 12 Nov 2025 13:26:40 GMT
78-
--- BerespHeader Content-Length: 311
79-
--- BerespHeader Content-Type: text/plain; charset=utf-8
80-
--- Timestamp Beresp: 1762954000.460562 0.001744 0.001270
81-
--- TTL RFC 120 10 0 1762954000 1762954000 1762954000 0 0 cacheable
74+
--- BerespHeader Date: Thu, 13 Nov 2025 10:14:49 GMT
75+
--- BerespHeader Server: Varnish
76+
--- BerespHeader X-Varnish: 2
77+
--- BerespHeader Content-Type: text/plain
78+
--- BerespHeader X-Default-Response: yes
79+
--- BerespHeader Content-Length: 16
80+
--- BerespHeader Connection: keep-alive
81+
--- Timestamp Beresp: 1763028889.799297 0.000194 0.000103
82+
--- TTL RFC 120 10 0 1763028890 1763028890 1763028889 0 0 cacheable
8283
--- VCL_call BACKEND_RESPONSE
83-
--- BerespHeader Cache-Control: max-age=5
84-
--- TTL VCL 5 10 0 1762954000 cacheable
84+
--- BereqHeader x-retry-whoami: 1
8585
--- VCL_return retry
86-
--- BackendClose 30 whoami close RESP_CLOSE
87-
--- Timestamp Retry: 1762954000.460663 0.001845 0.000101
86+
--- BackendClose 30 backend1 close RESP_CLOSE
87+
--- Timestamp Retry: 1763028889.799324 0.000221 0.000027
8888
--- Link bereq 32769 retry
89-
--- End
90-
*4* << BeReq >> 32769
89+
--- End
90+
*4* << BeReq >> 32769
9191
-4- Begin bereq 3 retry
92-
-4- Timestamp Start: 1762954000.460663 0.001845 0.000000
92+
-4- Timestamp Start: 1763028889.799324 0.000221 0.000000
9393
-4- BereqMethod GET
9494
-4- BereqURL /rbt
9595
-4- BereqProtocol HTTP/1.1
9696
-4- BereqHeader Host: varnishlog.iou.re
9797
-4- BereqHeader Accept: */*
9898
-4- BereqHeader User-Agent: hurl/7.0.0
9999
-4- BereqHeader X-Forwarded-For: 192.168.65.1
100-
-4- BereqHeader Via: 1.1 26f88e4aab50 (Varnish/7.7)
101-
-4- BereqHeader whoami: 1
100+
-4- BereqHeader Via: 1.1 4b1d1831226f (Varnish/7.7)
102101
-4- BereqHeader x-do-retry: yes
103102
-4- BereqHeader Accept-Encoding: gzip
104103
-4- BereqHeader X-Varnish: 3
104+
-4- BereqHeader x-retry-whoami: 1
105105
-4- BereqUnset X-Varnish: 3
106106
-4- BereqHeader X-Varnish: 32769
107107
-4- VCL_call BACKEND_FETCH
108108
-4- VCL_return fetch
109-
-4- Timestamp Fetch: 1762954000.460678 0.001860 0.000015
110-
-4- Timestamp Connected: 1762954000.460853 0.002035 0.000174
111-
-4- BackendOpen 30 whoami 192.168.50.11 80 192.168.50.10 50350 connect
112-
-4- Timestamp Bereq: 1762954000.460888 0.002070 0.000034
109+
-4- Timestamp Fetch: 1763028889.799329 0.000226 0.000004
110+
-4- Timestamp Connected: 1763028889.799422 0.000319 0.000093
111+
-4- BackendOpen 30 whoami 192.168.50.12 80 192.168.50.10 60360 connect
112+
-4- Timestamp Bereq: 1763028889.799433 0.000330 0.000010
113113
-4- BerespProtocol HTTP/1.1
114114
-4- BerespStatus 200
115115
-4- BerespReason OK
116-
-4- BerespHeader Date: Wed, 12 Nov 2025 13:26:40 GMT
117-
-4- BerespHeader Content-Length: 315
116+
-4- BerespHeader Date: Thu, 13 Nov 2025 10:14:49 GMT
117+
-4- BerespHeader Content-Length: 323
118118
-4- BerespHeader Content-Type: text/plain; charset=utf-8
119-
-4- Timestamp Beresp: 1762954000.461784 0.002966 0.000896
120-
-4- TTL RFC 120 10 0 1762954000 1762954000 1762954000 0 0 cacheable
119+
-4- Timestamp Beresp: 1763028889.799775 0.000671 0.000341
120+
-4- TTL RFC 120 10 0 1763028890 1763028890 1763028889 0 0 cacheable
121121
-4- VCL_call BACKEND_RESPONSE
122-
-4- BerespHeader Cache-Control: max-age=5
123-
-4- TTL VCL 5 10 0 1762954000 cacheable
124122
-4- VCL_return deliver
125-
-4- Timestamp Process: 1762954000.461832 0.003015 0.000048
126-
-4- Filters
123+
-4- Timestamp Process: 1763028889.799785 0.000682 0.000010
124+
-4- Filters
127125
-4- Storage malloc s0
128126
-4- Fetch_Body 3 length stream
129127
-4- BackendClose 30 whoami recycle
130-
-4- Timestamp BerespBody: 1762954000.461914 0.003096 0.000081
131-
-4- Length 315
132-
-4- BereqAcct 436 0 436 236 315 551
133-
-4- End
128+
-4- Timestamp BerespBody: 1763028889.799812 0.000709 0.000026
129+
-4- Length 323
130+
-4- BereqAcct 433 0 433 300 323 623
131+
-4- End
132+

assets/examples/cached.txt

Lines changed: 47 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,47 @@
1-
* << Session >> 6
2-
- Begin sess 0 HTTP/1
3-
- SessOpen 192.168.65.1 61200 http 192.168.50.10 80 1762612268.273411 28
4-
- Link req 9 rxreq
5-
- SessClose REM_CLOSE 0.111
6-
- End
7-
** << Request >> 9
8-
-- Begin req 6 rxreq
9-
-- Timestamp Start: 1762612268.383000 0.000000 0.000000
10-
-- Timestamp Req: 1762612268.383000 0.000000 0.000000
11-
-- VCL_use boot
12-
-- ReqStart 192.168.65.1 61200 http
13-
-- ReqMethod GET
14-
-- ReqURL /item
15-
-- ReqProtocol HTTP/1.1
16-
-- ReqHeader Host: varnishlog.iou.re
17-
-- ReqHeader Accept: */*
18-
-- ReqHeader X-Forwarded-For: 1.2.3.4
19-
-- ReqHeader Cached: 1
20-
-- ReqHeader User-Agent: hurl/7.0.0
21-
-- ReqUnset X-Forwarded-For: 1.2.3.4
22-
-- ReqHeader X-Forwarded-For: 1.2.3.4, 192.168.65.1
23-
-- ReqHeader Via: 1.1 4dab8a10025c (Varnish/7.7)
24-
-- VCL_call RECV
25-
-- ReqHeader whoami: 1
26-
-- VCL_return hash
27-
-- VCL_call HASH
28-
-- VCL_return lookup
29-
-- Hit 8 4.892716 10.000000 0.000000
30-
-- VCL_call HIT
31-
-- VCL_return deliver
32-
-- RespProtocol HTTP/1.1
33-
-- RespStatus 200
34-
-- RespReason OK
35-
-- RespHeader Date: Sat, 08 Nov 2025 14:31:08 GMT
36-
-- RespHeader Content-Length: 304
37-
-- RespHeader Content-Type: text/plain; charset=utf-8
38-
-- RespHeader Cache-Control: max-age=5
39-
-- RespHeader X-Varnish: 9 8
40-
-- RespHeader Age: 0
41-
-- RespHeader Via: 1.1 4dab8a10025c (Varnish/7.7)
42-
-- RespHeader Accept-Ranges: bytes
43-
-- VCL_call DELIVER
44-
-- VCL_return deliver
45-
-- Timestamp Process: 1762612268.383100 0.000100 0.000100
46-
-- Filters
47-
-- RespHeader Connection: keep-alive
48-
-- Timestamp Resp: 1762612268.383226 0.000226 0.000126
49-
-- ReqAcct 121 0 121 251 304 555
50-
-- End
1+
* << Request >> 4
2+
- Begin req 1 rxreq
3+
- Timestamp Start: 1763030681.497130 0.000000 0.000000
4+
- Timestamp Req: 1763030681.497130 0.000000 0.000000
5+
- VCL_use boot
6+
- ReqStart 192.168.65.1 54660 http
7+
- ReqMethod GET
8+
- ReqURL /item
9+
- ReqProtocol HTTP/1.1
10+
- ReqHeader Host: varnishlog.iou.re
11+
- ReqHeader Accept: */*
12+
- ReqHeader X-Forwarded-For: 1.2.3.4
13+
- ReqHeader Cached: 1
14+
- ReqHeader User-Agent: hurl/7.0.0
15+
- ReqUnset X-Forwarded-For: 1.2.3.4
16+
- ReqHeader X-Forwarded-For: 1.2.3.4, 192.168.65.1
17+
- ReqHeader Via: 1.1 e088e52945df (Varnish/7.7)
18+
- VCL_call RECV
19+
- VCL_Log start custom recv
20+
- ReqHeader whoami: 1
21+
- VCL_Log end custom recv
22+
- VCL_return hash
23+
- VCL_call HASH
24+
- VCL_return lookup
25+
- Hit 3 4.898911 10.000000 0.000000
26+
- VCL_call HIT
27+
- VCL_return deliver
28+
- RespProtocol HTTP/1.1
29+
- RespStatus 200
30+
- RespReason OK
31+
- RespHeader Date: Thu, 13 Nov 2025 10:44:41 GMT
32+
- RespHeader Content-Length: 304
33+
- RespHeader Content-Type: text/plain; charset=utf-8
34+
- RespHeader Cache-Control: max-age=5
35+
- RespHeader X-Varnish: 4 3
36+
- RespHeader Age: 0
37+
- RespHeader Via: 1.1 e088e52945df (Varnish/7.7)
38+
- RespHeader Accept-Ranges: bytes
39+
- VCL_call DELIVER
40+
- VCL_return deliver
41+
- Timestamp Process: 1763030681.497166 0.000035 0.000035
42+
- Filters
43+
- RespHeader Connection: keep-alive
44+
- Timestamp Resp: 1763030681.497187 0.000056 0.000020
45+
- ReqAcct 121 0 121 251 304 555
46+
- End
47+

0 commit comments

Comments
 (0)