Skip to content

Commit 82ed284

Browse files
committed
Update expression examples (request body fields)
1 parent bc1080c commit 82ed284

File tree

1 file changed

+38
-23
lines changed

1 file changed

+38
-23
lines changed

src/content/docs/ruleset-engine/rules-language/fields/http-request-body.mdx

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,14 @@ The return value may be truncated if [`http.request.body.truncated`](#httpreques
7272
- **Whitespace:** preserved
7373
- **Non-ASCII:** preserved
7474

75-
Example:
76-
77-
```txt
78-
any(http.request.body.form["username"][*] == "admin")
79-
```
80-
8175
Example value:
76+
8277
`{username": ["admin"]}`
8378

79+
Example:
80+
81+
`any(http.request.body.form["username"][*] == "admin")`
82+
8483
## `http.request.body.form.names`
8584

8685
`http.request.body.form.names` <Type text='Array<String>' />
@@ -97,16 +96,14 @@ The return value may be truncated if [`http.request.body.truncated`](#httpreques
9796
- **Whitespace:** preserved
9897
- **Non-ASCII:** preserved
9998

100-
Example:
101-
102-
```txt
103-
any(http.request.body.form.names[*] == "username")
104-
```
105-
10699
Example value:
107100

108101
`["username"]`
109102

103+
Example:
104+
105+
`any(http.request.body.form.names[*] == "username")`
106+
110107
## `http.request.body.form.values`
111108

112109
`http.request.body.form.values` <Type text='Array<String>' />
@@ -123,16 +120,14 @@ The return value may be truncated if [`http.request.body.truncated`](#httpreques
123120
- **Whitespace:** preserved
124121
- **Non-ASCII:** preserved
125122

126-
Example:
127-
128-
```txt
129-
any(http.request.body.form.values[*] == "admin")
130-
```
131-
132123
Example value:
133124

134125
`["admin"]`
135126

127+
Example:
128+
129+
`any(http.request.body.form.values[*] == "admin")`
130+
136131
## `http.request.body.mime`
137132

138133
`http.request.body.mime` <Type text='String' />
@@ -141,9 +136,13 @@ The MIME type of the request detected from the request body.
141136

142137
Supports the most common MIME types of the following general categories: video, audio, image, application, text.
143138

139+
Example value:
140+
141+
`"image/jpeg"`
142+
144143
Example:
145144

146-
`image/jpeg`
145+
`http.request.body.mime in {"image/bmp" "image/gif" "image/jpeg" "image/png" "image/tiff"}`
147146

148147
This field is available on all Cloudflare plans.
149148

@@ -155,7 +154,11 @@ A Map (or associative array) representation of multipart names to multipart valu
155154

156155
Example value:
157156

158-
`{"username": ["alice_doe"], "picture": [<binary_content_of_file>]}`
157+
`{"username": ["alice_doe"], "role": ["editor"], "picture": [<binary_content_of_file>]}`
158+
159+
Example:
160+
161+
`any(http.request.body.multipart["role"][*] == "admin")`
159162

160163
## `http.request.body.multipart.names`
161164

@@ -181,6 +184,10 @@ Example value:
181184

182185
`["alice_doe", <binary_content_of_file>]`
183186

187+
Example:
188+
189+
`any(http.request.body.multipart.values[*] == "alice_doe")`
190+
184191
## `http.request.body.multipart.content_types`
185192

186193
`http.request.body.multipart.content_types` <Type text='Array<Array<String>>' />
@@ -203,11 +210,11 @@ List of `Content-Disposition` headers for each part in the multipart body.
203210

204211
Example value:
205212

206-
`[["form-data; name=\"username\""], ["form-data;name=\"picture\""]]`
213+
`[["form-data; name=\"username\""], ["form-data; name=\"picture\""]]`
207214

208215
Example:
209216

210-
`any(http.request.body.multipart.content_dispositions[*][0] in {"form-data; name=\"username\"" "form-data;name=\"picture\""})`
217+
`any(http.request.body.multipart.content_dispositions[*][0] in {"form-data; name=\"username\"" "form-data; name=\"picture\""})`
211218

212219
## `http.request.body.multipart.content_transfer_encodings`
213220

@@ -217,7 +224,11 @@ List of `Content-Transfer-Encoding` headers for each part in the multipart body.
217224

218225
Example value:
219226

220-
`[["quoted-printable"], ["quoted-printable"]]`
227+
`[["quoted-printable"], ["base64"]]`
228+
229+
Example:
230+
231+
`any(http.request.body.multipart.content_transfer_encodings[*][0] == "binary")`
221232

222233
## `http.request.body.multipart.filenames`
223234

@@ -228,3 +239,7 @@ List of filenames for each part in the multipart body.
228239
Example value:
229240

230241
`[["file1.txt"], ["photo.jpg"]]`
242+
243+
Example:
244+
245+
`any(http.request.body.multipart.filenames[*][0] in {"token.txt" "password.txt"})`

0 commit comments

Comments
 (0)