summaryrefslogtreecommitdiffstats
path: root/reg-tests/http-messaging/http_transfer_encoding.vtc
blob: 322dfe29acabd9d6ffc9f25cb04c8674a858e687 (plain)
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
varnishtest "A test to validate Transfer-Encoding header conformance to the spec"

feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev0)'"
feature ignore_unknown_macro

server s1 {
    rxreq
    expect req.http.content-length == <undef>
    expect req.http.transfer-encoding == "chunked"
    expect req.bodylen == 0
    expect req.body == ""
    txresp -status 200

    accept
    rxreq
    expect req.http.content-length == <undef>
    expect req.http.transfer-encoding == "chunked"
    expect req.bodylen == 0
    expect req.body == ""
    txresp -status 200

    accept
    rxreq
    send "HTTP/1.0 200 Ok\r\n"
    send "Transfer-Encoding: chunked\r\n\r\n"
    send "0\r\n\r\n"

    accept
    rxreq
    send "HTTP/1.1 200 Ok\r\n"
    send "Transfer-Encoding: chunked\r\n"
    send "Content-Length: 30\r\n\r\n"
    send "0\r\n\r\nResponse splitting attach"

    accept
    rxreq
    expect req.url == "/1"
    expect req.http.transfer-encoding == "chunked"
    expect req.http.te == "trailers"
    txresp

    rxreq
    expect req.url == "/2"
    expect req.http.transfer-encoding == "chunked"
    expect req.http.te == <undef>
    txresp

    rxreq
    expect req.url == "/3"
    expect req.http.transfer-encoding == "chunked"
    expect req.http.te == <undef>
    txresp
} -start

server s2 {
    rxreq
    txresp -nolen \
        -hdr "Transfer-Encoding: chunked, chunked" \
        -body "0\r\n\r\n"

    accept
    rxreq
    txresp -nolen \
        -hdr "Transfer-Encoding: chunked, gzip, chunked" \
        -body "0\r\n\r\n"

    accept
    rxreq
    txresp -nolen \
        -hdr "Transfer-Encoding: chunked, gzip" \
        -body "0\r\n\r\n"

    accept
    rxreq
    txresp \
        -hdr "Transfer-Encoding: gzip"
} -start

haproxy h1 -conf {
    defaults
        mode http
        timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
        timeout client  "${HAPROXY_TEST_TIMEOUT-5s}"
        timeout server  "${HAPROXY_TEST_TIMEOUT-5s}"

    listen fe1
        bind "fd@${fe1}"
        server s1 ${s1_addr}:${s1_port}

    listen fe2
        bind "fd@${fe2}"
        server s2 ${s2_addr}:${s2_port}
} -start

client c1 -connect ${h1_fe1_sock} {
    txreq -method POST -nolen \
        -hdr "Transfer-Encoding: chunked" \
        -hdr "Content-Length: 31" \
        -body "0\r\n\r\nGET /smuggled HTTP/1.1\r\n\r\n"
    rxresp
    expect resp.status == 200
    expect resp.http.connection == "close"
    expect_close
} -run

client c2 -connect ${h1_fe1_sock} {
    send "POST / HTTP/1.0\r\n"
    send "Transfer-Encoding: chunked\r\n\r\n"
    send "0\r\n\r\n"
    rxresp
    expect resp.status == 200
    expect_close
} -run

client c3 -connect ${h1_fe1_sock} {
    txreq
    rxresp
    expect resp.status == 200
    expect resp.http.content-length == <undef>
    expect resp.http.transfer-encoding == "chunked"
    expect resp.bodylen == 0
    expect resp.body == ""
    expect_close
} -run

client c4 -connect ${h1_fe1_sock} {
    txreq
    rxresp
    expect resp.status == 200
    expect resp.http.content-length == <undef>
    expect resp.http.transfer-encoding == "chunked"
    expect resp.bodylen == 0
    expect resp.body == ""
} -run

client c5 -connect ${h1_fe1_sock} {
    txreq -method POST -url "/1" -nolen \
        -hdr "Transfer-Encoding: chunked" \
        -hdr "TE: trailers, gzip" \
        -body "0\r\n\r\n"
    rxresp
    expect resp.status == 200

    txreq -method POST -url "/2" -nolen \
        -hdr "Transfer-Encoding: chunked" \
        -hdr "TE: gzip" \
        -body "0\r\n\r\n"
    rxresp
    expect resp.status == 200

    txreq -method POST -url "/3" -nolen \
        -hdr "Transfer-Encoding: chunked" \
        -hdr "TE: trailers;q=0.5" \
        -body "0\r\n\r\n"
    rxresp
    expect resp.status == 200
} -run

client c6 -connect ${h1_fe1_sock} {
    txreq -nolen \
        -hdr "Transfer-Encoding: chunked, chunked" \
        -body "0\r\n\r\n"
    rxresp
    expect resp.status == 400
} -run

client c7 -connect ${h1_fe1_sock} {
    txreq -nolen \
        -hdr "Transfer-Encoding: chunked, gzip, chunked" \
        -body "0\r\n\r\n"
    rxresp
    expect resp.status == 400
} -run

client c8 -connect ${h1_fe1_sock} {
    txreq -nolen \
        -hdr "Transfer-Encoding: chunked, gzip" \
        -body "0\r\n\r\n"
    rxresp
    expect resp.status == 400
} -run

client c9 -connect ${h1_fe1_sock} {
    txreq \
        -hdr "Transfer-Encoding: gzip"
    rxresp
    expect resp.status == 400
} -run

client c10 -connect ${h1_fe1_sock} {
    txreq -nolen \
        -hdr "Transfer-Encoding: gzip, chunked" \
        -body "0\r\n\r\n"
    rxresp
    expect resp.status == 422
} -run

client c11 -connect ${h1_fe2_sock} {
    txreq
    rxresp
    expect resp.status == 502
} -run -repeat 4